@blocklet/discuss-kit-ux 2.4.35 → 2.4.37

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 (222) hide show
  1. package/dist/axios.d.ts +8 -0
  2. package/dist/blocklets.d.ts +1 -1
  3. package/dist/blocklets.mjs +17 -0
  4. package/dist/components/api-error-handler/api-error-handler.d.ts +1 -1
  5. package/dist/components/api-error-handler/api-error-handler.mjs +25 -0
  6. package/dist/components/api-error-handler/default-handler.mjs +69 -0
  7. package/dist/components/api-error-handler/index.mjs +2 -0
  8. package/dist/components/api-error-handler/json-validation-interceptor.d.ts +1 -1
  9. package/dist/components/api-error-handler/json-validation-interceptor.mjs +9 -0
  10. package/dist/components/arcsphere/index.mjs +51 -0
  11. package/dist/components/authz/access-control.d.ts +15 -1
  12. package/dist/components/authz/access-control.mjs +15 -0
  13. package/dist/components/authz/context.d.ts +2 -1
  14. package/dist/components/authz/context.mjs +30 -0
  15. package/dist/components/authz/index.d.ts +1 -1
  16. package/dist/components/authz/index.mjs +2 -0
  17. package/dist/components/auto-translate/api.d.ts +1 -1
  18. package/dist/components/auto-translate/api.mjs +23 -0
  19. package/dist/components/auto-translate/auto-translate-button.d.ts +2 -1
  20. package/dist/components/auto-translate/auto-translate-button.mjs +47 -0
  21. package/dist/components/auto-translate/editor-store-adaptor.mjs +14 -0
  22. package/dist/components/auto-translate/index.mjs +6 -0
  23. package/dist/components/auto-translate/languages.mjs +61 -0
  24. package/dist/components/auto-translate/post-auto-translate-plugin.d.ts +4 -3
  25. package/dist/components/auto-translate/post-auto-translate-plugin.mjs +32 -0
  26. package/dist/components/auto-translate/store.d.ts +3 -3
  27. package/dist/components/auto-translate/store.mjs +23 -0
  28. package/dist/components/auto-translate/translate.d.ts +3 -2
  29. package/dist/components/auto-translate/translate.mjs +103 -0
  30. package/dist/components/auto-translate/utils.d.ts +1 -1
  31. package/dist/components/auto-translate/utils.mjs +14 -0
  32. package/dist/components/auto-translate/with-availibility-check.d.ts +1 -1
  33. package/dist/components/auto-translate/with-availibility-check.mjs +10 -0
  34. package/dist/components/avatars/author-info.d.ts +3 -2
  35. package/dist/components/avatars/author-info.mjs +184 -0
  36. package/dist/components/avatars/avatar.d.ts +2 -1
  37. package/dist/components/avatars/avatar.mjs +9 -0
  38. package/dist/components/avatars/avatars.d.ts +4 -3
  39. package/dist/components/avatars/avatars.mjs +49 -0
  40. package/dist/components/avatars/badge.d.ts +2 -1
  41. package/dist/components/avatars/badge.mjs +178 -0
  42. package/dist/components/avatars/index.mjs +5 -0
  43. package/dist/components/avatars/system-user.d.ts +1 -1
  44. package/dist/components/avatars/system-user.mjs +58 -0
  45. package/dist/components/back.d.ts +2 -1
  46. package/dist/components/back.mjs +28 -0
  47. package/dist/components/blog/blog-link.mjs +16 -0
  48. package/dist/components/blog/blog-list.d.ts +4 -3
  49. package/dist/components/blog/blog-list.mjs +441 -0
  50. package/dist/components/blog/cover-image.d.ts +4 -3
  51. package/dist/components/blog/cover-image.mjs +160 -0
  52. package/dist/components/blog/index.mjs +4 -0
  53. package/dist/components/blog/permalink.d.ts +3 -2
  54. package/dist/components/blog/permalink.mjs +78 -0
  55. package/dist/components/blog/types.d.ts +1 -1
  56. package/dist/components/blog/types.mjs +0 -0
  57. package/dist/components/button-group/button-group.d.ts +2 -1
  58. package/dist/components/button-group/button-group.mjs +195 -0
  59. package/dist/components/button-group/index.mjs +1 -0
  60. package/dist/components/chat/channel-group.d.ts +3 -2
  61. package/dist/components/chat/channel-group.mjs +41 -0
  62. package/dist/components/chat/chat-client.d.ts +2 -2
  63. package/dist/components/chat/chat-client.mjs +33 -0
  64. package/dist/components/chat/chat-header-addon.d.ts +2 -1
  65. package/dist/components/chat/chat-header-addon.mjs +26 -0
  66. package/dist/components/chat/chat-in-wallet.d.ts +2 -1
  67. package/dist/components/chat/chat-in-wallet.mjs +67 -0
  68. package/dist/components/chat/chat-input.d.ts +3 -2
  69. package/dist/components/chat/chat-input.mjs +295 -0
  70. package/dist/components/chat/chat-list-in-wallet.d.ts +2 -1
  71. package/dist/components/chat/chat-list-in-wallet.mjs +113 -0
  72. package/dist/components/chat/chat-list.d.ts +2 -1
  73. package/dist/components/chat/chat-list.mjs +109 -0
  74. package/dist/components/chat/chat-room.d.ts +3 -2
  75. package/dist/components/chat/chat-room.mjs +225 -0
  76. package/dist/components/chat/chat.d.ts +2 -1
  77. package/dist/components/chat/chat.mjs +163 -0
  78. package/dist/components/chat/context.d.ts +4 -3
  79. package/dist/components/chat/context.mjs +303 -0
  80. package/dist/components/chat/hooks.d.ts +1 -1
  81. package/dist/components/chat/hooks.mjs +59 -0
  82. package/dist/components/chat/index.mjs +7 -0
  83. package/dist/components/chat/message-list.d.ts +3 -2
  84. package/dist/components/chat/message-list.mjs +151 -0
  85. package/dist/components/chat/message.d.ts +4 -3
  86. package/dist/components/chat/message.mjs +312 -0
  87. package/dist/components/chat/participants.d.ts +3 -2
  88. package/dist/components/chat/participants.mjs +60 -0
  89. package/dist/components/chat/time.d.ts +1 -1
  90. package/dist/components/chat/time.mjs +16 -0
  91. package/dist/components/chat/types.d.ts +1 -1
  92. package/dist/components/chat/types.mjs +0 -0
  93. package/dist/components/chat/unread-notification.d.ts +2 -2
  94. package/dist/components/chat/unread-notification.mjs +43 -0
  95. package/dist/components/chat/user-search.d.ts +2 -1
  96. package/dist/components/chat/user-search.mjs +143 -0
  97. package/dist/components/check-mark.d.ts +2 -1
  98. package/dist/components/check-mark.mjs +98 -0
  99. package/dist/components/confirm.d.ts +4 -4
  100. package/dist/components/confirm.mjs +103 -0
  101. package/dist/components/dayjs.d.ts +1 -1
  102. package/dist/components/dayjs.mjs +4 -0
  103. package/dist/components/default-editor-config-provider.d.ts +3 -2
  104. package/dist/components/default-editor-config-provider.mjs +107 -0
  105. package/dist/components/dirty-prompt.d.ts +3 -2
  106. package/dist/components/dirty-prompt.mjs +117 -0
  107. package/dist/components/editor/editor.d.ts +4 -3
  108. package/dist/{editor-B3z0rXVh.mjs → components/editor/editor.mjs} +7 -8
  109. package/dist/components/editor/index.mjs +2 -0
  110. package/dist/components/editor/lazy-editor.d.ts +3 -2
  111. package/dist/components/editor/lazy-editor.mjs +14 -0
  112. package/dist/components/editor/plugins/video-path-fixer-plugin.mjs +29 -0
  113. package/dist/components/editor/preview.d.ts +4 -3
  114. package/dist/components/editor/preview.mjs +32 -0
  115. package/dist/components/emoji-icon.d.ts +2 -1
  116. package/dist/components/emoji-icon.mjs +62 -0
  117. package/dist/components/empty-status/empty-status.d.ts +2 -1
  118. package/dist/components/empty-status/empty-status.mjs +24 -0
  119. package/dist/components/empty-status/index.mjs +1 -0
  120. package/dist/components/hooks/changed.mjs +34 -0
  121. package/dist/components/hooks/index.mjs +6 -0
  122. package/dist/components/hooks/interval.mjs +16 -0
  123. package/dist/components/hooks/locale-context.mjs +12 -0
  124. package/dist/components/hooks/measure.mjs +8 -0
  125. package/dist/components/hooks/now.mjs +10 -0
  126. package/dist/components/hooks/responsive.d.ts +1 -1
  127. package/dist/components/hooks/responsive.mjs +25 -0
  128. package/dist/components/hooks/session.d.ts +1 -0
  129. package/dist/components/hooks/session.mjs +41 -0
  130. package/dist/components/hooks/use-event-callback.mjs +14 -0
  131. package/dist/components/icon-button.d.ts +4 -3
  132. package/dist/components/icon-button.mjs +37 -0
  133. package/dist/components/input/auto-clear-plugin.mjs +26 -0
  134. package/dist/components/input/comment-input.d.ts +2 -1
  135. package/dist/components/input/comment-input.mjs +107 -0
  136. package/dist/components/input/image-path-fixer-plugin.mjs +29 -0
  137. package/dist/components/input/index.mjs +4 -0
  138. package/dist/components/input/input.d.ts +4 -4
  139. package/dist/components/input/input.mjs +152 -0
  140. package/dist/components/input/post-edit.d.ts +2 -1
  141. package/dist/components/input/post-edit.mjs +49 -0
  142. package/dist/components/input/scrollable-editor-wrapper.d.ts +2 -1
  143. package/dist/components/input/scrollable-editor-wrapper.mjs +18 -0
  144. package/dist/components/input/shortcut-plugin.mjs +28 -0
  145. package/dist/components/label-picker.d.ts +2 -1
  146. package/dist/components/label-picker.mjs +41 -0
  147. package/dist/components/lexical.mjs +69 -0
  148. package/dist/components/locale/en.mjs +92 -0
  149. package/dist/components/locale/index.mjs +3 -0
  150. package/dist/components/locale/zh.mjs +94 -0
  151. package/dist/components/pagination.d.ts +3 -2
  152. package/dist/components/pagination.mjs +44 -0
  153. package/dist/components/paywall.d.ts +2 -2
  154. package/dist/components/paywall.mjs +110 -0
  155. package/dist/components/point-up/{box-animation.json.d.ts → box-animation.json} +1 -4
  156. package/dist/components/point-up/index.d.ts +3 -2
  157. package/dist/components/point-up/index.mjs +153 -0
  158. package/dist/components/point-up/lottie-component.d.ts +2 -1
  159. package/dist/components/point-up/lottie-component.mjs +7 -0
  160. package/dist/components/posts/comment-list/comment-list.d.ts +2 -1
  161. package/dist/components/posts/comment-list/comment-list.mjs +163 -0
  162. package/dist/components/posts/comment-list/context.d.ts +4 -4
  163. package/dist/components/posts/comment-list/context.mjs +318 -0
  164. package/dist/components/posts/comment.d.ts +3 -2
  165. package/dist/components/posts/comment.mjs +184 -0
  166. package/dist/components/posts/index.mjs +6 -0
  167. package/dist/components/posts/menu.d.ts +3 -2
  168. package/dist/components/posts/menu.mjs +83 -0
  169. package/dist/components/posts/post-content.d.ts +2 -1
  170. package/dist/components/posts/post-content.mjs +86 -0
  171. package/dist/components/posts/post.d.ts +4 -4
  172. package/dist/components/posts/post.mjs +198 -0
  173. package/dist/components/profile-card/index.mjs +1 -0
  174. package/dist/components/profile-card/profile-card.d.ts +4 -3
  175. package/dist/components/profile-card/profile-card.mjs +162 -0
  176. package/dist/components/rating/binary-thumb.d.ts +4 -3
  177. package/dist/components/rating/binary-thumb.mjs +157 -0
  178. package/dist/components/rating/github-reaction-container.d.ts +2 -1
  179. package/dist/components/rating/github-reaction-container.mjs +46 -0
  180. package/dist/components/rating/github-reaction.d.ts +3 -2
  181. package/dist/components/rating/github-reaction.mjs +173 -0
  182. package/dist/components/rating/index.mjs +3 -0
  183. package/dist/components/rating/rater-list.d.ts +3 -2
  184. package/dist/components/rating/rater-list.mjs +33 -0
  185. package/dist/components/rating/rating.d.ts +1 -1
  186. package/dist/components/rating/rating.mjs +50 -0
  187. package/dist/components/routes.d.ts +1 -1
  188. package/dist/components/routes.mjs +27 -0
  189. package/dist/components/segmented-control.d.ts +3 -2
  190. package/dist/components/segmented-control.mjs +55 -0
  191. package/dist/components/shared/relative-time.d.ts +2 -1
  192. package/dist/components/shared/relative-time.mjs +21 -0
  193. package/dist/components/toast.d.ts +1 -1
  194. package/dist/components/toast.mjs +44 -0
  195. package/dist/components/uploader/index.d.ts +3 -3
  196. package/dist/components/uploader/index.mjs +70 -0
  197. package/dist/components/uploader/utils.mjs +16 -0
  198. package/dist/components/utils.d.ts +4 -4
  199. package/dist/components/utils.mjs +139 -0
  200. package/dist/components/view-more.d.ts +1 -1
  201. package/dist/components/view-more.mjs +50 -0
  202. package/dist/constants.mjs +14 -0
  203. package/dist/global.d.ts +1 -0
  204. package/dist/index.mjs +37 -0
  205. package/dist/preferences.mjs +9 -0
  206. package/dist/theme/index.d.ts +3 -3
  207. package/dist/theme/index.mjs +96 -0
  208. package/dist/theme/typography.d.ts +1 -1
  209. package/dist/theme/typography.mjs +66 -0
  210. package/dist/type-override.d.ts +7 -0
  211. package/dist/types.mjs +0 -0
  212. package/dist/vite-env.d.ts +1 -0
  213. package/dist/ws.d.ts +2 -2
  214. package/dist/ws.mjs +39 -0
  215. package/package.json +18 -25
  216. package/dist/components/avatars/Avatars.stories.d.ts +0 -5
  217. package/dist/components/posts/Post.stories.d.ts +0 -7
  218. package/dist/index-BlqRGWgQ.mjs +0 -7631
  219. package/dist/index.es.js +0 -118
  220. package/dist/index.umd.js +0 -7589
  221. package/dist/test/fixtures/index.d.ts +0 -4
  222. package/dist/test/fixtures/mock-session.d.ts +0 -3
