@webinex/chatify 2.0.1-alpha1 → 2.0.2-alpha2

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 (232) hide show
  1. package/dist/css/chatify.css +111 -12
  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 +10784 -232
  5. package/dist/esm/types/core/api/baseApi.d.ts +1 -1
  6. package/dist/esm/types/ui/Conversation/Conversation.d.ts +2 -0
  7. package/dist/esm/types/ui/Conversation/ConversationContext.d.ts +2 -0
  8. package/dist/esm/types/ui/Conversation/InputBox/InputBoxFile.d.ts +8 -0
  9. package/dist/esm/types/ui/Conversation/InputBox/InputBoxFileList.d.ts +8 -0
  10. package/dist/esm/types/ui/Conversation/InputBox/InputFilesBox.d.ts +11 -1
  11. package/dist/esm/types/ui/Conversation/InputBox/InputSubmitButtonBox.d.ts +2 -0
  12. package/dist/esm/types/ui/Conversation/InputBox/InputTextBox.d.ts +1 -0
  13. package/dist/esm/types/ui/Conversation/InputBox/index.d.ts +8 -1
  14. package/dist/esm/types/ui/Conversation/Message/MessageFile.d.ts +6 -0
  15. package/dist/esm/types/ui/Conversation/Message/MessageFileList.d.ts +3 -0
  16. package/dist/esm/types/ui/Conversation/Message/index.d.ts +6 -0
  17. package/dist/esm/types/ui/common/Icon.d.ts +2 -0
  18. package/dist/esm/types/ui/customize.d.ts +2 -2
  19. package/dist/esm/types/ui/localizer.d.ts +5 -0
  20. package/dist/esm/types/ui/useFormatter.d.ts +3 -0
  21. package/dist/index.d.ts +10835 -239
  22. package/package.json +94 -93
  23. package/src/core/api/api.ts +643 -642
  24. package/src/core/api/baseApi.ts +38 -38
  25. package/src/core/api/index.ts +1 -1
  26. package/src/core/client.ts +280 -280
  27. package/src/core/constants.ts +1 -1
  28. package/src/core/debounce.ts +90 -90
  29. package/src/core/index.ts +4 -4
  30. package/src/core/types.tsx +152 -152
  31. package/src/index.ts +2 -2
  32. package/src/styles/aside.scss +162 -161
  33. package/src/styles/chat.scss +209 -208
  34. package/src/styles/index.scss +153 -110
  35. package/src/styles/input.scss +147 -74
  36. package/src/styles/keyframes.scss +14 -14
  37. package/src/styles/members.scss +13 -13
  38. package/src/styles/mixins.scss +25 -20
  39. package/src/styles/variables.scss +13 -10
  40. package/src/ui/Chat/ChatContext.tsx +30 -30
  41. package/src/ui/Chat/ChatEditableHeaderName.tsx +63 -63
  42. package/src/ui/Chat/ChatHeaderActions.tsx +19 -19
  43. package/src/ui/Chat/ChatPanel.tsx +30 -30
  44. package/src/ui/Chat/ChatView.tsx +115 -115
  45. package/src/ui/Chat/Members/ChatMembersButton.tsx +9 -9
  46. package/src/ui/Chat/Members/ChatMembersPanel.tsx +112 -112
  47. package/src/ui/Chat/Members/ChatMembersPreview.tsx +25 -25
  48. package/src/ui/Chat/Members/index.ts +13 -13
  49. package/src/ui/Chat/index.ts +6 -6
  50. package/src/ui/ChatGroup/ChatGroupContext.tsx +50 -50
  51. package/src/ui/ChatGroup/ChatGroupPanel.tsx +73 -73
  52. package/src/ui/ChatGroup/Create/CreateChatButton.tsx +15 -15
  53. package/src/ui/ChatGroup/Create/CreateChatForm.tsx +36 -36
  54. package/src/ui/ChatGroup/Create/CreateChatMemberInput.tsx +65 -65
  55. package/src/ui/ChatGroup/Create/CreateChatNameInput.tsx +25 -25
  56. package/src/ui/ChatGroup/Create/CreateChatPanel.tsx +45 -45
  57. package/src/ui/ChatGroup/Create/index.ts +19 -19
  58. package/src/ui/ChatGroup/Layout/ChatGroupAside.tsx +12 -12
  59. package/src/ui/ChatGroup/Layout/ChatGroupBody.tsx +10 -10
  60. package/src/ui/ChatGroup/Layout/ChatGroupFooter.tsx +3 -3
  61. package/src/ui/ChatGroup/Layout/ChatGroupHeader.tsx +5 -5
  62. package/src/ui/ChatGroup/Layout/ChatGroupMain.tsx +17 -17
  63. package/src/ui/ChatGroup/Layout/index.ts +19 -19
  64. package/src/ui/ChatGroup/List/ChatList.tsx +41 -41
  65. package/src/ui/ChatGroup/List/ChatListItemAvatar.tsx +22 -22
  66. package/src/ui/ChatGroup/List/ChatListItemBox.tsx +26 -26
  67. package/src/ui/ChatGroup/List/ChatListItemLastMessage.tsx +15 -15
  68. package/src/ui/ChatGroup/List/ChatListItemLastMessageAuthor.tsx +15 -15
  69. package/src/ui/ChatGroup/List/ChatListItemLastMessageContent.tsx +21 -21
  70. package/src/ui/ChatGroup/List/ChatListItemLastMessageSentAt.tsx +22 -22
  71. package/src/ui/ChatGroup/List/ChatListItemName.tsx +8 -8
  72. package/src/ui/ChatGroup/List/ChatListItemUnreadCount.tsx +12 -12
  73. package/src/ui/ChatGroup/List/index.ts +31 -31
  74. package/src/ui/ChatGroup/index.ts +5 -5
  75. package/src/ui/Chatify.tsx +9 -9
  76. package/src/ui/Conversation/Conversation.tsx +78 -76
  77. package/src/ui/Conversation/ConversationActions.tsx +5 -5
  78. package/src/ui/Conversation/ConversationBody.tsx +28 -28
  79. package/src/ui/Conversation/ConversationContext.ts +29 -27
  80. package/src/ui/Conversation/ConversationHeader.tsx +23 -23
  81. package/src/ui/Conversation/ConversationName.tsx +7 -7
  82. package/src/ui/Conversation/InputBox/InputBox.tsx +113 -40
  83. package/src/ui/Conversation/InputBox/InputBoxFile.tsx +38 -0
  84. package/src/ui/Conversation/InputBox/InputBoxFileList.tsx +21 -0
  85. package/src/ui/Conversation/InputBox/InputFilesBox.tsx +78 -9
  86. package/src/ui/Conversation/InputBox/InputSubmitButtonBox.tsx +26 -17
  87. package/src/ui/Conversation/InputBox/InputTextBox.tsx +55 -53
  88. package/src/ui/Conversation/InputBox/index.ts +23 -16
  89. package/src/ui/Conversation/Message/MessageAuthor.tsx +13 -13
  90. package/src/ui/Conversation/Message/MessageBox.tsx +20 -20
  91. package/src/ui/Conversation/Message/MessageContent.tsx +15 -11
  92. package/src/ui/Conversation/Message/MessageFile.tsx +52 -0
  93. package/src/ui/Conversation/Message/MessageFileList.tsx +14 -0
  94. package/src/ui/Conversation/Message/MessageInfoBox.tsx +28 -28
  95. package/src/ui/Conversation/Message/MessageRow.tsx +28 -28
  96. package/src/ui/Conversation/Message/MessageText.tsx +7 -7
  97. package/src/ui/Conversation/Message/index.ts +28 -22
  98. package/src/ui/Conversation/NextObserver/NextMessagesObserver.tsx +47 -47
  99. package/src/ui/Conversation/NextObserver/index.ts +1 -1
  100. package/src/ui/Conversation/ReadObserver/MessageReadObserver.tsx +49 -49
  101. package/src/ui/Conversation/ReadObserver/index.ts +1 -1
  102. package/src/ui/Conversation/SendingMessage/SendingMessageBox.tsx +16 -16
  103. package/src/ui/Conversation/SendingMessage/SendingMessageContent.tsx +13 -13
  104. package/src/ui/Conversation/SendingMessage/SendingMessageInfoBox.tsx +13 -13
  105. package/src/ui/Conversation/SendingMessage/SendingMessageText.tsx +7 -7
  106. package/src/ui/Conversation/SendingMessage/index.ts +16 -16
  107. package/src/ui/Conversation/SystemMessage/SystemMessageBox.tsx +20 -20
  108. package/src/ui/Conversation/SystemMessage/SystemMessageRow.tsx +28 -28
  109. package/src/ui/Conversation/SystemMessage/index.ts +10 -10
  110. package/src/ui/Conversation/index.ts +13 -13
  111. package/src/ui/Thread/ThreadActions.tsx +22 -22
  112. package/src/ui/Thread/ThreadContext.ts +13 -13
  113. package/src/ui/Thread/ThreadPanel.tsx +127 -127
  114. package/src/ui/Thread/index.tsx +3 -3
  115. package/src/ui/color.ts +20 -20
  116. package/src/ui/common/Avatar.tsx +20 -20
  117. package/src/ui/common/Icon.tsx +44 -40
  118. package/src/ui/common/MessageSkeleton.tsx +20 -20
  119. package/src/ui/common/index.ts +13 -13
  120. package/src/ui/customize.tsx +51 -53
  121. package/src/ui/index.ts +11 -11
  122. package/src/ui/localizer.tsx +96 -81
  123. package/src/ui/useFormatter.tsx +17 -0
  124. package/dist/esm/types/core/api/accountApi.d.ts +0 -5
  125. package/dist/esm/types/core/api/chatApi.d.ts +0 -16
  126. package/dist/esm/types/core/api/chatListApi.d.ts +0 -5
  127. package/dist/esm/types/core/api/chatMemberApi.d.ts +0 -6
  128. package/dist/esm/types/core/api/chatMessageApi.d.ts +0 -3
  129. package/dist/esm/types/core/api/threadApi.d.ts +0 -1
  130. package/dist/esm/types/core/api/threadMessageApi.d.ts +0 -6
  131. package/src/core/api/accountApi.ts +0 -11
  132. package/src/core/api/chatApi.ts +0 -87
  133. package/src/core/api/chatListApi.ts +0 -134
  134. package/src/core/api/chatMemberApi.ts +0 -20
  135. package/src/core/api/chatMessageApi.ts +0 -12
  136. package/src/core/api/threadApi.ts +0 -8
  137. package/src/core/api/threadMessageApi.ts +0 -20
  138. package/src/types/core/api/accountApi.d.ts +0 -5
  139. package/src/types/core/api/api.d.ts +0 -2380
  140. package/src/types/core/api/baseApi.d.ts +0 -15
  141. package/src/types/core/api/chatApi.d.ts +0 -16
  142. package/src/types/core/api/chatListApi.d.ts +0 -5
  143. package/src/types/core/api/chatMemberApi.d.ts +0 -6
  144. package/src/types/core/api/chatMessageApi.d.ts +0 -3
  145. package/src/types/core/api/index.d.ts +0 -1
  146. package/src/types/core/api/threadApi.d.ts +0 -1
  147. package/src/types/core/api/threadMessageApi.d.ts +0 -6
  148. package/src/types/core/client.d.ts +0 -83
  149. package/src/types/core/constants.d.ts +0 -1
  150. package/src/types/core/debounce.d.ts +0 -27
  151. package/src/types/core/index.d.ts +0 -4
  152. package/src/types/core/types.d.ts +0 -105
  153. package/src/types/index.d.ts +0 -2
  154. package/src/types/ui/Chat/ChatContext.d.ts +0 -10
  155. package/src/types/ui/Chat/ChatEditableHeaderName.d.ts +0 -2
  156. package/src/types/ui/Chat/ChatHeaderActions.d.ts +0 -2
  157. package/src/types/ui/Chat/ChatPanel.d.ts +0 -13
  158. package/src/types/ui/Chat/ChatView.d.ts +0 -17
  159. package/src/types/ui/Chat/Members/ChatMembersButton.d.ts +0 -2
  160. package/src/types/ui/Chat/Members/ChatMembersPanel.d.ts +0 -2
  161. package/src/types/ui/Chat/Members/ChatMembersPreview.d.ts +0 -2
  162. package/src/types/ui/Chat/Members/index.d.ts +0 -11
  163. package/src/types/ui/Chat/index.d.ts +0 -6
  164. package/src/types/ui/ChatGroup/ChatGroupContext.d.ts +0 -12
  165. package/src/types/ui/ChatGroup/ChatGroupPanel.d.ts +0 -15
  166. package/src/types/ui/ChatGroup/Create/CreateChatButton.d.ts +0 -2
  167. package/src/types/ui/ChatGroup/Create/CreateChatForm.d.ts +0 -11
  168. package/src/types/ui/ChatGroup/Create/CreateChatMemberInput.d.ts +0 -5
  169. package/src/types/ui/ChatGroup/Create/CreateChatNameInput.d.ts +0 -5
  170. package/src/types/ui/ChatGroup/Create/CreateChatPanel.d.ts +0 -2
  171. package/src/types/ui/ChatGroup/Create/index.d.ts +0 -17
  172. package/src/types/ui/ChatGroup/Layout/ChatGroupAside.d.ts +0 -2
  173. package/src/types/ui/ChatGroup/Layout/ChatGroupBody.d.ts +0 -2
  174. package/src/types/ui/ChatGroup/Layout/ChatGroupFooter.d.ts +0 -2
  175. package/src/types/ui/ChatGroup/Layout/ChatGroupHeader.d.ts +0 -2
  176. package/src/types/ui/ChatGroup/Layout/ChatGroupMain.d.ts +0 -2
  177. package/src/types/ui/ChatGroup/Layout/index.d.ts +0 -17
  178. package/src/types/ui/ChatGroup/List/ChatList.d.ts +0 -2
  179. package/src/types/ui/ChatGroup/List/ChatListItemAvatar.d.ts +0 -3
  180. package/src/types/ui/ChatGroup/List/ChatListItemBox.d.ts +0 -6
  181. package/src/types/ui/ChatGroup/List/ChatListItemLastMessage.d.ts +0 -3
  182. package/src/types/ui/ChatGroup/List/ChatListItemLastMessageAuthor.d.ts +0 -3
  183. package/src/types/ui/ChatGroup/List/ChatListItemLastMessageContent.d.ts +0 -3
  184. package/src/types/ui/ChatGroup/List/ChatListItemLastMessageSentAt.d.ts +0 -3
  185. package/src/types/ui/ChatGroup/List/ChatListItemName.d.ts +0 -3
  186. package/src/types/ui/ChatGroup/List/ChatListItemUnreadCount.d.ts +0 -3
  187. package/src/types/ui/ChatGroup/List/index.d.ts +0 -29
  188. package/src/types/ui/ChatGroup/index.d.ts +0 -5
  189. package/src/types/ui/Chatify.d.ts +0 -8
  190. package/src/types/ui/Conversation/Conversation.d.ts +0 -21
  191. package/src/types/ui/Conversation/ConversationActions.d.ts +0 -2
  192. package/src/types/ui/Conversation/ConversationBody.d.ts +0 -2
  193. package/src/types/ui/Conversation/ConversationContext.d.ts +0 -20
  194. package/src/types/ui/Conversation/ConversationHeader.d.ts +0 -2
  195. package/src/types/ui/Conversation/ConversationName.d.ts +0 -2
  196. package/src/types/ui/Conversation/InputBox/InputBox.d.ts +0 -2
  197. package/src/types/ui/Conversation/InputBox/InputFilesBox.d.ts +0 -2
  198. package/src/types/ui/Conversation/InputBox/InputSubmitButtonBox.d.ts +0 -5
  199. package/src/types/ui/Conversation/InputBox/InputTextBox.d.ts +0 -8
  200. package/src/types/ui/Conversation/InputBox/index.d.ts +0 -14
  201. package/src/types/ui/Conversation/Message/MessageAuthor.d.ts +0 -3
  202. package/src/types/ui/Conversation/Message/MessageBox.d.ts +0 -6
  203. package/src/types/ui/Conversation/Message/MessageContent.d.ts +0 -3
  204. package/src/types/ui/Conversation/Message/MessageInfoBox.d.ts +0 -3
  205. package/src/types/ui/Conversation/Message/MessageRow.d.ts +0 -6
  206. package/src/types/ui/Conversation/Message/MessageText.d.ts +0 -3
  207. package/src/types/ui/Conversation/Message/index.d.ts +0 -20
  208. package/src/types/ui/Conversation/NextObserver/NextMessagesObserver.d.ts +0 -5
  209. package/src/types/ui/Conversation/NextObserver/index.d.ts +0 -1
  210. package/src/types/ui/Conversation/ReadObserver/MessageReadObserver.d.ts +0 -6
  211. package/src/types/ui/Conversation/ReadObserver/index.d.ts +0 -1
  212. package/src/types/ui/Conversation/SendingMessage/SendingMessageBox.d.ts +0 -7
  213. package/src/types/ui/Conversation/SendingMessage/SendingMessageContent.d.ts +0 -3
  214. package/src/types/ui/Conversation/SendingMessage/SendingMessageInfoBox.d.ts +0 -3
  215. package/src/types/ui/Conversation/SendingMessage/SendingMessageText.d.ts +0 -3
  216. package/src/types/ui/Conversation/SendingMessage/index.d.ts +0 -14
  217. package/src/types/ui/Conversation/SystemMessage/SystemMessageBox.d.ts +0 -6
  218. package/src/types/ui/Conversation/SystemMessage/SystemMessageRow.d.ts +0 -9
  219. package/src/types/ui/Conversation/SystemMessage/index.d.ts +0 -8
  220. package/src/types/ui/Conversation/index.d.ts +0 -12
  221. package/src/types/ui/Thread/ThreadActions.d.ts +0 -2
  222. package/src/types/ui/Thread/ThreadContext.d.ts +0 -8
  223. package/src/types/ui/Thread/ThreadPanel.d.ts +0 -14
  224. package/src/types/ui/Thread/index.d.ts +0 -3
  225. package/src/types/ui/color.d.ts +0 -6
  226. package/src/types/ui/common/Avatar.d.ts +0 -6
  227. package/src/types/ui/common/Icon.d.ts +0 -20
  228. package/src/types/ui/common/MessageSkeleton.d.ts +0 -5
  229. package/src/types/ui/common/index.d.ts +0 -11
  230. package/src/types/ui/customize.d.ts +0 -9
  231. package/src/types/ui/index.d.ts +0 -11
  232. package/src/types/ui/localizer.d.ts +0 -35
