@webinex/chatify 2.0.0-alpha1 → 2.0.0-alpha3

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 (234) hide show
  1. package/dist/css/chatify.css +116 -13
  2. package/dist/esm/index.js +2 -2
  3. package/dist/esm/index.js.map +1 -1
  4. package/dist/esm/types/core/api/api.d.ts +10703 -387
  5. package/dist/esm/types/core/api/baseApi.d.ts +1 -1
  6. package/dist/esm/types/core/client.d.ts +2 -2
  7. package/dist/esm/types/core/types.d.ts +3 -6
  8. package/dist/esm/types/ui/Conversation/Conversation.d.ts +2 -0
  9. package/dist/esm/types/ui/Conversation/ConversationContext.d.ts +2 -0
  10. package/dist/esm/types/ui/Conversation/InputBox/InputBoxFile.d.ts +8 -0
  11. package/dist/esm/types/ui/Conversation/InputBox/InputBoxFileList.d.ts +8 -0
  12. package/dist/esm/types/ui/Conversation/InputBox/InputFilesBox.d.ts +11 -1
  13. package/dist/esm/types/ui/Conversation/InputBox/InputSubmitButtonBox.d.ts +2 -0
  14. package/dist/esm/types/ui/Conversation/InputBox/InputTextBox.d.ts +1 -0
  15. package/dist/esm/types/ui/Conversation/InputBox/index.d.ts +8 -1
  16. package/dist/esm/types/ui/Conversation/Message/MessageFile.d.ts +6 -0
  17. package/dist/esm/types/ui/Conversation/Message/MessageFileList.d.ts +3 -0
  18. package/dist/esm/types/ui/Conversation/Message/index.d.ts +6 -0
  19. package/dist/esm/types/ui/common/Icon.d.ts +14 -12
  20. package/dist/esm/types/ui/customize.d.ts +2 -2
  21. package/dist/esm/types/ui/localizer.d.ts +5 -0
  22. package/dist/esm/types/ui/useFormatter.d.ts +3 -0
  23. package/dist/index.d.ts +10772 -415
  24. package/package.json +94 -93
  25. package/src/core/api/api.ts +639 -642
  26. package/src/core/api/baseApi.ts +38 -38
  27. package/src/core/api/index.ts +1 -1
  28. package/src/core/client.ts +280 -280
  29. package/src/core/constants.ts +1 -1
  30. package/src/core/debounce.ts +90 -90
  31. package/src/core/index.ts +4 -4
  32. package/src/core/types.tsx +149 -152
  33. package/src/index.ts +2 -2
  34. package/src/styles/aside.scss +162 -161
  35. package/src/styles/chat.scss +209 -208
  36. package/src/styles/index.scss +159 -110
  37. package/src/styles/input.scss +147 -74
  38. package/src/styles/keyframes.scss +14 -14
  39. package/src/styles/members.scss +13 -13
  40. package/src/styles/mixins.scss +25 -20
  41. package/src/styles/variables.scss +13 -10
  42. package/src/ui/Chat/ChatContext.tsx +30 -30
  43. package/src/ui/Chat/ChatEditableHeaderName.tsx +63 -63
  44. package/src/ui/Chat/ChatHeaderActions.tsx +19 -19
  45. package/src/ui/Chat/ChatPanel.tsx +30 -30
  46. package/src/ui/Chat/ChatView.tsx +115 -115
  47. package/src/ui/Chat/Members/ChatMembersButton.tsx +9 -9
  48. package/src/ui/Chat/Members/ChatMembersPanel.tsx +112 -112
  49. package/src/ui/Chat/Members/ChatMembersPreview.tsx +25 -25
  50. package/src/ui/Chat/Members/index.ts +13 -13
  51. package/src/ui/Chat/index.ts +6 -6
  52. package/src/ui/ChatGroup/ChatGroupContext.tsx +50 -50
  53. package/src/ui/ChatGroup/ChatGroupPanel.tsx +73 -73
  54. package/src/ui/ChatGroup/Create/CreateChatButton.tsx +15 -15
  55. package/src/ui/ChatGroup/Create/CreateChatForm.tsx +36 -36
  56. package/src/ui/ChatGroup/Create/CreateChatMemberInput.tsx +65 -65
  57. package/src/ui/ChatGroup/Create/CreateChatNameInput.tsx +25 -25
  58. package/src/ui/ChatGroup/Create/CreateChatPanel.tsx +45 -45
  59. package/src/ui/ChatGroup/Create/index.ts +19 -19
  60. package/src/ui/ChatGroup/Layout/ChatGroupAside.tsx +12 -12
  61. package/src/ui/ChatGroup/Layout/ChatGroupBody.tsx +10 -10
  62. package/src/ui/ChatGroup/Layout/ChatGroupFooter.tsx +3 -3
  63. package/src/ui/ChatGroup/Layout/ChatGroupHeader.tsx +5 -5
  64. package/src/ui/ChatGroup/Layout/ChatGroupMain.tsx +17 -17
  65. package/src/ui/ChatGroup/Layout/index.ts +19 -19
  66. package/src/ui/ChatGroup/List/ChatList.tsx +41 -42
  67. package/src/ui/ChatGroup/List/ChatListItemAvatar.tsx +22 -22
  68. package/src/ui/ChatGroup/List/ChatListItemBox.tsx +26 -26
  69. package/src/ui/ChatGroup/List/ChatListItemLastMessage.tsx +15 -15
  70. package/src/ui/ChatGroup/List/ChatListItemLastMessageAuthor.tsx +15 -15
  71. package/src/ui/ChatGroup/List/ChatListItemLastMessageContent.tsx +21 -21
  72. package/src/ui/ChatGroup/List/ChatListItemLastMessageSentAt.tsx +22 -22
  73. package/src/ui/ChatGroup/List/ChatListItemName.tsx +8 -8
  74. package/src/ui/ChatGroup/List/ChatListItemUnreadCount.tsx +12 -12
  75. package/src/ui/ChatGroup/List/index.ts +31 -31
  76. package/src/ui/ChatGroup/index.ts +5 -5
  77. package/src/ui/Chatify.tsx +9 -9
  78. package/src/ui/Conversation/Conversation.tsx +78 -76
  79. package/src/ui/Conversation/ConversationActions.tsx +5 -5
  80. package/src/ui/Conversation/ConversationBody.tsx +28 -28
  81. package/src/ui/Conversation/ConversationContext.ts +29 -27
  82. package/src/ui/Conversation/ConversationHeader.tsx +23 -23
  83. package/src/ui/Conversation/ConversationName.tsx +7 -7
  84. package/src/ui/Conversation/InputBox/InputBox.tsx +122 -40
  85. package/src/ui/Conversation/InputBox/InputBoxFile.tsx +38 -0
  86. package/src/ui/Conversation/InputBox/InputBoxFileList.tsx +21 -0
  87. package/src/ui/Conversation/InputBox/InputFilesBox.tsx +78 -9
  88. package/src/ui/Conversation/InputBox/InputSubmitButtonBox.tsx +26 -17
  89. package/src/ui/Conversation/InputBox/InputTextBox.tsx +61 -53
  90. package/src/ui/Conversation/InputBox/index.ts +23 -16
  91. package/src/ui/Conversation/Message/MessageAuthor.tsx +13 -13
  92. package/src/ui/Conversation/Message/MessageBox.tsx +20 -20
  93. package/src/ui/Conversation/Message/MessageContent.tsx +15 -11
  94. package/src/ui/Conversation/Message/MessageFile.tsx +54 -0
  95. package/src/ui/Conversation/Message/MessageFileList.tsx +14 -0
  96. package/src/ui/Conversation/Message/MessageInfoBox.tsx +28 -28
  97. package/src/ui/Conversation/Message/MessageRow.tsx +28 -28
  98. package/src/ui/Conversation/Message/MessageText.tsx +7 -7
  99. package/src/ui/Conversation/Message/index.ts +28 -22
  100. package/src/ui/Conversation/NextObserver/NextMessagesObserver.tsx +47 -47
  101. package/src/ui/Conversation/NextObserver/index.ts +1 -1
  102. package/src/ui/Conversation/ReadObserver/MessageReadObserver.tsx +49 -49
  103. package/src/ui/Conversation/ReadObserver/index.ts +1 -1
  104. package/src/ui/Conversation/SendingMessage/SendingMessageBox.tsx +16 -16
  105. package/src/ui/Conversation/SendingMessage/SendingMessageContent.tsx +13 -13
  106. package/src/ui/Conversation/SendingMessage/SendingMessageInfoBox.tsx +13 -13
  107. package/src/ui/Conversation/SendingMessage/SendingMessageText.tsx +7 -7
  108. package/src/ui/Conversation/SendingMessage/index.ts +16 -16
  109. package/src/ui/Conversation/SystemMessage/SystemMessageBox.tsx +20 -20
  110. package/src/ui/Conversation/SystemMessage/SystemMessageRow.tsx +28 -28
  111. package/src/ui/Conversation/SystemMessage/index.ts +10 -10
  112. package/src/ui/Conversation/index.ts +13 -13
  113. package/src/ui/Thread/ThreadActions.tsx +22 -22
  114. package/src/ui/Thread/ThreadContext.ts +13 -13
  115. package/src/ui/Thread/ThreadPanel.tsx +127 -127
  116. package/src/ui/Thread/index.tsx +3 -3
  117. package/src/ui/color.ts +20 -20
  118. package/src/ui/common/Avatar.tsx +20 -20
  119. package/src/ui/common/Icon.tsx +44 -40
  120. package/src/ui/common/MessageSkeleton.tsx +20 -20
  121. package/src/ui/common/index.ts +13 -13
  122. package/src/ui/customize.tsx +51 -53
  123. package/src/ui/index.ts +11 -11
  124. package/src/ui/localizer.tsx +96 -81
  125. package/src/ui/useFormatter.tsx +17 -0
  126. package/dist/esm/types/core/api/accountApi.d.ts +0 -5
  127. package/dist/esm/types/core/api/chatApi.d.ts +0 -16
  128. package/dist/esm/types/core/api/chatListApi.d.ts +0 -5
  129. package/dist/esm/types/core/api/chatMemberApi.d.ts +0 -6
  130. package/dist/esm/types/core/api/chatMessageApi.d.ts +0 -3
  131. package/dist/esm/types/core/api/threadApi.d.ts +0 -1
  132. package/dist/esm/types/core/api/threadMessageApi.d.ts +0 -6
  133. package/src/core/api/accountApi.ts +0 -11
  134. package/src/core/api/chatApi.ts +0 -87
  135. package/src/core/api/chatListApi.ts +0 -134
  136. package/src/core/api/chatMemberApi.ts +0 -20
  137. package/src/core/api/chatMessageApi.ts +0 -12
  138. package/src/core/api/threadApi.ts +0 -8
  139. package/src/core/api/threadMessageApi.ts +0 -20
  140. package/src/types/core/api/accountApi.d.ts +0 -5
  141. package/src/types/core/api/api.d.ts +0 -2380
  142. package/src/types/core/api/baseApi.d.ts +0 -15
  143. package/src/types/core/api/chatApi.d.ts +0 -16
  144. package/src/types/core/api/chatListApi.d.ts +0 -5
  145. package/src/types/core/api/chatMemberApi.d.ts +0 -6
  146. package/src/types/core/api/chatMessageApi.d.ts +0 -3
  147. package/src/types/core/api/index.d.ts +0 -1
  148. package/src/types/core/api/threadApi.d.ts +0 -1
  149. package/src/types/core/api/threadMessageApi.d.ts +0 -6
  150. package/src/types/core/client.d.ts +0 -83
  151. package/src/types/core/constants.d.ts +0 -1
  152. package/src/types/core/debounce.d.ts +0 -27
  153. package/src/types/core/index.d.ts +0 -4
  154. package/src/types/core/types.d.ts +0 -105
  155. package/src/types/index.d.ts +0 -2
  156. package/src/types/ui/Chat/ChatContext.d.ts +0 -10
  157. package/src/types/ui/Chat/ChatEditableHeaderName.d.ts +0 -2
  158. package/src/types/ui/Chat/ChatHeaderActions.d.ts +0 -2
  159. package/src/types/ui/Chat/ChatPanel.d.ts +0 -13
  160. package/src/types/ui/Chat/ChatView.d.ts +0 -17
  161. package/src/types/ui/Chat/Members/ChatMembersButton.d.ts +0 -2
  162. package/src/types/ui/Chat/Members/ChatMembersPanel.d.ts +0 -2
  163. package/src/types/ui/Chat/Members/ChatMembersPreview.d.ts +0 -2
  164. package/src/types/ui/Chat/Members/index.d.ts +0 -11
  165. package/src/types/ui/Chat/index.d.ts +0 -6
  166. package/src/types/ui/ChatGroup/ChatGroupContext.d.ts +0 -12
  167. package/src/types/ui/ChatGroup/ChatGroupPanel.d.ts +0 -15
  168. package/src/types/ui/ChatGroup/Create/CreateChatButton.d.ts +0 -2
  169. package/src/types/ui/ChatGroup/Create/CreateChatForm.d.ts +0 -11
  170. package/src/types/ui/ChatGroup/Create/CreateChatMemberInput.d.ts +0 -5
  171. package/src/types/ui/ChatGroup/Create/CreateChatNameInput.d.ts +0 -5
  172. package/src/types/ui/ChatGroup/Create/CreateChatPanel.d.ts +0 -2
  173. package/src/types/ui/ChatGroup/Create/index.d.ts +0 -17
  174. package/src/types/ui/ChatGroup/Layout/ChatGroupAside.d.ts +0 -2
  175. package/src/types/ui/ChatGroup/Layout/ChatGroupBody.d.ts +0 -2
  176. package/src/types/ui/ChatGroup/Layout/ChatGroupFooter.d.ts +0 -2
  177. package/src/types/ui/ChatGroup/Layout/ChatGroupHeader.d.ts +0 -2
  178. package/src/types/ui/ChatGroup/Layout/ChatGroupMain.d.ts +0 -2
  179. package/src/types/ui/ChatGroup/Layout/index.d.ts +0 -17
  180. package/src/types/ui/ChatGroup/List/ChatList.d.ts +0 -2
  181. package/src/types/ui/ChatGroup/List/ChatListItemAvatar.d.ts +0 -3
  182. package/src/types/ui/ChatGroup/List/ChatListItemBox.d.ts +0 -6
  183. package/src/types/ui/ChatGroup/List/ChatListItemLastMessage.d.ts +0 -3
  184. package/src/types/ui/ChatGroup/List/ChatListItemLastMessageAuthor.d.ts +0 -3
  185. package/src/types/ui/ChatGroup/List/ChatListItemLastMessageContent.d.ts +0 -3
  186. package/src/types/ui/ChatGroup/List/ChatListItemLastMessageSentAt.d.ts +0 -3
  187. package/src/types/ui/ChatGroup/List/ChatListItemName.d.ts +0 -3
  188. package/src/types/ui/ChatGroup/List/ChatListItemUnreadCount.d.ts +0 -3
  189. package/src/types/ui/ChatGroup/List/index.d.ts +0 -29
  190. package/src/types/ui/ChatGroup/index.d.ts +0 -5
  191. package/src/types/ui/Chatify.d.ts +0 -8
  192. package/src/types/ui/Conversation/Conversation.d.ts +0 -21
  193. package/src/types/ui/Conversation/ConversationActions.d.ts +0 -2
  194. package/src/types/ui/Conversation/ConversationBody.d.ts +0 -2
  195. package/src/types/ui/Conversation/ConversationContext.d.ts +0 -20
  196. package/src/types/ui/Conversation/ConversationHeader.d.ts +0 -2
  197. package/src/types/ui/Conversation/ConversationName.d.ts +0 -2
  198. package/src/types/ui/Conversation/InputBox/InputBox.d.ts +0 -2
  199. package/src/types/ui/Conversation/InputBox/InputFilesBox.d.ts +0 -2
  200. package/src/types/ui/Conversation/InputBox/InputSubmitButtonBox.d.ts +0 -5
  201. package/src/types/ui/Conversation/InputBox/InputTextBox.d.ts +0 -8
  202. package/src/types/ui/Conversation/InputBox/index.d.ts +0 -14
  203. package/src/types/ui/Conversation/Message/MessageAuthor.d.ts +0 -3
  204. package/src/types/ui/Conversation/Message/MessageBox.d.ts +0 -6
  205. package/src/types/ui/Conversation/Message/MessageContent.d.ts +0 -3
  206. package/src/types/ui/Conversation/Message/MessageInfoBox.d.ts +0 -3
  207. package/src/types/ui/Conversation/Message/MessageRow.d.ts +0 -6
  208. package/src/types/ui/Conversation/Message/MessageText.d.ts +0 -3
  209. package/src/types/ui/Conversation/Message/index.d.ts +0 -20
  210. package/src/types/ui/Conversation/NextObserver/NextMessagesObserver.d.ts +0 -5
  211. package/src/types/ui/Conversation/NextObserver/index.d.ts +0 -1
  212. package/src/types/ui/Conversation/ReadObserver/MessageReadObserver.d.ts +0 -6
  213. package/src/types/ui/Conversation/ReadObserver/index.d.ts +0 -1
  214. package/src/types/ui/Conversation/SendingMessage/SendingMessageBox.d.ts +0 -7
  215. package/src/types/ui/Conversation/SendingMessage/SendingMessageContent.d.ts +0 -3
  216. package/src/types/ui/Conversation/SendingMessage/SendingMessageInfoBox.d.ts +0 -3
  217. package/src/types/ui/Conversation/SendingMessage/SendingMessageText.d.ts +0 -3
  218. package/src/types/ui/Conversation/SendingMessage/index.d.ts +0 -14
  219. package/src/types/ui/Conversation/SystemMessage/SystemMessageBox.d.ts +0 -6
  220. package/src/types/ui/Conversation/SystemMessage/SystemMessageRow.d.ts +0 -9
  221. package/src/types/ui/Conversation/SystemMessage/index.d.ts +0 -8
  222. package/src/types/ui/Conversation/index.d.ts +0 -12
  223. package/src/types/ui/Thread/ThreadActions.d.ts +0 -2
  224. package/src/types/ui/Thread/ThreadContext.d.ts +0 -8
  225. package/src/types/ui/Thread/ThreadPanel.d.ts +0 -14
  226. package/src/types/ui/Thread/index.d.ts +0 -3
  227. package/src/types/ui/color.d.ts +0 -6
  228. package/src/types/ui/common/Avatar.d.ts +0 -6
  229. package/src/types/ui/common/Icon.d.ts +0 -20
  230. package/src/types/ui/common/MessageSkeleton.d.ts +0 -5
  231. package/src/types/ui/common/index.d.ts +0 -11
  232. package/src/types/ui/customize.d.ts +0 -9
  233. package/src/types/ui/index.d.ts +0 -11
  234. package/src/types/ui/localizer.d.ts +0 -35
