@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,86 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { Suspense } from "react";
3
+ import { lazyRetry as lazy } from "@arcblock/ux/lib/Util";
4
+ import CheckboxPlugin from "@blocklet/editor/lib/ext/CheckboxPlugin";
5
+ import { styled } from "@mui/material/styles";
6
+ import Box from "@mui/material/Box";
7
+ import { inferInitialEditorState } from "../lexical.mjs";
8
+ import { ViewMore } from "../view-more.mjs";
9
+ import PostEdit from "../input/post-edit.mjs";
10
+ import ImagePathFixerPlugin from "../input/image-path-fixer-plugin.mjs";
11
+ import { VideoPathFixerPlugin } from "../editor/plugins/video-path-fixer-plugin.mjs";
12
+ const BlockletEditor = lazy(() => import("@blocklet/editor"));
13
+ const StyledBlockletEditor = styled(BlockletEditor)`
14
+ .editor-scroller {
15
+ min-height: initial;
16
+ }
17
+ .ContentEditable__root {
18
+ padding: 0;
19
+ }
20
+ .be-editable > p:last-child {
21
+ margin-bottom: 0;
22
+ }
23
+ `;
24
+ const innerHeight = parseInt(String(window.innerHeight / 3), 10);
25
+ export default function PostContent({
26
+ content,
27
+ editing = false,
28
+ onExitEditing,
29
+ onSubmit,
30
+ autoCollapse,
31
+ enableHeadingsIdPlugin,
32
+ onReady,
33
+ children,
34
+ editorPrepend,
35
+ ...rest
36
+ }) {
37
+ if (editing && onSubmit) {
38
+ return /* @__PURE__ */ jsx(
39
+ Box,
40
+ {
41
+ sx: {
42
+ ".be-editable": { maxHeight: 768, overflow: "auto", minHeight: `${Math.max(innerHeight, 200)}px !important` }
43
+ },
44
+ children: /* @__PURE__ */ jsx(PostEdit, { content, onCancel: onExitEditing, send: onSubmit, onSuccess: onExitEditing })
45
+ }
46
+ );
47
+ }
48
+ if (!autoCollapse) {
49
+ return /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsxs(
50
+ StyledBlockletEditor,
51
+ {
52
+ editable: false,
53
+ editorState: inferInitialEditorState(content),
54
+ enableHeadingsIdPlugin,
55
+ onReady,
56
+ prepend: /* @__PURE__ */ jsxs(Fragment, { children: [
57
+ /* @__PURE__ */ jsx(ImagePathFixerPlugin, {}),
58
+ /* @__PURE__ */ jsx(VideoPathFixerPlugin, {}),
59
+ editorPrepend
60
+ ] }),
61
+ children: [
62
+ /* @__PURE__ */ jsx(CheckboxPlugin, { send: onSubmit }),
63
+ children
64
+ ]
65
+ }
66
+ ) });
67
+ }
68
+ return /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(ViewMore, { ...rest, children: /* @__PURE__ */ jsxs(
69
+ StyledBlockletEditor,
70
+ {
71
+ editable: false,
72
+ editorState: inferInitialEditorState(content),
73
+ enableHeadingsIdPlugin,
74
+ onReady,
75
+ prepend: /* @__PURE__ */ jsxs(Fragment, { children: [
76
+ editorPrepend,
77
+ /* @__PURE__ */ jsx(ImagePathFixerPlugin, {}),
78
+ /* @__PURE__ */ jsx(VideoPathFixerPlugin, {})
79
+ ] }),
80
+ children: [
81
+ /* @__PURE__ */ jsx(CheckboxPlugin, { send: onSubmit }),
82
+ children
83
+ ]
84
+ }
85
+ ) }) });
86
+ }
@@ -1,6 +1,6 @@
1
- import { default as React } from 'react';
2
- import { default as MuiMenuItem } from '@mui/material/MenuItem';
3
- import { Post } from '../../types';
1
+ import React from 'react';
2
+ import MuiMenuItem from '@mui/material/MenuItem';
3
+ import type { Post } from '../../types';
4
4
  export interface PostProps {
5
5
  post: Post;
6
6
  interactive?: boolean;
@@ -22,5 +22,5 @@ interface PostContext {
22
22
  interactive: boolean;
23
23
  post: Post;
24
24
  }
25
- export default function PostComponent({ post, render, renderExtraContent, customMenu, interactive, onContentUpdate, allowCopyLink, autoCollapse, showProfileCard, resolveAuthorInfoAppend, editorPlugins, enableAutoTranslate, ...rest }: PostProps): import("react/jsx-runtime").JSX.Element;
25
+ export default function PostComponent({ post, render, renderExtraContent, customMenu, interactive, onContentUpdate, allowCopyLink, autoCollapse, showProfileCard, resolveAuthorInfoAppend, editorPlugins, enableAutoTranslate, ...rest }: PostProps): JSX.Element;
26
26
  export {};
@@ -0,0 +1,198 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { useEffect, useState } from "react";
3
+ import Box from "@mui/material/Box";
4
+ import { styled } from "@mui/material/styles";
5
+ import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
6
+ import MuiMenuItem from "@mui/material/MenuItem";
7
+ import clsx from "clsx";
8
+ import { useInViewport } from "ahooks";
9
+ import ArrowForwardUpIcon from "virtual:icons/tabler/arrow-forward-up";
10
+ import { Stack } from "@mui/material";
11
+ import RelativeTime from "../shared/relative-time.mjs";
12
+ import { AuthorInfo } from "../avatars/index.mjs";
13
+ import PostContent from "./post-content.mjs";
14
+ import { useSessionContext } from "../hooks/index.mjs";
15
+ import { copy } from "../utils.mjs";
16
+ import Menu from "./menu.mjs";
17
+ import { ProfileCardTooltip } from "../profile-card/profile-card.mjs";
18
+ import { PostAutoTranslatePlugin } from "../auto-translate/post-auto-translate-plugin.mjs";
19
+ const Root = styled(Box)`
20
+ .post-highlighted {
21
+ animation: highlighted-post-fade 3s;
22
+ animation-timing-function: ease-out;
23
+ }
24
+ @-webkit-keyframes highlighted-post-fade {
25
+ 0% {
26
+ background-color: #fcf4d9;
27
+ }
28
+ 100% {
29
+ background-color: rgba(255, 255, 153, 0);
30
+ }
31
+ }
32
+ @-moz-keyframes highlighted-post-fade {
33
+ 0% {
34
+ background-color: #fcf4d9;
35
+ }
36
+ 100% {
37
+ background-color: rgba(255, 255, 153, 0);
38
+ }
39
+ }
40
+ `;
41
+ export default function PostComponent({
42
+ post,
43
+ render,
44
+ renderExtraContent,
45
+ customMenu,
46
+ interactive = true,
47
+ onContentUpdate,
48
+ allowCopyLink = false,
49
+ autoCollapse,
50
+ showProfileCard,
51
+ resolveAuthorInfoAppend = () => void 0,
52
+ editorPlugins,
53
+ enableAutoTranslate,
54
+ ...rest
55
+ }) {
56
+ const { session, isAdmin } = useSessionContext();
57
+ const isAuthor = post.author.did === session?.user?.did;
58
+ const commentUrl = window.location.hash.substring(1);
59
+ const { t } = useLocaleContext();
60
+ const [editing, setEditing] = useState(false);
61
+ const postContext = { isAdmin, isAuthor, interactive, post };
62
+ const [inViewport] = useInViewport(() => document?.getElementById(post.id));
63
+ const [hasEnteredViewport, setHasEnteredViewport] = useState(false);
64
+ let menuItems = [];
65
+ if (isAuthor && !post.deletedAt) {
66
+ menuItems.push(
67
+ /* @__PURE__ */ jsx(MuiMenuItem, { onClick: () => setEditing(true), children: t("edit") }, "edit")
68
+ );
69
+ }
70
+ if (allowCopyLink) {
71
+ menuItems.push(
72
+ /* @__PURE__ */ jsx(
73
+ MuiMenuItem,
74
+ {
75
+ onClick: () => copy(
76
+ window.location.hash ? window.location.href.replace(window.location.hash, `#${post.id}`) : `${window.location.href}#${post.id}`
77
+ ),
78
+ children: t("copyLink")
79
+ },
80
+ "copyLink"
81
+ )
82
+ );
83
+ }
84
+ const isTargetPost = commentUrl === post.id;
85
+ menuItems = customMenu ? customMenu(menuItems, postContext) : menuItems;
86
+ const renderTime = () => {
87
+ if (allowCopyLink) {
88
+ return /* @__PURE__ */ jsx(Box, { component: "a", href: `#${post.id}`, sx: { color: "text.secondary", textDecoration: "none" }, children: /* @__PURE__ */ jsx(RelativeTime, { value: post.createdAt }) });
89
+ }
90
+ return /* @__PURE__ */ jsx(RelativeTime, { value: post.createdAt });
91
+ };
92
+ let systemTip = "";
93
+ if (post.deletedAt) {
94
+ systemTip = t("deleted");
95
+ } else if (!post.content) {
96
+ systemTip = t("emptyContent");
97
+ }
98
+ const showSystemTip = systemTip && !editing;
99
+ useEffect(() => {
100
+ if (inViewport) {
101
+ setHasEnteredViewport(inViewport);
102
+ }
103
+ }, [inViewport]);
104
+ return /* @__PURE__ */ jsxs(Root, { sx: { position: "relative", mt: 2, py: 1 }, ...rest, children: [
105
+ /* @__PURE__ */ jsxs(
106
+ Box,
107
+ {
108
+ id: post.id,
109
+ className: clsx({ "post-highlighted": isTargetPost && hasEnteredViewport }),
110
+ sx: {
111
+ flex: "1"
112
+ },
113
+ children: [
114
+ /* @__PURE__ */ jsxs(
115
+ Box,
116
+ {
117
+ sx: {
118
+ display: "flex",
119
+ justifyContent: "space-between",
120
+ alignItems: "start"
121
+ },
122
+ children: [
123
+ /* @__PURE__ */ jsx(
124
+ AuthorInfo,
125
+ {
126
+ size: "sm",
127
+ fontSize: 14,
128
+ avatarSize: 32,
129
+ user: post.author,
130
+ createdAt: renderTime(),
131
+ showProfileCard,
132
+ append: resolveAuthorInfoAppend(post),
133
+ showDID: false
134
+ }
135
+ ),
136
+ /* @__PURE__ */ jsx(Menu, { items: menuItems, style: { position: "absolute", right: 0, top: 0 } })
137
+ ]
138
+ }
139
+ ),
140
+ /* @__PURE__ */ jsxs(Box, { sx: { ml: { xs: 0, md: 5.5 } }, children: [
141
+ post.replyTo && /* @__PURE__ */ jsx(Box, { sx: { pt: 1 }, children: /* @__PURE__ */ jsx(ProfileCardTooltip, { user: post.replyTo, children: /* @__PURE__ */ jsxs(
142
+ Stack,
143
+ {
144
+ direction: "row",
145
+ sx: {
146
+ alignItems: "center",
147
+ gap: 0.5,
148
+ display: "inline-flex",
149
+ color: "text.secondary",
150
+ cursor: "pointer",
151
+ ".did-address-text": { color: "primary.light" }
152
+ },
153
+ children: [
154
+ /* @__PURE__ */ jsx(Box, { component: ArrowForwardUpIcon }),
155
+ /* @__PURE__ */ jsx("span", { children: "Reply to" }),
156
+ /* @__PURE__ */ jsx(Box, { component: "span", children: post.replyTo.fullName })
157
+ ]
158
+ }
159
+ ) }) }),
160
+ showSystemTip && /* @__PURE__ */ jsx(
161
+ Box,
162
+ {
163
+ sx: {
164
+ display: "inline-block",
165
+ px: 2.5,
166
+ py: 1,
167
+ my: 1,
168
+ fontSize: 14,
169
+ bgcolor: "grey.100",
170
+ color: "grey.600",
171
+ borderRadius: 1
172
+ },
173
+ children: systemTip
174
+ }
175
+ ),
176
+ !showSystemTip && !post.deletedAt && /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
177
+ PostContent,
178
+ {
179
+ content: post.content,
180
+ editing,
181
+ onExitEditing: () => setEditing(false),
182
+ onSubmit: (content) => onContentUpdate(post, content),
183
+ autoCollapse,
184
+ editorPrepend: /* @__PURE__ */ jsxs(Fragment, { children: [
185
+ editorPlugins,
186
+ enableAutoTranslate && /* @__PURE__ */ jsx(PostAutoTranslatePlugin, { postId: post.id, updatedAt: post.updatedAt || "" })
187
+ ] })
188
+ },
189
+ editing ? "comment-content" : post.synced || 0
190
+ ) }),
191
+ render && /* @__PURE__ */ jsx(Box, { sx: { mt: 1 }, children: render(postContext) })
192
+ ] })
193
+ ]
194
+ }
195
+ ),
196
+ renderExtraContent && renderExtraContent(postContext)
197
+ ] });
198
+ }
@@ -0,0 +1 @@
1
+ export * from "./profile-card.mjs";
@@ -1,14 +1,15 @@
1
- import { User } from '../../types';
1
+ /// <reference types="react" />
2
+ import type { User } from '../../types';
2
3
  interface ProfileCardProps {
3
4
  user: User;
4
5
  click: () => void;
5
6
  }