@@ -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">{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);
@@ -1,40 +1,44 @@
1
- import { FC } from 'react';
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
-
15
- export type IconType = keyof typeof ICONS;
16
-
17
- export interface IconProps {
18
- type: IconType;
19
- }
20
-
21
- export const ICONS = {
22
- attach: PaperClipOutlined,
23
- send: SendOutlined,
24
- 'remove-member': UserDeleteOutlined,
25
- 'remove-member-delete-history': UsergroupDeleteOutlined,
26
- 'add-member': UserAddOutlined,
27
- 'add-member-with-history': UsergroupAddOutlined,
28
- members: TeamOutlined,
29
- edit: EditOutlined,
30
- close: CloseOutlined,
31
- chat: TeamOutlined,
32
- watch: EyeOutlined,
33
- unwatch: EyeInvisibleOutlined,
34
- };
35
-
36
- export const Icon = customize<FC<IconProps>>('Icon', (props) => {
37
- const { type } = props;
38
- const IconComponent = ICONS[type];
39
- return IconComponent ? <IconComponent /> : null;
40
- });
1
+ import { FC } from 'react';
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';
16
+
17
+ export type IconType = keyof typeof ICONS;
18
+
19
+ export interface IconProps {
20
+ type: IconType;
21
+ }
22
+
23
+ export const ICONS = {
24
+ attach: PaperClipOutlined,
25
+ send: SendOutlined,
26
+ 'remove-member': UserDeleteOutlined,
27
+ 'remove-member-delete-history': UsergroupDeleteOutlined,
28
+ 'add-member': UserAddOutlined,
29
+ 'add-member-with-history': UsergroupAddOutlined,
30
+ members: TeamOutlined,
31
+ edit: EditOutlined,
32
+ close: CloseOutlined,
33
+ chat: TeamOutlined,
34
+ watch: EyeOutlined,
35
+ unwatch: EyeInvisibleOutlined,
36
+ 'delete-file': DeleteOutlined,
37
+ 'open-file': DownloadOutlined,
38
+ };
39
+
40
+ export const Icon = customize<FC<IconProps>>('Icon', (props) => {
41
+ const { type } = props;
42
+ const IconComponent = ICONS[type];
43
+ return IconComponent ? <IconComponent /> : null;
44
+ });
@@ -1,20 +1,20 @@
1
- import { Skeleton } from 'antd';
2
- import { customize } from '../customize';
3
-
4
- export interface MessageSkeletonProps {
5
- count?: number;
6
- }
7
-
8
- export const MessageSkeleton = customize('MessageSkeleton', (props: MessageSkeletonProps) => {
9
- const { count = 1 } = props;
10
- return (
11
- <>
12
- {Array.from(Array(count)).map((_, index) => (
13
- <div className="wxchtf-message-skeleton" key={index}>
14
- <Skeleton.Avatar className="wxchtf-avatar" active />
15
- <Skeleton.Button active className="wxchtf-content" />
16
- </div>
17
- ))}
18
- </>
19
- );
20
- });
1
+ import { Skeleton } from 'antd';
2
+ import { customize } from '../customize';
3
+
4
+ export interface MessageSkeletonProps {
5
+ count?: number;
6
+ }
7
+
8
+ export const MessageSkeleton = customize('MessageSkeleton', (props: MessageSkeletonProps) => {
9
+ const { count = 1 } = props;
10
+ return (
11
+ <>
12
+ {Array.from(Array(count)).map((_, index) => (
13
+ <div className="wxchtf-message-skeleton" key={index}>
14
+ <Skeleton.Avatar className="wxchtf-avatar" active />
15
+ <Skeleton.Button active className="wxchtf-content" />
16
+ </div>
17
+ ))}
18
+ </>
19
+ );
20
+ });