@@ -0,0 +1,67 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useMemo } from "react";
3
+ import { useParams } from "react-router-dom";
4
+ import { Backdrop, useMediaQuery } from "@mui/material";
5
+ import Box from "@mui/material/Box";
6
+ import CircularProgress from "@mui/material/CircularProgress";
7
+ import ChatBubbleEmptyIcon from "virtual:icons/iconoir/chat-bubble-empty";
8
+ import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
9
+ import ChatRoom from "./chat-room.mjs";
10
+ import { useChatContext } from "./context.mjs";
11
+ function Empty({ sx }) {
12
+ const { t } = useLocaleContext();
13
+ const mergedSx = [
14
+ {
15
+ display: "flex",
16
+ flexDirection: "column",
17
+ justifyContent: "center",
18
+ alignItems: "center",
19
+ gap: 1,
20
+ color: "grey.600"
21
+ },
22
+ ...Array.isArray(sx) ? sx : [sx]
23
+ ];
24
+ return /* @__PURE__ */ jsxs(Box, { sx: mergedSx, children: [
25
+ /* @__PURE__ */ jsx(ChatBubbleEmptyIcon, { style: { fontSize: 32 } }),
26
+ /* @__PURE__ */ jsx(Box, { component: "span", sx: { fontSize: 14, fontWeight: 500 }, children: t("chat.noChats") })
27
+ ] });
28
+ }
29
+ export default function ChatInWallet({ sx, ...rest }) {
30
+ const { chatId: activeChatId } = useParams();
31
+ const { initialized, chats } = useChatContext();
32
+ const downMd = useMediaQuery((theme) => theme.breakpoints.down("sm"));
33
+ const activeChat = chats?.filter((chat) => chat?.id === activeChatId)?.[0];
34
+ const show = useMemo(() => {
35
+ if (downMd) {
36
+ return {
37
+ left: !activeChatId,
38
+ right: !!activeChatId
39
+ };
40
+ }
41
+ return {
42
+ left: true,
43
+ right: true
44
+ };
45
+ }, [downMd, activeChatId]);
46
+ if (!initialized) {
47
+ return /* @__PURE__ */ jsx(
48
+ Backdrop,
49
+ {
50
+ open: true,
51
+ sx: {
52
+ zIndex: (theme) => theme.zIndex.drawer + 1,
53
+ bgcolor: "transparent"
54
+ },
55
+ children: /* @__PURE__ */ jsx(CircularProgress, {})
56
+ }
57
+ );
58
+ }
59
+ const mergedSx = [
60
+ { display: "flex", height: "100%", bgcolor: "background.default" },
61
+ ...Array.isArray(sx) ? sx : [sx]
62
+ ];
63
+ return /* @__PURE__ */ jsx(Box, { ...rest, sx: mergedSx, children: show.right && /* @__PURE__ */ jsxs(Box, { sx: { flex: 1, overflow: "hidden" }, children: [
64
+ /* @__PURE__ */ jsx(ChatRoom, { chat: activeChat, inWallet: true }),
65
+ !activeChatId && /* @__PURE__ */ jsx(Empty, { sx: { height: 1 } })
66
+ ] }) });
67
+ }
@@ -1,9 +1,10 @@
1
- import { EditorProps } from '../editor';
1
+ /// <reference types="react" />
2
+ import { type EditorProps } from '../editor';
2
3
  interface Props extends EditorProps {
3
4
  initialContent?: string;
4
5
  send: (content: string) => Promise<void>;
5
6
  onContentChange?: (content: string) => void;
6
7
  onFocusChange?: (focused: boolean) => void;
7
8
  }
