@webinex/chatify 2.0.0-alpha8 → 2.0.0-alpha9

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.
Files changed (216) hide show
  1. package/dist/Chatify-DGRV4QKP.js +2203 -0
  2. package/dist/Chatify-DGRV4QKP.js.map +1 -0
  3. package/dist/Chatify.css +670 -0
  4. package/dist/audit.css +60 -0
  5. package/dist/audit.js +242 -0
  6. package/dist/audit.js.map +1 -0
  7. package/dist/index.js +97 -0
  8. package/dist/index.js.map +1 -0
  9. package/dist/types/audit/AuditChatList.d.ts +9 -0
  10. package/dist/types/audit/AuditConversationPanel.d.ts +10 -0
  11. package/dist/types/audit/AuditPanel.d.ts +14 -0
  12. package/dist/types/audit/AuditPanelCustomizeValue.d.ts +9 -0
  13. package/dist/types/audit/AuditSearch.d.ts +5 -0
  14. package/dist/types/audit/AuditSearchValue.d.ts +14 -0
  15. package/dist/types/audit/auditApi.d.ts +97 -0
  16. package/dist/types/audit/index.d.ts +17 -0
  17. package/dist/types/core/api/api.d.ts +17295 -0
  18. package/dist/{esm/types → types}/core/api/baseApi.d.ts +1 -1
  19. package/dist/{esm/types → types}/core/client.d.ts +3 -3
  20. package/dist/{esm/types → types}/core/types.d.ts +5 -0
  21. package/dist/types/ui/Chat/ChatEditableHeaderName.d.ts +1 -0
  22. package/dist/types/ui/Chat/ChatHeaderActions.d.ts +1 -0
  23. package/dist/{esm/types → types}/ui/Chat/ChatView.d.ts +1 -2
  24. package/dist/types/ui/Chat/Members/ChatMembersButton.d.ts +1 -0
  25. package/dist/types/ui/Chat/Members/ChatMembersPanel.d.ts +1 -0
  26. package/dist/types/ui/Chat/Members/ChatMembersPreview.d.ts +1 -0
  27. package/dist/{esm/types → types}/ui/ChatGroup/ChatGroupPanel.d.ts +2 -2
  28. package/dist/types/ui/ChatGroup/Create/CreateChatButton.d.ts +1 -0
  29. package/dist/{esm/types → types}/ui/ChatGroup/Create/CreateChatForm.d.ts +1 -2
  30. package/dist/types/ui/ChatGroup/Create/CreateChatMemberInput.d.ts +4 -0
  31. package/dist/types/ui/ChatGroup/Create/CreateChatNameInput.d.ts +4 -0
  32. package/dist/types/ui/ChatGroup/Create/CreateChatPanel.d.ts +1 -0
  33. package/dist/types/ui/ChatGroup/Layout/ChatGroupAside.d.ts +1 -0
  34. package/dist/types/ui/ChatGroup/Layout/ChatGroupBody.d.ts +1 -0
  35. package/dist/types/ui/ChatGroup/Layout/ChatGroupFooter.d.ts +1 -0
  36. package/dist/types/ui/ChatGroup/Layout/ChatGroupHeader.d.ts +1 -0
  37. package/dist/types/ui/ChatGroup/Layout/ChatGroupMain.d.ts +1 -0
  38. package/dist/types/ui/ChatGroup/List/ChatListPanel.d.ts +1 -0
  39. package/dist/types/ui/ChatGroup/List/index.d.ts +6 -0
  40. package/dist/types/ui/Chatify.d.ts +9 -0
  41. package/dist/{esm/types → types}/ui/Conversation/Conversation.d.ts +2 -3
  42. package/dist/types/ui/Conversation/ConversationActions.d.ts +1 -0
  43. package/dist/types/ui/Conversation/ConversationBody.d.ts +1 -0
  44. package/dist/{esm/types → types}/ui/Conversation/ConversationContext.d.ts +6 -5
  45. package/dist/types/ui/Conversation/ConversationHeader.d.ts +1 -0
  46. package/dist/types/ui/Conversation/ConversationName.d.ts +1 -0
  47. package/dist/types/ui/Conversation/InputBox/InputBox.d.ts +1 -0
  48. package/dist/types/ui/Conversation/InputBox/InputBoxFile.d.ts +7 -0
  49. package/dist/types/ui/Conversation/InputBox/InputBoxFileList.d.ts +7 -0
  50. package/dist/types/ui/Conversation/InputBox/InputFilesBox.d.ts +11 -0
  51. package/dist/types/ui/Conversation/InputBox/InputSubmitButtonBox.d.ts +6 -0
  52. package/dist/{esm/types → types}/ui/Conversation/InputBox/InputTextBox.d.ts +1 -1
  53. package/dist/types/ui/Conversation/Message/MessageAuthor.d.ts +2 -0
  54. package/dist/types/ui/Conversation/Message/MessageBox.d.ts +5 -0
  55. package/dist/types/ui/Conversation/Message/MessageContent.d.ts +2 -0
  56. package/dist/types/ui/Conversation/Message/MessageFile.d.ts +5 -0
  57. package/dist/types/ui/Conversation/Message/MessageFileList.d.ts +2 -0
  58. package/dist/types/ui/Conversation/Message/MessageInfoBox.d.ts +2 -0
  59. package/dist/{esm/types → types}/ui/Conversation/Message/MessageRow.d.ts +1 -1
  60. package/dist/types/ui/Conversation/Message/MessageText.d.ts +2 -0
  61. package/dist/types/ui/Conversation/SendingMessage/SendingMessageBox.d.ts +6 -0
  62. package/dist/types/ui/Conversation/SendingMessage/SendingMessageContent.d.ts +2 -0
  63. package/dist/types/ui/Conversation/SendingMessage/SendingMessageInfoBox.d.ts +2 -0
  64. package/dist/types/ui/Conversation/SendingMessage/SendingMessageText.d.ts +2 -0
  65. package/dist/types/ui/Conversation/SystemMessage/SystemMessageBox.d.ts +5 -0
  66. package/dist/{esm/types → types}/ui/Conversation/SystemMessage/SystemMessageRow.d.ts +1 -1
  67. package/dist/types/ui/Thread/ThreadActions.d.ts +1 -0
  68. package/dist/{esm/types → types}/ui/Thread/ThreadContext.d.ts +1 -1
  69. package/dist/types/ui/common/Avatar.d.ts +5 -0
  70. package/dist/types/ui/common/ChatList/ChatList.d.ts +16 -0
  71. package/dist/types/ui/common/ChatList/ChatListItemAvatar.d.ts +2 -0
  72. package/dist/types/ui/common/ChatList/ChatListItemBox.d.ts +9 -0
  73. package/dist/types/ui/common/ChatList/ChatListItemLastMessage.d.ts +2 -0
  74. package/dist/types/ui/common/ChatList/ChatListItemLastMessageAuthor.d.ts +2 -0
  75. package/dist/types/ui/common/ChatList/ChatListItemLastMessageContent.d.ts +2 -0
  76. package/dist/types/ui/common/ChatList/ChatListItemLastMessageSentAt.d.ts +2 -0
  77. package/dist/types/ui/common/ChatList/ChatListItemName.d.ts +2 -0
  78. package/dist/types/ui/common/ChatList/ChatListItemUnreadCount.d.ts +2 -0
  79. package/dist/types/ui/common/ChatList/ChatListValue.d.ts +8 -0
  80. package/dist/{esm/types/ui/ChatGroup/List → types/ui/common/ChatList}/index.d.ts +1 -0
  81. package/dist/types/ui/common/Icon.d.ts +21 -0
  82. package/dist/types/ui/common/MessageSkeleton.d.ts +4 -0
  83. package/dist/{esm/types → types}/ui/common/index.d.ts +1 -0
  84. package/dist/{esm/types → types}/ui/customize.d.ts +1 -1
  85. package/dist/{esm/types → types}/ui/index.d.ts +1 -3
  86. package/dist/{esm/types → types}/ui/localizer.d.ts +7 -2
  87. package/package.json +39 -52
  88. package/src/audit/AuditChatList.tsx +25 -0
  89. package/src/audit/AuditConversationPanel.tsx +48 -0
  90. package/src/audit/AuditPanel.tsx +76 -0
  91. package/src/audit/AuditPanelCustomizeValue.ts +11 -0
  92. package/src/audit/AuditSearch.tsx +89 -0
  93. package/src/audit/AuditSearchValue.tsx +42 -0
  94. package/src/audit/auditApi.tsx +113 -0
  95. package/src/audit/index.d.ts +18 -0
  96. package/src/audit/index.tsx +28 -0
  97. package/src/audit/styles.scss +72 -0
  98. package/src/core/client.ts +1 -1
  99. package/src/core/debounce.ts +1 -1
  100. package/src/core/types.tsx +9 -0
  101. package/src/styles/aside.scss +0 -136
  102. package/src/styles/chat-list.scss +138 -0
  103. package/src/styles/chat.scss +0 -198
  104. package/src/styles/conversation.scss +200 -0
  105. package/src/styles/index.scss +2 -0
  106. package/src/ui/Chat/ChatEditableHeaderName.tsx +1 -1
  107. package/src/ui/Chat/Members/ChatMembersPreview.tsx +1 -1
  108. package/src/ui/ChatGroup/ChatGroupPanel.tsx +2 -2
  109. package/src/ui/ChatGroup/Layout/ChatGroupAside.tsx +2 -2
  110. package/src/ui/ChatGroup/List/ChatListPanel.tsx +28 -0
  111. package/src/ui/ChatGroup/List/index.ts +6 -29
  112. package/src/ui/Chatify.tsx +7 -1
  113. package/src/ui/Conversation/Conversation.tsx +15 -1
  114. package/src/ui/Conversation/ConversationActions.tsx +8 -1
  115. package/src/ui/Conversation/ConversationContext.ts +4 -3
  116. package/src/ui/Conversation/ConversationHeader.tsx +4 -8
  117. package/src/ui/Conversation/InputBox/InputBox.tsx +4 -0
  118. package/src/ui/Conversation/InputBox/InputTextBox.tsx +1 -1
  119. package/src/ui/Conversation/Message/MessageInfoBox.tsx +1 -1
  120. package/src/ui/Conversation/ReadObserver/MessageReadObserver.tsx +1 -1
  121. package/src/ui/common/ChatList/ChatList.tsx +84 -0
  122. package/src/ui/{ChatGroup/List → common/ChatList}/ChatListItemBox.tsx +11 -5
  123. package/src/ui/{ChatGroup/List → common/ChatList}/ChatListItemLastMessageAuthor.tsx +3 -3
  124. package/src/ui/{ChatGroup/List → common/ChatList}/ChatListItemLastMessageContent.tsx +4 -4
  125. package/src/ui/{ChatGroup/List → common/ChatList}/ChatListItemLastMessageSentAt.tsx +1 -1
  126. package/src/ui/{ChatGroup/List → common/ChatList}/ChatListItemUnreadCount.tsx +1 -1
  127. package/src/ui/common/ChatList/ChatListValue.ts +9 -0
  128. package/src/ui/common/ChatList/index.ts +32 -0
  129. package/src/ui/common/Icon.tsx +15 -13
  130. package/src/ui/common/index.ts +1 -0
  131. package/src/ui/index.ts +3 -3
  132. package/src/ui/localizer.tsx +14 -2
  133. package/dist/css/chatify.css +0 -664
  134. package/dist/esm/index.js +0 -11
  135. package/dist/esm/index.js.map +0 -1
  136. package/dist/esm/types/core/api/api.d.ts +0 -12696
  137. package/dist/esm/types/ui/Chat/ChatEditableHeaderName.d.ts +0 -2
  138. package/dist/esm/types/ui/Chat/ChatHeaderActions.d.ts +0 -2
  139. package/dist/esm/types/ui/Chat/Members/ChatMembersButton.d.ts +0 -2
  140. package/dist/esm/types/ui/Chat/Members/ChatMembersPanel.d.ts +0 -2
  141. package/dist/esm/types/ui/Chat/Members/ChatMembersPreview.d.ts +0 -2
  142. package/dist/esm/types/ui/ChatGroup/Create/CreateChatButton.d.ts +0 -2
  143. package/dist/esm/types/ui/ChatGroup/Create/CreateChatMemberInput.d.ts +0 -5
  144. package/dist/esm/types/ui/ChatGroup/Create/CreateChatNameInput.d.ts +0 -5
  145. package/dist/esm/types/ui/ChatGroup/Create/CreateChatPanel.d.ts +0 -2
  146. package/dist/esm/types/ui/ChatGroup/Layout/ChatGroupAside.d.ts +0 -2
  147. package/dist/esm/types/ui/ChatGroup/Layout/ChatGroupBody.d.ts +0 -2
  148. package/dist/esm/types/ui/ChatGroup/Layout/ChatGroupFooter.d.ts +0 -2
  149. package/dist/esm/types/ui/ChatGroup/Layout/ChatGroupHeader.d.ts +0 -2
  150. package/dist/esm/types/ui/ChatGroup/Layout/ChatGroupMain.d.ts +0 -2
  151. package/dist/esm/types/ui/ChatGroup/List/ChatList.d.ts +0 -2
  152. package/dist/esm/types/ui/ChatGroup/List/ChatListItemAvatar.d.ts +0 -3
  153. package/dist/esm/types/ui/ChatGroup/List/ChatListItemBox.d.ts +0 -6
  154. package/dist/esm/types/ui/ChatGroup/List/ChatListItemLastMessage.d.ts +0 -3
  155. package/dist/esm/types/ui/ChatGroup/List/ChatListItemLastMessageAuthor.d.ts +0 -3
  156. package/dist/esm/types/ui/ChatGroup/List/ChatListItemLastMessageContent.d.ts +0 -3
  157. package/dist/esm/types/ui/ChatGroup/List/ChatListItemLastMessageSentAt.d.ts +0 -3
  158. package/dist/esm/types/ui/ChatGroup/List/ChatListItemName.d.ts +0 -3
  159. package/dist/esm/types/ui/ChatGroup/List/ChatListItemUnreadCount.d.ts +0 -3
  160. package/dist/esm/types/ui/Chatify.d.ts +0 -8
  161. package/dist/esm/types/ui/Conversation/ConversationActions.d.ts +0 -2
  162. package/dist/esm/types/ui/Conversation/ConversationBody.d.ts +0 -2
  163. package/dist/esm/types/ui/Conversation/ConversationHeader.d.ts +0 -2
  164. package/dist/esm/types/ui/Conversation/ConversationName.d.ts +0 -2
  165. package/dist/esm/types/ui/Conversation/InputBox/InputBox.d.ts +0 -2
  166. package/dist/esm/types/ui/Conversation/InputBox/InputBoxFile.d.ts +0 -8
  167. package/dist/esm/types/ui/Conversation/InputBox/InputBoxFileList.d.ts +0 -8
  168. package/dist/esm/types/ui/Conversation/InputBox/InputFilesBox.d.ts +0 -12
  169. package/dist/esm/types/ui/Conversation/InputBox/InputSubmitButtonBox.d.ts +0 -7
  170. package/dist/esm/types/ui/Conversation/Message/MessageAuthor.d.ts +0 -3
  171. package/dist/esm/types/ui/Conversation/Message/MessageBox.d.ts +0 -6
  172. package/dist/esm/types/ui/Conversation/Message/MessageContent.d.ts +0 -3
  173. package/dist/esm/types/ui/Conversation/Message/MessageFile.d.ts +0 -6
  174. package/dist/esm/types/ui/Conversation/Message/MessageFileList.d.ts +0 -3
  175. package/dist/esm/types/ui/Conversation/Message/MessageInfoBox.d.ts +0 -3
  176. package/dist/esm/types/ui/Conversation/Message/MessageText.d.ts +0 -3
  177. package/dist/esm/types/ui/Conversation/SendingMessage/SendingMessageBox.d.ts +0 -7
  178. package/dist/esm/types/ui/Conversation/SendingMessage/SendingMessageContent.d.ts +0 -3
  179. package/dist/esm/types/ui/Conversation/SendingMessage/SendingMessageInfoBox.d.ts +0 -3
  180. package/dist/esm/types/ui/Conversation/SendingMessage/SendingMessageText.d.ts +0 -3
  181. package/dist/esm/types/ui/Conversation/SystemMessage/SystemMessageBox.d.ts +0 -6
  182. package/dist/esm/types/ui/Thread/ThreadActions.d.ts +0 -2
  183. package/dist/esm/types/ui/common/Avatar.d.ts +0 -6
  184. package/dist/esm/types/ui/common/Icon.d.ts +0 -22
  185. package/dist/esm/types/ui/common/MessageSkeleton.d.ts +0 -5
  186. package/dist/index.d.ts +0 -13384
  187. package/src/ui/ChatGroup/List/ChatList.tsx +0 -41
  188. /package/dist/{esm/types → types}/core/api/index.d.ts +0 -0
  189. /package/dist/{esm/types → types}/core/constants.d.ts +0 -0
  190. /package/dist/{esm/types → types}/core/debounce.d.ts +0 -0
  191. /package/dist/{esm/types → types}/core/index.d.ts +0 -0
  192. /package/dist/{esm/types → types}/index.d.ts +0 -0
  193. /package/dist/{esm/types → types}/ui/Chat/ChatContext.d.ts +0 -0
  194. /package/dist/{esm/types → types}/ui/Chat/ChatPanel.d.ts +0 -0
  195. /package/dist/{esm/types → types}/ui/Chat/Members/index.d.ts +0 -0
  196. /package/dist/{esm/types → types}/ui/Chat/index.d.ts +0 -0
  197. /package/dist/{esm/types → types}/ui/ChatGroup/ChatGroupContext.d.ts +0 -0
  198. /package/dist/{esm/types → types}/ui/ChatGroup/Create/index.d.ts +0 -0
  199. /package/dist/{esm/types → types}/ui/ChatGroup/Layout/index.d.ts +0 -0
  200. /package/dist/{esm/types → types}/ui/ChatGroup/index.d.ts +0 -0
  201. /package/dist/{esm/types → types}/ui/Conversation/InputBox/index.d.ts +0 -0
  202. /package/dist/{esm/types → types}/ui/Conversation/Message/index.d.ts +0 -0
  203. /package/dist/{esm/types → types}/ui/Conversation/NextObserver/NextMessagesObserver.d.ts +0 -0
  204. /package/dist/{esm/types → types}/ui/Conversation/NextObserver/index.d.ts +0 -0
  205. /package/dist/{esm/types → types}/ui/Conversation/ReadObserver/MessageReadObserver.d.ts +0 -0
  206. /package/dist/{esm/types → types}/ui/Conversation/ReadObserver/index.d.ts +0 -0
  207. /package/dist/{esm/types → types}/ui/Conversation/SendingMessage/index.d.ts +0 -0
  208. /package/dist/{esm/types → types}/ui/Conversation/SystemMessage/index.d.ts +0 -0
  209. /package/dist/{esm/types → types}/ui/Conversation/index.d.ts +0 -0
  210. /package/dist/{esm/types → types}/ui/Thread/ThreadPanel.d.ts +0 -0
  211. /package/dist/{esm/types → types}/ui/Thread/index.d.ts +0 -0
  212. /package/dist/{esm/types → types}/ui/color.d.ts +0 -0
  213. /package/dist/{esm/types → types}/ui/useFormatter.d.ts +0 -0
  214. /package/src/ui/{ChatGroup/List → common/ChatList}/ChatListItemAvatar.tsx +0 -0
  215. /package/src/ui/{ChatGroup/List → common/ChatList}/ChatListItemLastMessage.tsx +0 -0
  216. /package/src/ui/{ChatGroup/List → common/ChatList}/ChatListItemName.tsx +0 -0