6
- export declare function ProfileCard({ user, click, ...rest }: ProfileCardProps): import("react/jsx-runtime").JSX.Element;
7
+ export declare function ProfileCard({ user, click, ...rest }: ProfileCardProps): import("react").JSX.Element;
7
8
  interface ProfileCardTooltipProps {
8
9
  user: User;
9
10
  children: React.ReactElement<any> | ((props: {
10
11
  navigateToProfile: () => void;
11
12
  }) => React.ReactElement<any>);
12
13
  }
13
- export declare function ProfileCardTooltip({ user, children }: ProfileCardTooltipProps): import("react/jsx-runtime").JSX.Element;
14
+ export declare function ProfileCardTooltip({ user, children }: ProfileCardTooltipProps): import("react").JSX.Element;
14
15
  export {};
@@ -0,0 +1,162 @@
1
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
+ import { Link, useNavigate } from "react-router-dom";
3
+ import { Box, Button, styled } from "@mui/material";
4
+ import Tooltip, { tooltipClasses } from "@mui/material/Tooltip";
5
+ import DID from "@arcblock/ux/lib/DID";
6
+ import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
7
+ import { green } from "@mui/material/colors";
8
+ import { ChatBubbleOutlineOutlined as ChatBubbleOutlineOutlinedIcon } from "@mui/icons-material";
9
+ import { useBrowser } from "@arcblock/react-hooks";
10
+ import { useState } from "react";
11
+ import Avatar from "../avatars/avatar.mjs";
12
+ import { useSessionContext } from "../hooks/index.mjs";
13
+ import Badge from "../avatars/badge.mjs";
14
+ import { useChatInWallet } from "../chat/hooks.mjs";
15
+ import { openProfile, isInDiscussKitApp } from "../utils.mjs";
16
+ export function ProfileCard({ user, click, ...rest }) {
17
+ const { session } = useSessionContext();
18
+ const { t } = useLocaleContext();
19
+ let chatUrl = user?.did && `/chat/dm/${user?.did}`;
20
+ if (chatUrl && window.location.pathname?.includes(user?.did)) {
21
+ chatUrl = "";
22
+ }
23
+ return /* @__PURE__ */ jsxs(
24
+ Box,
25
+ {
26
+ sx: {
27
+ boxSizing: "border-box",
28
+ width: 340,
29
+ p: 2,
30
+ border: "1px solid",
31
+ borderColor: "divider",
32
+ borderRadius: 1,
33
+ fontSize: 14,
34
+ color: "grey.700",
35
+ bgcolor: "background.paper"
36
+ },
37
+ ...rest,
38
+ children: [
39
+ /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 2, cursor: "pointer" }, onClick: click, children: [
40
+ /* @__PURE__ */ jsx(Avatar, { did: user.did, src: user.avatar, size: 44, shape: "circle", variant: "circle" }),
41
+ /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column", flex: 1, overflow: "hidden" }, children: [
42
+ /* @__PURE__ */ jsxs(
43
+ Box,
44
+ {
45
+ component: "span",
46
+ sx: {
47
+ display: "flex",
48
+ justifyContent: "space-between",
49
+ alignItems: "center",
50
+ lineHeight: 1.3
51
+ },
52
+ children: [
53
+ /* @__PURE__ */ jsx(Box, { sx: { fontWeight: "bold" }, children: user.fullName }),
54
+ user.role && /* @__PURE__ */ jsx(
55
+ Box,
56
+ {
57
+ sx: {
58
+ px: 1.25,
59
+ border: 1,
60
+ borderColor: green[600],
61
+ color: green[600],
62
+ fontSize: 12,
63
+ fontWeight: "bold",
64
+ lineHeight: 1.5,
65
+ borderRadius: "100vh",
66
+ textTransform: "capitalize"
67
+ },
68
+ children: user.role
69
+ }
70
+ )
71
+ ]
72
+ }
73
+ ),
74
+ /* @__PURE__ */ jsx(
75
+ DID,
76
+ {
77
+ style: { marginTop: 4, lineHeight: 1, height: 14, maxWidth: 250, color: "inherit !important" },
78
+ size: 14,
79
+ did: user.did
80
+ }
81
+ ),
82
+ /* @__PURE__ */ jsx(Box, { sx: { mt: 1 }, children: /* @__PURE__ */ jsx(Badge, { passports: user?.passports || [], pointInfo: user?.pointInfo || {}, did: user?.did }) })
83
+ ] })
84
+ ] }),
85
+ chatUrl && user?.did !== window.blocklet.appId && session?.user?.did && session?.user?.did !== user.did && /* @__PURE__ */ jsxs(Fragment, { children: [
86
+ /* @__PURE__ */ jsx(Box, { sx: { my: 2, borderTop: "1px solid", borderColor: "divider" } }),
87
+ /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
88
+ Button,
89
+ {
90
+ component: Link,
91
+ to: chatUrl,
92
+ variant: "outlined",
93
+ color: "inherit",
94
+ startIcon: /* @__PURE__ */ jsx(ChatBubbleOutlineOutlinedIcon, { style: { fontSize: 16 } }),
95
+ sx: { fontSize: 12 },
96
+ children: t("messages")
97
+ }
98
+ ) })
99
+ ] })
100
+ ]
101
+ }
102
+ );
103
+ }
104
+ const HtmlTooltip = styled(({ className, ...props }) => /* @__PURE__ */ jsx(
105
+ Tooltip,
106
+ {
107
+ ...props,
108
+ classes: { popper: className },
109
+ slotProps: {
110
+ popper: {
111
+ disablePortal: true
112
+ }
113
+ }
114
+ }
115
+ ))(() => ({
116
+ [`& .${tooltipClasses.tooltip}`]: {
117
+ backgroundColor: "transparent",
118
+ maxWidth: "initial"
119
+ }
120
+ }));
121
+ export function ProfileCardTooltip({ user, children }) {
122
+ const navigate = useNavigate();
123
+ const [open, setOpen] = useState(false);
124
+ const { mobile } = useBrowser();
125
+ const { chatInWallet } = useChatInWallet();
126
+ const click = (e) => {
127
+ e?.stopPropagation?.();
128
+ e?.preventDefault?.();
129
+ setOpen(false);
130
+ if (chatInWallet) {
131
+ openProfile(user?.did, true);
132
+ } else {
133
+ setTimeout(() => {
134
+ if (isInDiscussKitApp) {
135
+ navigate(`/profile?did=${user?.did}`);
136
+ } else {
137
+ openProfile(user?.did);
138
+ }
139
+ }, 100);
140
+ }
141
+ };
142
+ const renderChildren = () => {
143
+ if (typeof children === "function") {
144
+ return children({ navigateToProfile: click });
145
+ }
146
+ return children;
147
+ };
148
+ if (mobile.any) {
149
+ return renderChildren();
150
+ }
151
+ return /* @__PURE__ */ jsx(
152
+ HtmlTooltip,
153
+ {
154
+ open,
155
+ onClose: () => setOpen(false),
156
+ onOpen: () => setOpen(true),
157
+ PopperProps: { disablePortal: false },
158
+ title: /* @__PURE__ */ jsx(ProfileCard, { user, click }),
159
+ children: renderChildren()
160
+ }
161
+ );
162
+ }
@@ -1,8 +1,9 @@
1
- import { RatingProps } from './rating';
2
- import { Rating as RatingType } from '../../types';
1
+ /// <reference types="react" />
2
+ import { type RatingProps } from './rating';
3
+ import type { Rating as RatingType } from '../../types';
3
4
  export type BinaryThumbProps = {
4
5
  data: RatingType[];
5
6
  variant?: 'default' | 'inverse';
6
7
  size?: 'sm' | 'lg';
7
8
  } & Pick<RatingProps, 'onRate' | 'onUnrate'>;