8
- export declare function ChatInput({ initialContent, send, onContentChange, onFocusChange }: Props): import("react/jsx-runtime").JSX.Element;
9
+ export declare function ChatInput({ initialContent, send, onContentChange, onFocusChange }: Props): import("react").JSX.Element;
9
10
  export {};
@@ -0,0 +1,295 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Box, Button, CircularProgress } from "@mui/material";
3
+ import SendIcon from "virtual:icons/tabler/send";
4
+ import LetterCaseIcon from "virtual:icons/tabler/letter-case";
5
+ import { useIsFocused } from "@blocklet/editor/lib/main/hooks/useIsFocused";
6
+ import { BusyPlugin } from "@blocklet/editor/lib/ext/BusyPlugin";
7
+ import { useEffect, useState } from "react";
8
+ import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
9
+ import { useBrowser } from "@arcblock/react-hooks";
10
+ import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
11
+ import { KEY_ENTER_COMMAND, COMMAND_PRIORITY_LOW, $getRoot, $getSelection, $createParagraphNode } from "lexical";
12
+ import { useLocalStorageState } from "ahooks";
13
+ import { EditorConfigProvider } from "@blocklet/editor";
14
+ import { LazyEditor } from "../editor/index.mjs";
15
+ import { MAX_COMMENT_LENGTH } from "../../constants.mjs";
16
+ function AutoClearPlugin({ clearKey }) {
17
+ const [editor] = useLexicalComposerContext();
18
+ useEffect(() => {
19
+ if (editor && clearKey) {
20
+ editor.update(() => {
21
+ const root = $getRoot();
22
+ const paragraph = $createParagraphNode();
23
+ root.clear();
24
+ root.append(paragraph);
25
+ if ($getSelection() !== null) {
26
+ paragraph.select();
27
+ }
28
+ });
29
+ }
30
+ }, [editor, clearKey]);
31
+ return null;
32
+ }
33
+ function FocusPlugin({ callback }) {
34
+ const hasFocus = useIsFocused();
35
+ useEffect(() => {
36
+ callback(hasFocus);
37
+ }, [callback, hasFocus]);
38
+ return null;
39
+ }
40
+ function DraggerPlugin() {
41
+ const [editor] = useLexicalComposerContext();
42
+ const { mobile } = useBrowser();
43
+ const hasFocus = useIsFocused();
44
+ const selection = editor.getEditorState().read($getSelection);
45
+ const enabled = mobile.any && hasFocus && selection;
46
+ const detectSwipe = (node, callback) => {
47
+ let touchstartY = 0;
48
+ let touchendY = 0;
49
+ function handleSwipe() {
50
+ if (touchstartY - touchendY > 10 || touchendY - touchstartY > 10) {
51
+ callback();
52
+ }
53
+ }
54
+ const onTouchStart = (event) => {
55
+ touchstartY = event.changedTouches[0].screenY;
56
+ };
57
+ const onTouchEnd = (event) => {
58
+ touchendY = event.changedTouches[0].screenY;
59
+ handleSwipe();
60
+ };
61
+ node.addEventListener("touchstart", onTouchStart, false);
62
+ node.addEventListener("touchend", onTouchEnd, false);
63
+ return () => {
64
+ node.removeEventListener("touchstart", onTouchStart, false);
65
+ node.removeEventListener("touchend", onTouchEnd, false);
66
+ };
67
+ };
68
+ useEffect(() => {
69
+ const root = editor.getRootElement();
70
+ if (enabled && root) {
71
+ const cleanup = [detectSwipe(document.body, () => editor.blur()), detectSwipe(root, () => editor.blur())];
72
+ return () => {
73
+ cleanup.forEach((fn) => fn());
74
+ };
75
+ }
76
+ return () => {
77
+ };
78
+ }, [editor, enabled]);
79
+ if (enabled) {
80
+ return /* @__PURE__ */ jsx(
81
+ Box,
82
+ {
83
+ sx: {
84
+ position: "absolute",
85
+ left: "50%",
86
+ top: 4,
87
+ width: 64,
88
+ marginLeft: "-32px",
89
+ height: 4,
90
+ bgcolor: "grey.300",
91
+ borderRadius: 0.1
92
+ }
93
+ }
94
+ );
95
+ }
96
+ return null;
97
+ }
98
+ function ShortcutPlugin({ callback }) {
99
+ const [editor] = useLexicalComposerContext();
100
+ const { mobile } = useBrowser();
101
+ useEffect(() => {
102
+ return editor.registerCommand(
103
+ KEY_ENTER_COMMAND,
104
+ (e) => {
105
+ if (mobile.any || e.shiftKey) {
106
+ return false;
107
+ }
108
+ if (document.getElementById("typeahead-menu")) {
109
+ return false;
110
+ }
111
+ callback();
112
+ e.preventDefault();
113
+ return true;
114
+ },
115
+ COMMAND_PRIORITY_LOW
116
+ );
117
+ }, [editor, callback, mobile.any]);
118
+ return null;
119
+ }
120
+ export function ChatInput({ initialContent, send, onContentChange, onFocusChange }) {
121
+ const { t } = useLocaleContext();
122
+ const [content, setContent] = useState("");
123
+ const [lastSent, setLastSent] = useState(0);
124
+ const [toolbarVisible, setToolbarVisible] = useLocalStorageState("chat-input-toolbar-visible", {
125
+ defaultValue: false
126
+ });
127
+ const { mobile } = useBrowser();
128
+ const [focused, setFocused] = useState(false);
129
+ const [editorBusy, setEditorBusy] = useState(false);
130
+ const FocusCallback = (v) => {
131
+ setFocused(v);
132
+ onFocusChange?.(v);
133
+ };
134
+ const onToolbarBtnMouseDown = (e) => {
135
+ e.preventDefault();
136
+ setToolbarVisible((x) => !x);
137
+ };
138
+ const compactView = mobile.any && !focused;
139
+ const handleSend = () => {
140
+ if (!content || editorBusy) return;
141
+ send(content);
142
+ setContent("");
143
+ setLastSent(Date.now());
144
+ };
145
+ const onSendBtnMouseDown = (e) => {
146
+ e.preventDefault();
147
+ handleSend();
148
+ };
149
+ return /* @__PURE__ */ jsxs(
150
+ Box,
151
+ {
152
+ sx: {
153
+ position: "relative",
154
+ pb: 5,
155
+ border: 1,
156
+ borderColor: "divider",
157
+ borderRadius: 1,
158
+ overflow: "hidden",
159
+ ".be-shell": { borderTop: "0 !important" },
160
+ ".be-shell .toolbar": { bgcolor: "grey.50", ...!toolbarVisible && { display: "none" } },
161
+ ".be-shell .be-editable": { px: "16px !important" },
162
+ ".be-shell .be-placeholder": { left: 16 },
163
+ ".be-shell .be-editable, .be-shell .be-content": { minHeight: "20px !important" },
164
+ ".be-shell .be-editable p": { my: 0 },
165
+ ".draggable-block-menu": { display: "none" },
166
+ ...compactView && {
167
+ pb: 0,
168
+ borderRadius: 2,
169
+ borderBottomLeftRadius: 0,
170
+ borderBottomRightRadius: 0
171
+ }
172
+ },
173
+ children: [
174
+ /* @__PURE__ */ jsxs(
175
+ Box,
176
+ {
177
+ sx: {
178
+ maxHeight: 400,
179
+ overflowY: "auto",
180
+ ...compactView && {
181
+ height: 44 + (toolbarVisible ? 44 : 0),
182
+ pt: toolbarVisible ? 0 : 0.5,
183
+ pb: 0.5,
184
+ overflow: "hidden",
185
+ ".be-shell .be-editable": { pr: "44px !important" }
186
+ }
187
+ },
188
+ children: [
189
+ compactView && !toolbarVisible && /* @__PURE__ */ jsx(
190
+ Box,
191
+ {
192
+ sx: {
193
+ position: "absolute",
194
+ right: 12,
195
+ top: 12,
196
+ display: "flex",
197
+ justifyContent: "center",
198
+ alignItems: "center",
199
+ width: 28,
200
+ height: 28,
201
+ bgcolor: "grey.300",
202
+ borderRadius: "100%"
203
+ },
204
+ children: /* @__PURE__ */ jsx(Box, { component: SendIcon, sx: { fontSize: 13, color: "text.secondary" } })
205
+ }
206
+ ),
207
+ /* @__PURE__ */ jsx(
208
+ EditorConfigProvider,
209
+ {
210
+ value: {
211
+ minimalMode: true,
212
+ characterLimitConfig: {
213
+ maxLength: MAX_COMMENT_LENGTH,
214
+ indicatorStyle: { display: "none" }
215
+ }
216
+ },
217
+ children: /* @__PURE__ */ jsxs(
218
+ LazyEditor,
219
+ {
220
+ enableSaveAreaPlugin: false,
221
+ initialContent: initialContent || "",
222
+ onChange: ({ content: contentStr, isEmpty }) => {
223
+ const value = isEmpty ? "" : contentStr;
224
+ setContent(value);
225
+ onContentChange?.(value);
226
+ },
227
+ autoFocus: false,
228
+ placeholder: "Jot something down",
229
+ children: [
230
+ /* @__PURE__ */ jsx(AutoClearPlugin, { clearKey: lastSent }),
231
+ /* @__PURE__ */ jsx(ShortcutPlugin, { callback: handleSend }),
232
+ /* @__PURE__ */ jsx(DraggerPlugin, {}),
233
+ /* @__PURE__ */ jsx(FocusPlugin, { callback: FocusCallback }),
234
+ /* @__PURE__ */ jsx(BusyPlugin, { onChange: (busy) => setEditorBusy(busy) })
235
+ ]
236
+ }
237
+ )
238
+ }
239
+ )
240
+ ]
241
+ }
242
+ ),
243
+ /* @__PURE__ */ jsxs(
244
+ Box,
245
+ {
246
+ sx: {
247
+ display: "flex",
248
+ justifyContent: "space-between",
249
+ alignItems: "center",
250
+ position: "absolute",
251
+ left: 0,
252
+ right: 0,
253
+ bottom: 0,
254
+ height: 40,
255
+ p: 1,
256
+ ...compactView && { display: "none" }
257
+ },
258
+ children: [
259
+ /* @__PURE__ */ jsx(
260
+ Button,
261
+ {
262
+ size: "small",
263
+ color: "primary",
264
+ variant: "text",
265
+ onMouseDown: onToolbarBtnMouseDown,
266
+ startIcon: /* @__PURE__ */ jsx(Box, { component: LetterCaseIcon, sx: { fontSize: "14px !important" } }),
267
+ sx: {
268
+ width: 32,
269
+ height: 28,
270
+ minWidth: 0,
271
+ ".MuiButton-startIcon": { m: 0, color: "text.secondary" },
272
+ ...toolbarVisible && { bgcolor: "grey.200" }
273
+ }
274
+ }
275
+ ),
276
+ /* @__PURE__ */ jsx(
277
+ Button,
278
+ {
279
+ size: "small",
280
+ color: "primary",
281
+ variant: "contained",
282
+ disabled: !content || editorBusy,
283
+ onMouseDown: onSendBtnMouseDown,
284
+ startIcon: editorBusy ? /* @__PURE__ */ jsx(CircularProgress, { size: 12 }) : /* @__PURE__ */ jsx(Box, { component: SendIcon, sx: { fontSize: "14px !important" } }),
285
+ sx: { height: 28 },
286
+ children: t("chat.send")
287
+ }
288
+ )
289
+ ]
290
+ }
291
+ )
292
+ ]
293
+ }
294
+ );
295
+ }
@@ -1,6 +1,7 @@
1
+ /// <reference types="react" />
1
2
  import { SxProps } from '@mui/material';