@@ -1,16 +1,16 @@
1
- import { SendingMessageBox } from './SendingMessageBox';
2
- import { SendingMessageContent } from './SendingMessageContent';
3
- import { SendingMessageInfoBox } from './SendingMessageInfoBox';
4
- import { SendingMessageText } from './SendingMessageText';
5
-
6
- export * from './SendingMessageBox';
7
- export * from './SendingMessageContent';
8
- export * from './SendingMessageInfoBox';
9
- export * from './SendingMessageText';
10
-
11
- export interface SendingMessageCustomizeValue {
12
- SendingMessageBox?: typeof SendingMessageBox.Component | null;
13
- SendingMessageContent?: typeof SendingMessageContent.Component | null;
14
- SendingMessageInfoBox?: typeof SendingMessageInfoBox.Component | null;
15
- SendingMessageText?: typeof SendingMessageText.Component | null;
16
- }
1
+ import { SendingMessageBox } from './SendingMessageBox';
2
+ import { SendingMessageContent } from './SendingMessageContent';
3
+ import { SendingMessageInfoBox } from './SendingMessageInfoBox';
4
+ import { SendingMessageText } from './SendingMessageText';
5
+
6
+ export * from './SendingMessageBox';
7
+ export * from './SendingMessageContent';
8
+ export * from './SendingMessageInfoBox';
9
+ export * from './SendingMessageText';
10
+
11
+ export interface SendingMessageCustomizeValue {
12
+ SendingMessageBox?: typeof SendingMessageBox.Component | null;
13
+ SendingMessageContent?: typeof SendingMessageContent.Component | null;
14
+ SendingMessageInfoBox?: typeof SendingMessageInfoBox.Component | null;
15
+ SendingMessageText?: typeof SendingMessageText.Component | null;
16
+ }
@@ -1,20 +1,20 @@
1
- import { useRef } from 'react';
2
- import { customize } from '../../customize';
3
- import { MessageBase } from '../../../core';
4
- import { SystemMessageRow } from './SystemMessageRow';
5
- import { MessageReadObserver } from '../ReadObserver';
6
-
7
- export interface SystemMessageBoxProps {
8
- message: MessageBase;
9
- }
10
-
11
- export const SystemMessageBox = customize('SystemMessageBox', (props: SystemMessageBoxProps) => {
12
- const ref = useRef<HTMLDivElement | null>(null);
13
-
14
- return (
15
- <>
16
- <MessageReadObserver messageRef={ref} {...props} />
17
- <SystemMessageRow containerRef={ref} {...props} />
18
- </>
19
- );
20
- });
1
+ import { useRef } from 'react';
2
+ import { customize } from '../../customize';
3
+ import { MessageBase } from '../../../core';
4
+ import { SystemMessageRow } from './SystemMessageRow';
5
+ import { MessageReadObserver } from '../ReadObserver';
6
+
7
+ export interface SystemMessageBoxProps {
8
+ message: MessageBase;
9
+ }
10
+
11
+ export const SystemMessageBox = customize('SystemMessageBox', (props: SystemMessageBoxProps) => {
12
+ const ref = useRef<HTMLDivElement | null>(null);
13
+
14
+ return (
15
+ <>
16
+ <MessageReadObserver messageRef={ref} {...props} />
17
+ <SystemMessageRow containerRef={ref} {...props} />
18
+ </>
19
+ );
20
+ });
@@ -1,28 +1,28 @@
1
- import { Ref } from 'react';
2
- import { customize } from '../../customize';
3
- import { Localizer, useLocalizer } from '../../localizer';
4
- import { MessageBase } from '../../../core';
5
-
6
- export interface SystemMessageRowProps {
7
- message: MessageBase;
8
- containerRef?: Ref<HTMLDivElement>;
9
- }
10
-
11
- export function formatSystemMessage(localizer: Localizer, text: string): React.ReactNode {
12
- const [key, payload] = text.split('::', 2);
13
- const data = payload ? JSON.parse(payload) : null;
14
- return localizer.system[key as keyof Localizer['system']](key as any, data);
15
- }
16
-
17
- export const SystemMessageRow = customize('SystemMessageRow', (props: SystemMessageRowProps) => {
18
- const { message, containerRef } = props;
19
- const { text, sentAt } = message;
20
- const localizer = useLocalizer();
21
-
22
- return (
23
- <div ref={containerRef} className="wxchtf-system-message">
24
- <div className="wxchtf-text">{formatSystemMessage(localizer, text)}</div>
25
- <div className="wxchtf-timestamp">{localizer.timestamp(sentAt)}</div>
26
- </div>
27
- );
28
- });
1
+ import { Ref } from 'react';
2
+ import { customize } from '../../customize';
3
+ import { Localizer, useLocalizer } from '../../localizer';
4
+ import { MessageBase } from '../../../core';
5
+
6
+ export interface SystemMessageRowProps {
7
+ message: MessageBase;
8
+ containerRef?: Ref<HTMLDivElement>;
9
+ }
10
+
11
+ export function formatSystemMessage(localizer: Localizer, text: string): React.ReactNode {
12
+ const [key, payload] = text.split('::', 2);
13
+ const data = payload ? JSON.parse(payload) : null;
14
+ return localizer.system[key as keyof Localizer['system']](key as any, data);
15
+ }
16
+
17
+ export const SystemMessageRow = customize('SystemMessageRow', (props: SystemMessageRowProps) => {
18
+ const { message, containerRef } = props;
19
+ const { text, sentAt } = message;
20
+ const localizer = useLocalizer();
21
+
22
+ return (
23
+ <div ref={containerRef} className="wxchtf-system-message">
24
+ <div className="wxchtf-text">{text && formatSystemMessage(localizer, text)}</div>
25
+ <div className="wxchtf-timestamp">{localizer.timestamp(sentAt)}</div>
26
+ </div>
27
+ );
28
+ });
@@ -1,10 +1,10 @@
1
- import { SystemMessageBox } from './SystemMessageBox';
2
- import { SystemMessageRow } from './SystemMessageRow';
3
-
4
- export * from './SystemMessageBox';
5
- export * from './SystemMessageRow';
6
-
7
- export interface SystemMessageCustomizeValue {
8
- SystemMessageBox?: typeof SystemMessageBox.Component | null;
9
- SystemMessageRow?: typeof SystemMessageRow.Component | null;
10
- }
1
+ import { SystemMessageBox } from './SystemMessageBox';
2
+ import { SystemMessageRow } from './SystemMessageRow';
3
+
4
+ export * from './SystemMessageBox';
5
+ export * from './SystemMessageRow';
6
+
7
+ export interface SystemMessageCustomizeValue {
8
+ SystemMessageBox?: typeof SystemMessageBox.Component | null;
9
+ SystemMessageRow?: typeof SystemMessageRow.Component | null;
10
+ }
@@ -1,13 +1,13 @@
1
- export * from './InputBox';
2
- export * from './Message';
3
- export * from './NextObserver';
4
- export * from './ReadObserver';
5
- export * from './SendingMessage';
6
- export * from './SystemMessage';
7
-
8
- export * from './ConversationActions';
9
- export * from './ConversationBody';
10
- export * from './ConversationHeader';
11
- export * from './ConversationName';
12
- export * from './ConversationContext';
13
- export * from './Conversation';
1
+ export * from './InputBox';
2
+ export * from './Message';
3
+ export * from './NextObserver';
4
+ export * from './ReadObserver';
5
+ export * from './SendingMessage';
6
+ export * from './SystemMessage';
7
+
8
+ export * from './ConversationActions';
9
+ export * from './ConversationBody';
10
+ export * from './ConversationHeader';
11
+ export * from './ConversationName';
12
+ export * from './ConversationContext';
13
+ export * from './Conversation';
@@ -1,22 +1,22 @@
1
- import { Button, Tooltip } from 'antd';
2
- import { customize } from '../customize';
3
- import { useThreadContext } from './ThreadContext';
4
- import { Icon } from '../common/Icon';
5
-
6
- export const ThreadActions = customize('ThreadActions', () => {
7
- const { watch, onWatch } = useThreadContext();
8
-
9
- if (!watch) {
10
- return (
11
- <Tooltip title="Watch thread">
12
- <Button type="link" icon={<Icon type="watch" />} onClick={() => onWatch(true)} />
13
- </Tooltip>
14
- );
15
- }
16
-
17
- return (
18
- <Tooltip title="Unwatch thread">
19
- <Button type="link" icon={<Icon type="unwatch" />} onClick={() => onWatch(false)} />
20
- </Tooltip>
21
- );
22
- });
1
+ import { Button, Tooltip } from 'antd';
2
+ import { customize } from '../customize';
3
+ import { useThreadContext } from './ThreadContext';
4
+ import { Icon } from '../common/Icon';
5
+
6
+ export const ThreadActions = customize('ThreadActions', () => {
7
+ const { watch, onWatch } = useThreadContext();
8
+
9
+ if (!watch) {
10
+ return (
11
+ <Tooltip title="Watch thread">
12
+ <Button type="link" icon={<Icon type="watch" />} onClick={() => onWatch(true)} />
13
+ </Tooltip>
14
+ );
15
+ }
16
+
17
+ return (
18
+ <Tooltip title="Unwatch thread">
19
+ <Button type="link" icon={<Icon type="unwatch" />} onClick={() => onWatch(false)} />
20
+ </Tooltip>
21
+ );
22
+ });
@@ -1,13 +1,13 @@
1
- import React from 'react';
2
-
3
- export interface ThreadContextValue {
4
- id: string;
5
- watch: boolean;
6
- onWatch: (value: boolean) => void;
7
- }
8
-
9
- export const ThreadContext = React.createContext<ThreadContextValue>(null!);
10
-
11
- export function useThreadContext() {
12
- return React.useContext(ThreadContext);
13
- }
1
+ import React from 'react';
2
+
3
+ export interface ThreadContextValue {
4
+ id: string;
5
+ watch: boolean;
6
+ onWatch: (value: boolean) => void;
7
+ }
8
+
9
+ export const ThreadContext = React.createContext<ThreadContextValue>(null!);
10
+
11
+ export function useThreadContext() {
12
+ return React.useContext(ThreadContext);
13
+ }
@@ -1,127 +1,127 @@
1
- import { useCallback, useEffect, useMemo } from 'react';
2
- import { MessageBody, chatifyApi, parseThreadMessageId } from '../../core';
3
- import { Conversation, ConversationCustomizeValue, ConversationProps } from '../Conversation';
4
- import { ThreadContext, ThreadContextValue } from './ThreadContext';
5
- import { Localizer, LocalizerContext, defaultLocalizer } from '../localizer';
6
- import { CustomizeContext } from '../customize';
7
- import { ThreadActions } from './ThreadActions';
8
- import { CommonCustomizeValue } from '../common';
9
-
10
- export interface ThreadCustomizeValue extends ConversationCustomizeValue, CommonCustomizeValue {
11
- ThreadActions?: typeof ThreadActions.Component | null;
12
- }
13
-
14
- export interface ThreadPanelProps {
15
- threadId: string;
16
- className?: string;
17
- customize?: ThreadCustomizeValue;
18
- localizer?: Localizer;
19
- }
20
-
21
- function usePanelState(props: ThreadPanelProps) {
22
- const { threadId } = props;
23
- const { data: thread } = chatifyApi.useGetThreadQuery({ id: threadId });
24
- const { data: messageList } = chatifyApi.useGetThreadMessageListQuery({ threadId });
25
- const { id, name, archive, lastReadMessageId, watch } = thread ?? {};
26
- const { messages, hasMore } = messageList ?? {};
27
-
28
- const [read] = chatifyApi.useReadThreadMessageMutation();
29
- const onRead = useCallback((id: string) => read({ id }), [read]);
30
-
31
- const [fetchNext, { isLoading: isFetchNextLoading }] = chatifyApi.useFetchNextThreadMessageListMutation();
32
- const onNext = useCallback(() => fetchNext({ threadId }), [fetchNext, threadId]);
33
-
34
- const [send] = chatifyApi.useSendThreadMessageMutation();
35
- const onSend = useCallback(
36
- (message: MessageBody) => send({ body: message, threadId }).unwrap(),
37
- [threadId, send],
38
- );
39
-
40
- const { data: readQueue } = chatifyApi.useGetThreadMessageReadQueueQuery();
41
-
42
- const conversation = useMemo(() => {
43
- if (!id) {
44
- return null;
45
- }
46
-
47
- const result: ConversationProps = {
48
- value: { id: id!, name: name!, active: !archive, lastReadMessageId: lastReadMessageId ?? null },
49
- messages,
50
- hasMore,
51
- onNext,
52
- nextLoading: isFetchNextLoading,
53
- onRead,
54
- onSend,
55
- noReadTracking: !watch,
56
- isReading: (id: string) =>
57
- readQueue!.some(
58
- (unit) => parseThreadMessageId(unit.value)[0] === parseThreadMessageId(id)[0] && id <= unit.value,
59
- ),
60
- };
61
-
62
- return result;
63
- }, [
64
- onNext,
65
- onRead,
66
- onSend,
67
- isFetchNextLoading,
68
- id,
69
- name,
70
- archive,
71
- messages,
72
- hasMore,
73
- lastReadMessageId,
74
- readQueue,
75
- watch,
76
- ]);
77
-
78
- const [watchThread] = chatifyApi.useWatchThreadMutation();
79
-
80
- const threadContext = useMemo<ThreadContextValue | null>(
81
- () =>
82
- thread
83
- ? {
84
- id: thread.id,
85
- watch: thread.watch,
86
- onWatch: (value) => watchThread({ id: thread.id, watch: value }).unwrap(),
87
- }
88
- : null,
89
- [thread, watchThread],
90
- );
91
-
92
- return [conversation, threadContext] as const;
93
- }
94
-
95
- const DEFAULT_CUSTOMIZE: ThreadCustomizeValue = {
96
- ConversationActions: () => <ThreadActions />,
97
- };
98
-
99
- export function ThreadPanel(props: ThreadPanelProps) {
100
- const { threadId, customize, localizer = defaultLocalizer, className = '' } = props;
101
- const [conversation, threadContext] = usePanelState(props);
102
- const customizeMergeValue = useMemo(() => ({ ...DEFAULT_CUSTOMIZE, ...customize }), [customize]);
103
-
104
- useEffect(() => {
105
- chatifyApi.settings.client.connectToThread(threadId);
106
-
107
- return () => {
108
- chatifyApi.settings.client.disconnectFromThread(threadId);
109
- };
110
- }, [threadId]);
111
-
112
- if (!conversation || !threadContext) {
113
- return null;
114
- }
115
-
116
- return (
117
- <LocalizerContext.Provider value={localizer}>
118
- <ThreadContext.Provider value={threadContext}>
119
- <CustomizeContext.Provider value={customizeMergeValue as any}>
120
- <div className={`wxchtf-chatify wxchtf-thread ${className}`}>
121
- {conversation && <Conversation {...conversation} />}
122
- </div>
123
- </CustomizeContext.Provider>
124
- </ThreadContext.Provider>
125
- </LocalizerContext.Provider>
126
- );
127
- }
1
+ import { useCallback, useEffect, useMemo } from 'react';
2
+ import { MessageBody, chatifyApi, parseThreadMessageId } from '../../core';
3
+ import { Conversation, ConversationCustomizeValue, ConversationProps } from '../Conversation';
4
+ import { ThreadContext, ThreadContextValue } from './ThreadContext';
5
+ import { Localizer, LocalizerContext, defaultLocalizer } from '../localizer';
6
+ import { CustomizeContext } from '../customize';
7
+ import { ThreadActions } from './ThreadActions';
8
+ import { CommonCustomizeValue } from '../common';
9
+
10
+ export interface ThreadCustomizeValue extends ConversationCustomizeValue, CommonCustomizeValue {
11
+ ThreadActions?: typeof ThreadActions.Component | null;
12
+ }
13
+
14
+ export interface ThreadPanelProps {
15
+ threadId: string;
16
+ className?: string;
17
+ customize?: ThreadCustomizeValue;
18
+ localizer?: Localizer;
19
+ }
20
+
21
+ function usePanelState(props: ThreadPanelProps) {
22
+ const { threadId } = props;
23
+ const { data: thread } = chatifyApi.useGetThreadQuery({ id: threadId });
24
+ const { data: messageList } = chatifyApi.useGetThreadMessageListQuery({ threadId });
25
+ const { id, name, archive, lastReadMessageId, watch } = thread ?? {};
26
+ const { messages, hasMore } = messageList ?? {};
27
+
28
+ const [read] = chatifyApi.useReadThreadMessageMutation();
29
+ const onRead = useCallback((id: string) => read({ id }), [read]);
30
+
31
+ const [fetchNext, { isLoading: isFetchNextLoading }] = chatifyApi.useFetchNextThreadMessageListMutation();
32
+ const onNext = useCallback(() => fetchNext({ threadId }), [fetchNext, threadId]);
33
+
34
+ const [send] = chatifyApi.useSendThreadMessageMutation();
35
+ const onSend = useCallback(
36
+ (message: MessageBody) => send({ body: message, threadId }).unwrap(),
37
+ [threadId, send],
38
+ );
39
+
40
+ const { data: readQueue } = chatifyApi.useGetThreadMessageReadQueueQuery();
41
+
42
+ const conversation = useMemo(() => {
43
+ if (!id) {
44
+ return null;
45
+ }
46
+
47
+ const result: ConversationProps = {
48
+ value: { id: id!, name: name!, active: !archive, lastReadMessageId: lastReadMessageId ?? null },
49
+ messages,
50
+ hasMore,
51
+ onNext,
52
+ nextLoading: isFetchNextLoading,
53
+ onRead,
54
+ onSend,
55
+ noReadTracking: !watch,
56
+ isReading: (id: string) =>
57
+ readQueue!.some(
58
+ (unit) => parseThreadMessageId(unit.value)[0] === parseThreadMessageId(id)[0] && id <= unit.value,
59
+ ),
60
+ };
61
+
62
+ return result;
63
+ }, [
64
+ onNext,
65
+ onRead,
66
+ onSend,
67
+ isFetchNextLoading,
68
+ id,
69
+ name,
70
+ archive,
71
+ messages,
72
+ hasMore,
73
+ lastReadMessageId,
74
+ readQueue,
75
+ watch,
76
+ ]);
77
+
78
+ const [watchThread] = chatifyApi.useWatchThreadMutation();
79
+
80
+ const threadContext = useMemo<ThreadContextValue | null>(
81
+ () =>
82
+ thread
83
+ ? {
84
+ id: thread.id,
85
+ watch: thread.watch,
86
+ onWatch: (value) => watchThread({ id: thread.id, watch: value }).unwrap(),
87
+ }
88
+ : null,
89
+ [thread, watchThread],
90
+ );
91
+
92
+ return [conversation, threadContext] as const;
93
+ }
94
+
95
+ const DEFAULT_CUSTOMIZE: ThreadCustomizeValue = {
96
+ ConversationActions: () => <ThreadActions />,
97
+ };
98
+
99
+ export function ThreadPanel(props: ThreadPanelProps) {
100
+ const { threadId, customize, localizer = defaultLocalizer, className = '' } = props;
101
+ const [conversation, threadContext] = usePanelState(props);
102
+ const customizeMergeValue = useMemo(() => ({ ...DEFAULT_CUSTOMIZE, ...customize }), [customize]);
103
+
104
+ useEffect(() => {
105
+ chatifyApi.settings.client.connectToThread(threadId);
106
+
107
+ return () => {
108
+ chatifyApi.settings.client.disconnectFromThread(threadId);
109
+ };
110
+ }, [threadId]);
111
+
112
+ if (!conversation || !threadContext) {
113
+ return null;
114
+ }
115
+
116
+ return (
117
+ <LocalizerContext.Provider value={localizer}>
118
+ <ThreadContext.Provider value={threadContext}>
119
+ <CustomizeContext.Provider value={customizeMergeValue as any}>
120
+ <div className={`wxchtf-chatify wxchtf-thread ${className}`}>
121
+ {conversation && <Conversation {...conversation} />}
122
+ </div>
123
+ </CustomizeContext.Provider>
124
+ </ThreadContext.Provider>
125
+ </LocalizerContext.Provider>
126
+ );
127
+ }
@@ -1,3 +1,3 @@
1
- export * from './ThreadActions';
2
- export * from './ThreadPanel';
3
- export * from './ThreadContext';
1
+ export * from './ThreadActions';
2
+ export * from './ThreadPanel';
3
+ export * from './ThreadContext';
package/src/ui/color.ts CHANGED
@@ -1,20 +1,20 @@
1
- interface ColorOptions {
2
- saturation?: number;
3
- lightness?: number;
4
- }
5
-
6
- const DEFAULT_COLOR_OPTIONS: ColorOptions = {
7
- saturation: 100,
8
- lightness: 75,
9
- };
10
-
11
- export function color(value: string, options: ColorOptions = {}) {
12
- options = Object.assign({}, DEFAULT_COLOR_OPTIONS, options);
13
-
14
- let hash = 0;
15
- for (let i = 0; i < value.length; i++) {
16
- hash = value.charCodeAt(i) + ((hash << 5) - hash);
17
- hash = hash & hash;
18
- }
19
- return `hsl(${hash % 360}, ${options.saturation}%, ${options.lightness}%)`;
20
- }
1
+ interface ColorOptions {
2
+ saturation?: number;
3
+ lightness?: number;
4
+ }
5
+
6
+ const DEFAULT_COLOR_OPTIONS: ColorOptions = {
7
+ saturation: 100,
8
+ lightness: 75,
9
+ };
10
+
11
+ export function color(value: string, options: ColorOptions = {}) {
12
+ options = Object.assign({}, DEFAULT_COLOR_OPTIONS, options);
13
+
14
+ let hash = 0;
15
+ for (let i = 0; i < value.length; i++) {
16
+ hash = value.charCodeAt(i) + ((hash << 5) - hash);
17
+ hash = hash & hash;
18
+ }
19
+ return `hsl(${hash % 360}, ${options.saturation}%, ${options.lightness}%)`;
20
+ }
@@ -1,20 +1,20 @@
1
- import { FC, ForwardedRef, forwardRef } from 'react';
2
- import { Account } from '../../core';
3
- import { Avatar as AntdAvatar } from 'antd';
4
- import { customize } from '../customize';
5
-
6
- export interface AvatarProps {
7
- account: Account;
8
- }
9
-
10
- const _Avatar: FC<AvatarProps> = forwardRef(
11
- (props: AvatarProps, forwardRef: ForwardedRef<HTMLSpanElement>) => {
12
- const { account } = props;
13
-
14
- return <AntdAvatar ref={forwardRef} src={account.avatar} />;
15
- },
16
- );
17
-
18
- _Avatar.displayName = 'Avatar';
19
-
20
- export const Avatar = customize('Avatar', _Avatar);
1
+ import { FC, ForwardedRef, forwardRef } from 'react';
2
+ import { Account } from '../../core';
3
+ import { Avatar as AntdAvatar } from 'antd';
4
+ import { customize } from '../customize';
5
+
6
+ export interface AvatarProps {
7
+ account: Account;
8
+ }
9
+
10
+ const _Avatar: FC<AvatarProps> = forwardRef(
11
+ (props: AvatarProps, forwardRef: ForwardedRef<HTMLSpanElement>) => {
12
+ const { account } = props;
13
+
14
+ return <AntdAvatar ref={forwardRef} src={account.avatar} />;
15
+ },
16
+ );
17
+
18
+ _Avatar.displayName = 'Avatar';
19
+
20
+ export const Avatar = customize('Avatar', _Avatar);