8
- export default function BinaryThumb({ data, variant, size, ...rest }: BinaryThumbProps): import("react/jsx-runtime").JSX.Element;
9
+ export default function BinaryThumb({ data, variant, size, ...rest }: BinaryThumbProps): import("react").JSX.Element;
@@ -0,0 +1,157 @@
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useMemo, useState } from "react";
3
+ import { styled } from "@arcblock/ux/lib/Theme";
4
+ import Box from "@mui/material/Box";
5
+ import clsx from "clsx";
6
+ import ThumbUpIcon from "virtual:icons/iconoir/thumbs-up";
7
+ import RaterList from "./rater-list.mjs";
8
+ import Rating from "./rating.mjs";
9
+ import { useSessionContext } from "../hooks/index.mjs";
10
+ const values = ["1", "-1"];
11
+ export default function BinaryThumb({ data = [], variant = "default", size = "sm", ...rest }) {
12
+ const { session } = useSessionContext();
13
+ const [raterListVisible, setRaterListVisible] = useState(null);
14
+ const [loading, setLoading] = useState(false);
15
+ const countPerValue = useMemo(() => {
16
+ return data.reduce((acc, cur) => {
17
+ acc[cur.value] = (acc[cur.value] || 0) + 1;
18
+ return acc;
19
+ }, {});
20
+ }, [data]);
21
+ const selectedValue = useMemo(() => {
22
+ return data.find((x) => x.rater?.did === session?.user?.did)?.value;
23
+ }, [data, session.user]);
24
+ const render = ({ options, toggleRate }) => {
25
+ const handleTextClick = (event, value) => {
26
+ setRaterListVisible(value);
27
+ };
28
+ const clickRateHandle = async (option) => {
29
+ if (loading) {
30
+ return;
31
+ }
32
+ setLoading(true);
33
+ await toggleRate(option.value);
34
+ setLoading(false);
35
+ };
36
+ return /* @__PURE__ */ jsx(Root, { children: options.map((option) => {
37
+ const icon = option.value === "-1" ? /* @__PURE__ */ jsx(ThumbUpIcon, { style: { transform: "rotate(180deg)" } }) : /* @__PURE__ */ jsx(ThumbUpIcon, {});
38
+ return /* @__PURE__ */ jsxs("div", { className: "reaction-item", children: [
39
+ /* @__PURE__ */ jsx(
40
+ IconButton,
41
+ {
42
+ className: "reaction-item-btn",
43
+ icon,
44
+ text: option.count,
45
+ selected: option.selected,
46
+ onClick: () => clickRateHandle(option),
47
+ variant,
48
+ size,
49
+ onTextClick: (e) => handleTextClick(e, option.value),
50
+ disabled: loading
51
+ }
52
+ ),
53
+ /* @__PURE__ */ jsx(
54
+ RaterList,
55
+ {
56
+ open: raterListVisible === option.value,
57
+ onClose: () => setRaterListVisible(null),
58
+ value: raterListVisible,
59
+ ratings: data
60
+ }
61
+ )
62
+ ] }, option.value);
63
+ }) });
64
+ };
65
+ return /* @__PURE__ */ jsx(
66
+ Rating,
67
+ {
68
+ ...rest,
69
+ ratingType: "binary-thumb",
70
+ values,
71
+ countPerValue,
72
+ selectedValue,
73
+ render
74
+ }
75
+ );
76
+ }
77
+ const Root = styled(Box)`
78
+ display: flex;
79
+ .reaction-item {
80
+ display: flex;
81
+ align-items: center;
82
+ }
83
+ `;
84
+ function IconButton({ icon, text, onClick, selected, variant, size, onTextClick, disabled, ...rest }) {
85
+ const classes = clsx(rest.className, `reaction-btn-${size} reaction-btn-${variant}`, {
86
+ "reaction-btn-selected": selected,
87
+ "button-disabled": disabled
88
+ });
89
+ return /* @__PURE__ */ jsxs(IconButtonRoot, { ...rest, className: classes, children: [
90
+ /* @__PURE__ */ jsx("span", { className: "reaction-btn-icon", onClick, children: icon }),
91
+ !!text && /* @__PURE__ */ jsx("span", { className: "reaction-btn-text", onClick: (e) => onTextClick?.(e), children: text })
92
+ ] });
93
+ }
94
+ const IconButtonRoot = styled("div")`
95
+ display: flex;
96
+ align-items: center;
97
+ &.reaction-btn-selected {
98
+ color: ${(props) => props.theme.palette.primary.main};
99
+ }
100
+ .reaction-btn-icon {
101
+ display: flex;
102
+ line-height: 1;
103
+ cursor: pointer;
104
+ }
105
+ &.button-disabled {
106
+ opacity: 0.5;
107
+ .reaction-btn-icon {
108
+ cursor: not-allowed;
109
+ }
110
+ }
111
+ svg {
112
+ width: auto;
113
+ }
114
+ .reaction-btn-text {
115
+ display: inline-block;
116
+ cursor: pointer;
117
+ }
118
+ &.reaction-btn-sm {
119
+ min-width: 64px;
120
+ height: 18px;
121
+ font-size: 12px;
122
+ svg {
123
+ font-size: 15px;
124
+ }
125
+ .reaction-btn-text {
126
+ margin-left: 8px;
127
+ }
128
+ }
129
+ &.reaction-btn-lg {
130
+ min-width: 100px;
131
+ font-size: 14px;
132
+ .reaction-btn-icon {
133
+ justify-content: center;
134
+ align-items: center;
135
+ width: 44px;
136
+ height: 44px;
137
+ border-radius: 8px;
138
+ }
139
+ svg {
140
+ height: 20px;
141
+ }
142
+ .reaction-btn-text {
143
+ margin-left: 12px;
144
+ }
145
+ }
146
+ &.reaction-btn-inverse {
147
+ .reaction-btn-icon {
148
+ background-color: ${(props) => props.theme.palette.grey[200]};
149
+ }
150
+ &.reaction-btn-selected {
151
+ .reaction-btn-icon {
152
+ color: #fff;
153
+ background-color: ${(props) => props.theme.palette.primary.main};
154
+ }
155
+ }
156
+ }
157
+ `;
@@ -1,8 +1,9 @@
1
+ /// <reference types="react" />
1
2
  import { AxiosInstance } from 'axios';
2
3
  import { GithubReactionProps } from './github-reaction';
3
4
  interface Props extends Omit<GithubReactionProps, 'data' | 'onRate' | 'onUnrate'> {
4
5
  id: string;
5
6
  request: AxiosInstance;
6
7
  }
7
- export declare function GithubReactionContainer({ id, request, ...rest }: Props): import("react/jsx-runtime").JSX.Element | null;
8
+ export declare function GithubReactionContainer({ id, request, ...rest }: Props): import("react").JSX.Element | null;
8
9
  export {};