2
3
  interface ChatProps {
3
4
  sx?: SxProps;
4
5
  }
5
- export default function ChatListInWallet({ sx, ...rest }: ChatProps): import("react/jsx-runtime").JSX.Element;
6
+ export default function ChatListInWallet({ sx, ...rest }: ChatProps): import("react").JSX.Element;
6
7
  export {};
@@ -0,0 +1,113 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Backdrop, Divider } from "@mui/material";
3
+ import Box from "@mui/material/Box";
4
+ import CircularProgress from "@mui/material/CircularProgress";
5
+ import ChatBubbleEmptyIcon from "virtual:icons/iconoir/chat-bubble-empty";
6
+ import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
7
+ import { useEffect } from "react";
8
+ import bridge from "@arcblock/bridge";
9
+ import ChatList from "./chat-list.mjs";
10
+ import { useChatContext } from "./context.mjs";
11
+ import { UserSearch } from "./user-search.mjs";
12
+ import { useChatInWallet } from "./hooks.mjs";
13
+ import { useUnreadNotification } from "./unread-notification.mjs";
14
+ import { useSessionContext } from "../hooks/index.mjs";
15
+ import { Avatar } from "../avatars/index.mjs";
16
+ import { openProfile } from "../utils.mjs";
17
+ function Empty({ sx }) {
18
+ const { t } = useLocaleContext();
19
+ const mergedSx = [
20
+ {
21
+ display: "flex",
22
+ flexDirection: "column",
23
+ justifyContent: "center",
24
+ alignItems: "center",
25
+ gap: 1,
26
+ color: "grey.600"
27
+ },
28
+ ...Array.isArray(sx) ? sx : [sx]
29
+ ];
30
+ return /* @__PURE__ */ jsxs(Box, { sx: mergedSx, children: [
31
+ /* @__PURE__ */ jsx(ChatBubbleEmptyIcon, { style: { fontSize: 32 } }),
32
+ /* @__PURE__ */ jsx(Box, { component: "span", sx: { fontSize: 14, fontWeight: 500 }, children: t("chat.noChats") })
33
+ ] });
34
+ }
35
+ export default function ChatListInWallet({ sx, ...rest }) {
36
+ const { session } = useSessionContext();
37
+ const { initialized, chats } = useChatContext();
38
+ const { unreadMessageCount } = useUnreadNotification();
39
+ const { updateUnreadState, isWebNavbar } = useChatInWallet();
40
+ useEffect(() => {
41
+ updateUnreadState({ unread: unreadMessageCount > 0, unreadMessageCount });
42
+ }, [unreadMessageCount, updateUnreadState]);
43
+ if (!initialized) {
44
+ return /* @__PURE__ */ jsx(Backdrop, { open: true, sx: { zIndex: (theme) => theme.zIndex.drawer + 1, bgcolor: "transparent" }, children: /* @__PURE__ */ jsx(CircularProgress, {}) });
45
+ }
46
+ const mergedSx = [
47
+ {
48
+ display: "flex",
49
+ height: "100%",
50
+ bgcolor: "background.default",
51
+ ...window.chatInWallet?.safeAreaInsetTop && {
52
+ pt: `${window.chatInWallet.safeAreaInsetTop}px`
53
+ }
54
+ },
55
+ ...Array.isArray(sx) ? sx : [sx]
56
+ ];
57
+ return /* @__PURE__ */ jsx(Box, { ...rest, sx: mergedSx, children: /* @__PURE__ */ jsxs(
58
+ Box,
59
+ {
60
+ sx: {
61
+ display: "flex",
62
+ flexDirection: "column",
63
+ width: { sm: 320, xs: "100%" },
64
+ borderRight: { sm: (theme) => `1px solid ${theme.palette.divider}` }
65
+ },
66
+ children: [
67
+ /* @__PURE__ */ jsxs(Box, { sx: { flex: "0 0 auto", py: 1, px: 2 }, children: [
68
+ isWebNavbar && /* @__PURE__ */ jsxs(
69
+ Box,
70
+ {
71
+ sx: {
72
+ display: "flex",
73
+ justifyContent: "space-between",
74
+ alignItems: "center",
75
+ mb: 1
76
+ },
77
+ children: [
78
+ /* @__PURE__ */ jsxs(
79
+ Box,
80
+ {
81
+ onClick: () => {
82
+ bridge.call("switchApp");
83
+ },
84
+ sx: { display: "flex", alignItems: "center", gap: 1 },
85
+ children: [
86
+ /* @__PURE__ */ jsx(Box, { component: "img", src: window.blocklet.appLogo, alt: "", sx: { width: 20, height: 20 } }),
87
+ /* @__PURE__ */ jsx(Box, { component: "span", sx: { typography: "h5", fontWeight: "bold" }, children: window.blocklet.appName })
88
+ ]
89
+ }
90
+ ),
91
+ /* @__PURE__ */ jsx(
92
+ Avatar,
93
+ {
94
+ did: session?.user?.did,
95
+ src: session?.user?.avatar,
96
+ size: 20,
97
+ shape: "circle",
98
+ variant: "circle",
99
+ onClick: () => openProfile(session?.user?.did, true)
100
+ }
101
+ )
102
+ ]
103
+ }
104
+ ),
105
+ /* @__PURE__ */ jsx(UserSearch, { inputSx: { fontSize: 16 } })
106
+ ] }),
107
+ /* @__PURE__ */ jsx(Divider, {}),
108
+ !!chats?.length && /* @__PURE__ */ jsx(ChatList, { sx: { flex: 1, overflowY: "auto" }, inWallet: true }),
109
+ !chats?.length && /* @__PURE__ */ jsx(Empty, { sx: { flex: 1 } })
110
+ ]
111
+ }
112
+ ) });
113
+ }
@@ -1,7 +1,8 @@
1
+ /// <reference types="react" />
1
2
  import { SxProps } from '@mui/material';