@@ -14,7 +14,7 @@ export const ChatMembersPreview = customize('ChatMembersPreview', () => {
14
14
  }
15
15
 
16
16
  return (
17
- <AntdAvatar.Group maxCount={5}>
17
+ <AntdAvatar.Group max={{ count: 5 }}>
18
18
  {chat.members.map((x) => (
19
19
  <Tooltip key={x.id} title={x.name}>
20
20
  <Avatar account={x} />
@@ -2,7 +2,7 @@ import { CSSProperties, FC, useEffect, useMemo, useRef } from 'react';
2
2
  import { Localizer, LocalizerContext, defaultLocalizer } from '../localizer';
3
3
  import { CreateChatPanelCustomizeValue } from './Create';
4
4
  import { ChatGroupBody, ChatGroupFooter, ChatGroupHeader, ChatGroupLayoutCustomizeValue } from './Layout';
5
- import { ChatListCustomizeValue } from './List';
5
+ import { ChatListPanelCustomizeValue } from './List';
6
6
  import { ChatGroupContext, useChatGroupContext } from './ChatGroupContext';
7
7
  import { chatifyApi } from '../../core';
8
8
  import { CustomizeContext } from '../customize';
@@ -11,7 +11,7 @@ import { ChatViewCustomizeValue } from '../Chat';
11
11
  export interface ChatGroupCustomizeValue
12
12
  extends ChatViewCustomizeValue,
13
13
  CreateChatPanelCustomizeValue,
14
- ChatListCustomizeValue,
14
+ ChatListPanelCustomizeValue,
15
15
  ChatGroupLayoutCustomizeValue {}
16
16
 
17
17
  export interface ChatifyProps {
@@ -1,12 +1,12 @@
1
1
  import { customize } from '../../customize';
2
- import { ChatList } from '../List';
2
+ import { ChatListPanel } from '../List';
3
3
  import { CreateChatButton } from '../Create/CreateChatButton';
4
4
 
5
5
  export const ChatGroupAside = customize('ChatGroupAside', () => {
6
6
  return (
7
7
  <div className="wxchtf-aside">
8
8
  <CreateChatButton />
9
- <ChatList />
9
+ <ChatListPanel />
10
10
  </div>
11
11
  );
12
12
  });
@@ -0,0 +1,28 @@
1
+ import { useMemo } from 'react';
2
+ import { chatifyApi } from '../../../core';
3
+ import { customize } from '../../customize';
4
+ import { useChatGroupContext } from '../ChatGroupContext';
5
+ import { ChatListValue, ChatList } from '../../common';
6
+
7
+ function useData() {
8
+ const { data: chats } = chatifyApi.useGetChatListQuery();
9
+ return useMemo(
10
+ () =>
11
+ chats?.map(
12
+ (x): ChatListValue => ({
13
+ id: x.id,
14
+ name: x.name,
15
+ lastMessage: x.message,
16
+ lastReadMessageId: x.lastReadMessageId,
17
+ }),
18
+ ) ?? [],
19
+ [chats],
20
+ );
21
+ }
22
+
23
+ export const ChatListPanel = customize('ChatListPanel', () => {
24
+ const { chatId, openChat } = useChatGroupContext();
25
+ const data = useData();
26
+
27
+ return <ChatList items={data} selected={chatId} onSelect={openChat} />;
28
+ });
@@ -1,31 +1,8 @@
1
- import { ChatList } from './ChatList';
2
- import { ChatListItemAvatar } from './ChatListItemAvatar';
3
- import { ChatListItemBox } from './ChatListItemBox';
4
- import { ChatListItemLastMessage } from './ChatListItemLastMessage';
5
- import { ChatListItemLastMessageAuthor } from './ChatListItemLastMessageAuthor';
6
- import { ChatListItemLastMessageContent } from './ChatListItemLastMessageContent';
7
- import { ChatListItemLastMessageSentAt } from './ChatListItemLastMessageSentAt';
8
- import { ChatListItemName } from './ChatListItemName';
9
- import { ChatListItemUnreadCount } from './ChatListItemUnreadCount';
1
+ import { ChatListCustomizeValue } from '../../common';
2
+ import { ChatListPanel } from './ChatListPanel';
10
3
 
11
- export * from './ChatList';
12
- export * from './ChatListItemAvatar';
13
- export * from './ChatListItemBox';
14
- export * from './ChatListItemLastMessage';
15
- export * from './ChatListItemLastMessageAuthor';
16
- export * from './ChatListItemLastMessageContent';
17
- export * from './ChatListItemLastMessageSentAt';
18
- export * from './ChatListItemName';
19
- export * from './ChatListItemUnreadCount';
4
+ export * from './ChatListPanel';
20
5
 
21
- export interface ChatListCustomizeValue {
22
- ChatList?: typeof ChatList.Component | null;
23
- ChatListItemAvatar?: typeof ChatListItemAvatar.Component | null;
24
- ChatListItemBox?: typeof ChatListItemBox.Component | null;
25
- ChatListItemLastMessage?: typeof ChatListItemLastMessage.Component | null;
26
- ChatListItemLastMessageAuthor?: typeof ChatListItemLastMessageAuthor.Component | null;
27
- ChatListItemLastMessageContent?: typeof ChatListItemLastMessageContent.Component | null;
28
- ChatListItemLastMessageSentAt?: typeof ChatListItemLastMessageSentAt.Component | null;
29
- ChatListItemName?: typeof ChatListItemName.Component | null;
30
- ChatListItemUnreadCount?: typeof ChatListItemUnreadCount.Component | null;
31
- }
6
+ export type ChatListPanelCustomizeValue = ChatListCustomizeValue & {
7
+ ChatListPanel?: typeof ChatListPanel.Component | null;
8
+ };
@@ -2,8 +2,14 @@ import { ChatPanel } from './Chat';
2
2
  import { ChatGroupPanel } from './ChatGroup';
3
3
  import { ThreadPanel } from './Thread';
4
4
 
5
+ export interface ChatifyType {
6
+ Thread: typeof ThreadPanel;
7
+ ChatGroup: typeof ChatGroupPanel;
8
+ Chat: typeof ChatPanel;
9
+ }
10
+
5
11
  export const Chatify = {
6
12
  Thread: ThreadPanel,
7
13
  ChatGroup: ChatGroupPanel,
8
14
  Chat: ChatPanel,
9
- };
15
+ } as unknown as ChatifyType;
@@ -30,7 +30,19 @@ export interface ConversationCustomizeValue
30
30
  }
31
31
 
32
32
  export const Conversation = customize('Conversation', (props: ConversationProps) => {
33
- const { value, hasMore, messages, nextLoading, onNext, onRead, onSend, isReading, noReadTracking } = props;
33
+ const {
34
+ value,
35
+ hasMore,
36
+ messages,
37
+ nextLoading,
38
+ onNext,
39
+ onRead,
40
+ onSend,
41
+ isReading,
42
+ noReadTracking,
43
+ onClose,
44
+ } = props;
45
+
34
46
  const { id, active, name, lastReadMessageId } = value;
35
47
 
36
48
  const context = useMemo<ConversationContextValue>(
@@ -47,6 +59,7 @@ export const Conversation = customize('Conversation', (props: ConversationProps)
47
59
  onSend,
48
60
  isReading,
49
61
  noReadTracking,
62
+ onClose,
50
63
  }),
51
64
  [
52
65
  id,
@@ -61,6 +74,7 @@ export const Conversation = customize('Conversation', (props: ConversationProps)
61
74
  lastReadMessageId,
62
75
  isReading,
63
76
  noReadTracking,
77
+ onClose,
64
78
  ],
65
79
  );
66
80
 
@@ -1,5 +1,12 @@
1
+ import { Button } from 'antd';
1
2
  import { customize } from '../customize';
3
+ import { useConversation } from './ConversationContext';
4
+ import { Icon } from '../common';
2
5
 
3
6
  export const ConversationActions = customize('ConversationActions', () => {
4
- return null;
7
+ const { onClose } = useConversation();
8
+
9
+ if (!onClose) return null;
10
+
11
+ return <Button onClick={onClose} type="link" icon={<Icon type="close" />} />;
5
12
  });
@@ -15,11 +15,12 @@ export interface ConversationContextValue extends ConversationValue {
15
15
  nextLoading: boolean;
16
16
  noReadTracking?: boolean;
17
17
 
18
- isReading: (id: string) => boolean;
18
+ isReading?: (id: string) => boolean;
19
19
  onNext: () => void;
20
- onSend: (message: MessageBody) => void;
21
- onRead: (id: string) => void;
20
+ onSend?: (message: MessageBody) => void;
21
+ onRead?: (id: string) => void;
22
22
  flippo?: Flippo;
23
+ onClose?: () => void;
23
24
  }
24
25
 
25
26
  export const ConversationContext = React.createContext<ConversationContextValue>(undefined!);
@@ -1,22 +1,18 @@
1
1
  import { Col, Row } from 'antd';
2
- import { customize, useCustomize } from '../customize';
2
+ import { customize } from '../customize';
3
3
  import { ConversationName } from './ConversationName';
4
4
  import { ConversationActions } from './ConversationActions';
5
5
 
6
6
  export const ConversationHeader = customize('ConversationHeader', () => {
7
- const Actions = useCustomize(ConversationActions);
8
-
9
7
  return (
10
8
  <div className="wxchtf-conversation-header">
11
9
  <Row justify="space-between" align="middle">
12
10
  <Col>
13
11
  <ConversationName />
14
12
  </Col>
15
- {Actions && (
16
- <Col className="wxchtf-conversation-actions">
17
- <Actions />
18
- </Col>
19
- )}
13
+ <Col className="wxchtf-conversation-actions">
14
+ <ConversationActions />
15
+ </Col>
20
16
  </Row>
21
17
  </div>
22
18
  );
@@ -15,6 +15,10 @@ function useFormState() {
15
15
  const { onUpload, files, loading, setFiles, showFileBox, onDeleteFile } = useFlippoInputFileBox();
16
16
 
17
17
  const onSubmit = useCallback(() => {
18
+ if (!onSend) {
19
+ return;
20
+ }
21
+
18
22
  const textValue = text.trim().length === 0 ? null : text.trim();
19
23
 
20
24
  if ((!textValue && files.length === 0) || loading) {
@@ -1,6 +1,6 @@
1
1
  import { Input } from 'antd';
2
2
  import { customize } from '../../customize';
3
- import isHotkey from 'is-hotkey';
3
+ import { isHotkey } from 'is-hotkey';
4
4
  import { RefObject, memo, useCallback } from 'react';
5
5
  import { useLocalizer } from '../../localizer';
6
6
  import { TextAreaProps } from 'antd/es/input';
@@ -12,7 +12,7 @@ export const MessageInfoBox = customize('MessageInfoBox', (props: MessageBoxProp
12
12
  const my = sentBy.id === me;
13
13
  const localizer = useLocalizer();
14
14
  const isRead = lastReadMessageId != null && id.localeCompare(lastReadMessageId) <= 0;
15
- const reading = !isRead && isReading(id);
15
+ const reading = !isRead && isReading?.(id);
16
16
 
17
17
  return (
18
18
  <div className="wxchtf-message-info-box">
@@ -20,7 +20,7 @@ const Observer: FC<MessageReadObserverProps> = (props) => {
20
20
  new IntersectionObserver(([entry]) => {
21
21
  if (entry.isIntersecting && !readRef.current) {
22
22
  readRef.current = true;
23
- onRead(message.id);
23
+ onRead?.(message.id);
24
24
  }
25
25
  }),
26
26
 
@@ -0,0 +1,84 @@
1
+ import { Menu, MenuProps } from 'antd';
2
+ import { useMemo } from 'react';
3
+ import { ChatListItemBox } from './ChatListItemBox';
4
+ import { customize } from '../../customize';
5
+ import { ChatListValue } from './ChatListValue';
6
+ import { useLocalizer } from '../../localizer';
7
+ import { messageSequencePart } from '../../../core';
8
+
9
+ export interface ChatListProps {
10
+ className?: string;
11
+ items: ChatListValue[];
12
+ selected: string | null;
13
+ onSelect?: (id: string) => void;
14
+
15
+ /**
16
+ * If true, do not show read status.
17
+ */
18
+ noRead?: boolean;
19
+
20
+ /**
21
+ * If set, shows a message at the bottom indicating that only the top N chats are shown.
22
+ */
23
+ top?: number;
24
+ }
25
+
26
+ function useOnSelect(props: ChatListProps) {
27
+ const { onSelect } = props;
28
+
29
+ return useMemo(
30
+ () =>
31
+ onSelect
32
+ ? (info: Parameters<NonNullable<MenuProps['onSelect']>>[0]) => onSelect(info.key as string)
33
+ : undefined,
34
+ [onSelect],
35
+ );
36
+ }
37
+
38
+ function useMenuItems(props: ChatListProps) {
39
+ //28b2a1a6-c052-4761-ad2d-95ce36d59f06-000000001
40
+ const { items, noRead, top } = props;
41
+ const localizer = useLocalizer();
42
+
43
+ return useMemo<MenuProps['items']>(() => {
44
+ const result = items
45
+ ?.slice()
46
+ .sort(
47
+ (a, b) => -messageSequencePart(a.lastMessage.id).localeCompare(messageSequencePart(b.lastMessage.id)),
48
+ )
49
+ .map((x) => ({ key: x.id, label: <ChatListItemBox chat={x} noRead={noRead} /> }));
50
+
51
+ if (top != null) {
52
+ return [
53
+ ...result,
54
+ {
55
+ type: 'item',
56
+ key: 'top',
57
+ disabled: true,
58
+ label: (
59
+ <div style={{ textAlign: 'center', cursor: 'text', fontStyle: 'italic' }}>
60
+ {localizer.chatList.topShown(top)}
61
+ </div>
62
+ ),
63
+ },
64
+ ];
65
+ }
66
+
67
+ return result;
68
+ }, [items, noRead, top, localizer]);
69
+ }
70
+
71
+ export const ChatList = customize('ChatList', (props: ChatListProps) => {
72
+ const { selected: selectedChatId } = props;
73
+ const selected = useMemo(() => (selectedChatId ? [selectedChatId] : []), [selectedChatId]);
74
+ const onSelect = useOnSelect(props);
75
+ const items = useMenuItems(props);
76
+
77
+ return (
78
+ <>
79
+ {items && (
80
+ <Menu className="wxchtf-chat-list" selectedKeys={selected} onSelect={onSelect} items={items} />
81
+ )}
82
+ </>
83
+ );
84
+ });
@@ -1,20 +1,26 @@
1
- import { ChatListItem as ChatListItemModel } from '../../../core';
2
1
  import { customize } from '../../customize';
3
2
  import { ChatListItemName } from './ChatListItemName';
4
3
  import { ChatListItemUnreadCount } from './ChatListItemUnreadCount';
5
4
  import { ChatListItemLastMessage } from './ChatListItemLastMessage';
6
5
  import { ChatListItemAvatar } from './ChatListItemAvatar';
6
+ import { ChatListValue } from './ChatListValue';
7
7
 
8
8
  export interface ChatListItemBoxProps {
9
- chat: ChatListItemModel;
9
+ chat: ChatListValue;
10
+
11
+ /**
12
+ * If true, do not show read status.
13
+ */
14
+ noRead?: boolean;
10
15
  }
11
16
 
12
17
  export const ChatListItemBox = customize('ChatListItemBox', (props: ChatListItemBoxProps) => {
13
- const { message, lastReadMessageId } = props.chat;
14
- const read = lastReadMessageId != null && lastReadMessageId.localeCompare(message.id) >= 0;
18
+ const { noRead = false } = props;
19
+ const { lastMessage, lastReadMessageId } = props.chat;
20
+ const read = lastReadMessageId != null && lastReadMessageId.localeCompare(lastMessage.id) >= 0;
15
21
 
16
22
  return (
17
- <div className={'wxchtf-chat' + (!read ? ' --unread' : '')}>
23
+ <div className={'wxchtf-chat' + (!read && !noRead ? ' --unread' : '')}>
18
24
  <ChatListItemAvatar {...props} />
19
25
  <span className="wxchtf-chat-info">
20
26
  <ChatListItemName {...props} />
@@ -4,12 +4,12 @@ import type { ChatListItemBoxProps } from './ChatListItemBox';
4
4
  export const ChatListItemLastMessageAuthor = customize(
5
5
  'ChatListItemLastMessageAuthor',
6
6
  (props: ChatListItemBoxProps) => {
7
- const { message } = props.chat;
7
+ const { lastMessage } = props.chat;
8
8
 
9
- if (message.sentBy.id === 'chatify::system') {
9
+ if (lastMessage.sentBy.id === 'chatify::system') {
10
10
  return null;
11
11
  }
12
12
 
13
- return <div className="wxchtf-chat-last-author">{message.sentBy.name}</div>;
13
+ return <div className="wxchtf-chat-last-author">{lastMessage.sentBy.name}</div>;
14
14
  },
15
15
  );
@@ -7,14 +7,14 @@ import type { ChatListItemBoxProps } from './ChatListItemBox';
7
7
  export const ChatListItemLastMessageContent = customize<FC<ChatListItemBoxProps>>(
8
8
  'ChatListItemLastMessageContent',
9
9
  (props) => {
10
- const { message } = props.chat;
10
+ const { lastMessage } = props.chat;
11
11
  const localizer = useLocalizer();
12
12
 
13
13
  return (
14
14
  <div className="wxchtf-chat-last-message">
15
- {message.sentBy.id === 'chatify::system'
16
- ? message.text && formatSystemMessage(localizer, message.text)
17
- : message.text}
15
+ {lastMessage.sentBy.id === 'chatify::system'
16
+ ? lastMessage.text && formatSystemMessage(localizer, lastMessage.text)
17
+ : lastMessage.text}
18
18
  </div>
19
19
  );
20
20
  },
@@ -7,7 +7,7 @@ export const ChatListItemLastMessageSentAt = customize(
7
7
  (props: ChatListItemBoxProps) => {
8
8
  const {
9
9
  chat: {
10
- message: { sentAt },
10
+ lastMessage: { sentAt },
11
11
  },
12
12
  } = props;
13
13
 
@@ -4,7 +4,7 @@ import { ChatListItemBoxProps } from './ChatListItemBox';
4
4
  export const ChatListItemUnreadCount = customize('ChatListItemUnreadCount', (props: ChatListItemBoxProps) => {
5
5
  const { totalUnreadCount: unreadCount } = props.chat;
6
6
 
7
- if (unreadCount <= 0) {
7
+ if (unreadCount == null || unreadCount <= 0) {
8
8
  return null;
9
9
  }
10
10
 
@@ -0,0 +1,9 @@
1
+ import { MessageBase } from '../../../core';
2
+
3
+ export interface ChatListValue {
4
+ id: string;
5
+ name: string;
6
+ lastMessage: MessageBase;
7
+ totalUnreadCount?: number;
8
+ lastReadMessageId?: string | null;
9
+ }
@@ -0,0 +1,32 @@
1
+ import { ChatList } from './ChatList';
2
+ import { ChatListItemAvatar } from './ChatListItemAvatar';
3
+ import { ChatListItemBox } from './ChatListItemBox';
4
+ import { ChatListItemLastMessage } from './ChatListItemLastMessage';
5
+ import { ChatListItemLastMessageAuthor } from './ChatListItemLastMessageAuthor';
6
+ import { ChatListItemLastMessageContent } from './ChatListItemLastMessageContent';
7
+ import { ChatListItemLastMessageSentAt } from './ChatListItemLastMessageSentAt';
8
+ import { ChatListItemName } from './ChatListItemName';
9
+ import { ChatListItemUnreadCount } from './ChatListItemUnreadCount';
10
+
11
+ export * from './ChatList';
12
+ export * from './ChatListItemAvatar';
13
+ export * from './ChatListItemBox';
14
+ export * from './ChatListItemLastMessage';
15
+ export * from './ChatListItemLastMessageAuthor';
16
+ export * from './ChatListItemLastMessageContent';
17
+ export * from './ChatListItemLastMessageSentAt';
18
+ export * from './ChatListItemName';
19
+ export * from './ChatListItemUnreadCount';
20
+ export * from './ChatListValue';
21
+
22
+ export interface ChatListCustomizeValue {
23
+ ChatList?: typeof ChatList.Component | null;
24
+ ChatListItemAvatar?: typeof ChatListItemAvatar.Component | null;
25
+ ChatListItemBox?: typeof ChatListItemBox.Component | null;
26
+ ChatListItemLastMessage?: typeof ChatListItemLastMessage.Component | null;
27
+ ChatListItemLastMessageAuthor?: typeof ChatListItemLastMessageAuthor.Component | null;
28
+ ChatListItemLastMessageContent?: typeof ChatListItemLastMessageContent.Component | null;
29
+ ChatListItemLastMessageSentAt?: typeof ChatListItemLastMessageSentAt.Component | null;
30
+ ChatListItemName?: typeof ChatListItemName.Component | null;
31
+ ChatListItemUnreadCount?: typeof ChatListItemUnreadCount.Component | null;
32
+ }
@@ -1,18 +1,20 @@
1
1
  import { FC } from 'react';
2
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
- import CloseOutlined from '@ant-design/icons/CloseOutlined';
12
- import EyeInvisibleOutlined from '@ant-design/icons/EyeInvisibleOutlined';
13
- import EyeOutlined from '@ant-design/icons/EyeOutlined';
14
- import DeleteOutlined from '@ant-design/icons/DeleteOutlined';
15
- import DownloadOutlined from '@ant-design/icons/DownloadOutlined';
3
+ import {
4
+ SendOutlined,
5
+ PaperClipOutlined,
6
+ UserAddOutlined,
7
+ UsergroupAddOutlined,
8
+ UserDeleteOutlined,
9
+ UsergroupDeleteOutlined,
10
+ TeamOutlined,
11
+ EditOutlined,
12
+ CloseOutlined,
13
+ EyeInvisibleOutlined,
14
+ EyeOutlined,
15
+ DeleteOutlined,
16
+ DownloadOutlined,
17
+ } from '@ant-design/icons';
16
18
 
17
19
  export type IconType = keyof typeof ICONS;
18
20
 
@@ -5,6 +5,7 @@ import { MessageSkeleton } from './MessageSkeleton';
5
5
  export * from './Avatar';
6
6
  export * from './Icon';
7
7
  export * from './MessageSkeleton';
8
+ export * from './ChatList';
8
9
 
9
10
  export interface CommonCustomizeValue {
10
11
  Avatar?: typeof Avatar.Component | null;
package/src/ui/index.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import '../styles/index.scss';
2
+
1
3
  export * from './color';
2
4
  export * from './customize';
3
5
  export * from './Chatify';
@@ -6,6 +8,4 @@ export * from './Chat';
6
8
  export * from './ChatGroup';
7
9
  export * from './Conversation';
8
10
  export * from './Thread';
9
- export * from './common/Icon';
10
- export * from './common/Avatar';
11
- export * from './common/MessageSkeleton';
11
+ export * from './common';
@@ -2,7 +2,7 @@ import dayjs from 'dayjs';
2
2
  import React, { useContext } from 'react';
3
3
  import { SystemMessageText } from '../core';
4
4
 
5
- export interface Localizer {
5
+ export interface LocalizerBase {
6
6
  isToday: (value: string) => boolean;
7
7
  timestamp: (value: string) => string;
8
8
  dateTime: (value: string) => string;
@@ -39,15 +39,21 @@ export interface Localizer {
39
39
  kb: (value: number) => string;
40
40
  mb: (value: number) => string;
41
41
  };
42
+
43
+ chatList: {
44
+ topShown: (count: number) => string;
45
+ };
42
46
  }
43
47
 
48
+ export interface Localizer extends LocalizerBase {}
49
+
44
50
  export const LocalizerContext = React.createContext<Localizer>(null!);
45
51
 
46
52
  export function useLocalizer() {
47
53
  return useContext(LocalizerContext);
48
54
  }
49
55
 
50
- export const defaultLocalizer: Localizer = {
56
+ const base: LocalizerBase = {
51
57
  isToday: (value: string) => dayjs(value).isSame(dayjs(), 'day'),
52
58
  timestamp: (value: string) => dayjs(value).format('HH:mm'),
53
59
  dateTime: (value: string) => dayjs(value).format('DD/MM/YYYY HH:mm'),
@@ -93,4 +99,10 @@ export const defaultLocalizer: Localizer = {
93
99
  mb: (value: number) =>
94
100
  `${value.toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 2 })} MB`,
95
101
  },
102
+
103
+ chatList: {
104
+ topShown: (count: number) => `Latest active ${count} chat${count !== 1 ? 's' : ''} shown`,
105
+ },
96
106
  };
107
+
108
+ export const defaultLocalizer: Localizer = base as unknown as Localizer;