2
3
  interface Props {
3
4
  sx?: SxProps;
4
5
  inWallet?: boolean;
5
6
  }
6
- export default function ChatList({ inWallet, ...rest }: Props): import("react/jsx-runtime").JSX.Element;
7
+ export default function ChatList({ inWallet, ...rest }: Props): import("react").JSX.Element;
7
8
  export {};
@@ -0,0 +1,109 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import Box from "@mui/material/Box";
3
+ import { Badge } from "@mui/material";
4
+ import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
5
+ import { grey } from "@mui/material/colors";
6
+ import { useChatContext } from "./context.mjs";
7
+ import { AuthorInfo, SystemUser } from "../avatars/index.mjs";
8
+ import ChannelGroup from "./channel-group.mjs";
9
+ import { useChatInWallet } from "./hooks.mjs";
10
+ import { useUnreadNotification } from "./unread-notification.mjs";
11
+ export default function ChatList({ inWallet, ...rest }) {
12
+ const { t } = useLocaleContext();
13
+ const { orderedChats, activeChatId, setActiveChat, getOppositeUser, getLastMessageText } = useChatContext();
14
+ const { chatUnreadCounts } = useUnreadNotification();
15
+ const { navigateToChat } = useChatInWallet();
16
+ const renderItem = (chat) => {
17
+ if (chat.type === "notification") {
18
+ return /* @__PURE__ */ jsx(SystemUser, { name: t("chat.notification") });
19
+ }
20
+ const latestMessageText = getLastMessageText(chat);
21
+ const latestMessageTextContent = latestMessageText && /* @__PURE__ */ jsx(
22
+ Box,
23
+ {
24
+ className: "message-content-text",
25
+ sx: {
26
+ overflow: "hidden",
27
+ textOverflow: "ellipsis",
28
+ whiteSpace: "nowrap",
29
+ width: 220,
30
+ fontWeight: "regular",
31
+ fontSize: 14,
32
+ lineHeight: 1.5
33
+ },
34
+ children: latestMessageText
35
+ }
36
+ );
37
+ if (chat.type === "dm") {
38
+ const oppositeUser = getOppositeUser(chat);
39
+ return /* @__PURE__ */ jsx(AuthorInfo, { user: oppositeUser, showProfileCard: true, showBadge: false, showDID: false, linkToProfile: !inWallet, children: latestMessageTextContent });
40
+ }
41
+ if (chat.type === "channel") {
42
+ return /* @__PURE__ */ jsx(ChannelGroup, { chat, children: latestMessageTextContent });
43
+ }
44
+ return null;
45
+ };
46
+ return /* @__PURE__ */ jsx(Box, { ...rest, children: orderedChats.map((chat) => {
47
+ const isActiveChat = activeChatId === chat.id;
48
+ const unreadCount = chatUnreadCounts[chat.id];
49
+ return /* @__PURE__ */ jsxs(
50
+ Box,
51
+ {
52
+ sx: {
53
+ position: "relative",
54
+ m: 1,
55
+ mx: { xs: 0, sm: 1 },
56
+ py: 1.5,
57
+ px: 2,
58
+ fontWeight: "bold",
59
+ color: isActiveChat ? "secondary.main" : "grey.700",
60
+ bgcolor: isActiveChat ? "action.selected" : "",
61
+ borderRadius: 1,
62
+ cursor: "pointer",
63
+ ...isActiveChat && {
64
+ ".did-address-text": { color: `${grey[500]} !important` },
65
+ ".message-content-text": { color: `${grey[500]}` }
66
+ }
67
+ },
68
+ onClick: () => {
69
+ if (inWallet) {
70
+ const webTitleMap = {
71
+ dm: () => getOppositeUser(chat)?.fullName || t("chat.unknown"),
72
+ notification: () => t("chat.notification"),
73
+ channel: () => chat?.type === "channel" ? `# ${chat.name}` : t("chat.unknownChannel"),
74
+ default: () => t("chat.chats")
75
+ };
76
+ const getWebTitle = () => {
77
+ if (!chat) {
78
+ return t("chat.chats");
79
+ }
80
+ const getTitle = webTitleMap[chat.type] || webTitleMap.default;
81
+ return getTitle();
82
+ };
83
+ navigateToChat({ id: chat.id, title: getWebTitle() });
84
+ } else {
85
+ setActiveChat(chat);
86
+ }
87
+ },
88
+ children: [
89
+ renderItem(chat),
90
+ unreadCount > 0 && /* @__PURE__ */ jsx(
91
+ Badge,
92
+ {
93
+ badgeContent: unreadCount,
94
+ color: "primary",
95
+ sx: {
96
+ position: "absolute",
97
+ top: "50%",
98
+ right: { xs: 28, md: 16 },
99
+ transform: "translateY(-50%)"
100
+ },
101
+ children: /* @__PURE__ */ jsx(Box, { sx: { width: 1, height: 1 } })
102
+ }
103
+ )
104
+ ]
105
+ },
106
+ chat.id
107
+ );
108
+ }) });
109
+ }
@@ -1,7 +1,8 @@
1
- import { Chat } from './types';
1
+ /// <reference types="react" />
2
+ import type { Chat } from './types';
2
3
  interface ChatProps {
3
4
  chat: Chat;
4
5
  inWallet: boolean;
5
6
  }
6
- export default function ChatRoom({ chat, inWallet, ...rest }: ChatProps): import("react/jsx-runtime").JSX.Element;
7
+ export default function ChatRoom({ chat, inWallet, ...rest }: ChatProps): import("react").JSX.Element;
7
8
  export {};