@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.
- package/dist/axios.d.ts +8 -0
- package/dist/blocklets.d.ts +1 -1
- package/dist/blocklets.mjs +17 -0
- package/dist/components/api-error-handler/api-error-handler.d.ts +1 -1
- package/dist/components/api-error-handler/api-error-handler.mjs +25 -0
- package/dist/components/api-error-handler/default-handler.mjs +69 -0
- package/dist/components/api-error-handler/index.mjs +2 -0
- package/dist/components/api-error-handler/json-validation-interceptor.d.ts +1 -1
- package/dist/components/api-error-handler/json-validation-interceptor.mjs +9 -0
- package/dist/components/arcsphere/index.mjs +51 -0
- package/dist/components/authz/access-control.d.ts +15 -1
- package/dist/components/authz/access-control.mjs +15 -0
- package/dist/components/authz/context.d.ts +2 -1
- package/dist/components/authz/context.mjs +30 -0
- package/dist/components/authz/index.d.ts +1 -1
- package/dist/components/authz/index.mjs +2 -0
- package/dist/components/auto-translate/api.d.ts +1 -1
- package/dist/components/auto-translate/api.mjs +23 -0
- package/dist/components/auto-translate/auto-translate-button.d.ts +2 -1
- package/dist/components/auto-translate/auto-translate-button.mjs +47 -0
- package/dist/components/auto-translate/editor-store-adaptor.mjs +14 -0
- package/dist/components/auto-translate/index.mjs +6 -0
- package/dist/components/auto-translate/languages.mjs +61 -0
- package/dist/components/auto-translate/post-auto-translate-plugin.d.ts +4 -3
- package/dist/components/auto-translate/post-auto-translate-plugin.mjs +32 -0
- package/dist/components/auto-translate/store.d.ts +3 -3
- package/dist/components/auto-translate/store.mjs +23 -0
- package/dist/components/auto-translate/translate.d.ts +3 -2
- package/dist/components/auto-translate/translate.mjs +103 -0
- package/dist/components/auto-translate/utils.d.ts +1 -1
- package/dist/components/auto-translate/utils.mjs +14 -0
- package/dist/components/auto-translate/with-availibility-check.d.ts +1 -1
- package/dist/components/auto-translate/with-availibility-check.mjs +10 -0
- package/dist/components/avatars/author-info.d.ts +3 -2
- package/dist/components/avatars/author-info.mjs +184 -0
- package/dist/components/avatars/avatar.d.ts +2 -1
- package/dist/components/avatars/avatar.mjs +9 -0
- package/dist/components/avatars/avatars.d.ts +4 -3
- package/dist/components/avatars/avatars.mjs +49 -0
- package/dist/components/avatars/badge.d.ts +2 -1
- package/dist/components/avatars/badge.mjs +178 -0
- package/dist/components/avatars/index.mjs +5 -0
- package/dist/components/avatars/system-user.d.ts +1 -1
- package/dist/components/avatars/system-user.mjs +58 -0
- package/dist/components/back.d.ts +2 -1
- package/dist/components/back.mjs +28 -0
- package/dist/components/blog/blog-link.mjs +16 -0
- package/dist/components/blog/blog-list.d.ts +4 -3
- package/dist/components/blog/blog-list.mjs +441 -0
- package/dist/components/blog/cover-image.d.ts +4 -3
- package/dist/components/blog/cover-image.mjs +160 -0
- package/dist/components/blog/index.mjs +4 -0
- package/dist/components/blog/permalink.d.ts +3 -2
- package/dist/components/blog/permalink.mjs +78 -0
- package/dist/components/blog/types.d.ts +1 -1
- package/dist/components/blog/types.mjs +0 -0
- package/dist/components/button-group/button-group.d.ts +2 -1
- package/dist/components/button-group/button-group.mjs +195 -0
- package/dist/components/button-group/index.mjs +1 -0
- package/dist/components/chat/channel-group.d.ts +3 -2
- package/dist/components/chat/channel-group.mjs +41 -0
- package/dist/components/chat/chat-client.d.ts +2 -2
- package/dist/components/chat/chat-client.mjs +33 -0
- package/dist/components/chat/chat-header-addon.d.ts +2 -1
- package/dist/components/chat/chat-header-addon.mjs +26 -0
- package/dist/components/chat/chat-in-wallet.d.ts +2 -1
- package/dist/components/chat/chat-in-wallet.mjs +67 -0
- package/dist/components/chat/chat-input.d.ts +3 -2
- package/dist/components/chat/chat-input.mjs +295 -0
- package/dist/components/chat/chat-list-in-wallet.d.ts +2 -1
- package/dist/components/chat/chat-list-in-wallet.mjs +113 -0
- package/dist/components/chat/chat-list.d.ts +2 -1
- package/dist/components/chat/chat-list.mjs +109 -0
- package/dist/components/chat/chat-room.d.ts +3 -2
- package/dist/components/chat/chat-room.mjs +225 -0
- package/dist/components/chat/chat.d.ts +2 -1
- package/dist/components/chat/chat.mjs +163 -0
- package/dist/components/chat/context.d.ts +4 -3
- package/dist/components/chat/context.mjs +303 -0
- package/dist/components/chat/hooks.d.ts +1 -1
- package/dist/components/chat/hooks.mjs +59 -0
- package/dist/components/chat/index.mjs +7 -0
- package/dist/components/chat/message-list.d.ts +3 -2
- package/dist/components/chat/message-list.mjs +151 -0
- package/dist/components/chat/message.d.ts +4 -3
- package/dist/components/chat/message.mjs +312 -0
- package/dist/components/chat/participants.d.ts +3 -2
- package/dist/components/chat/participants.mjs +60 -0
- package/dist/components/chat/time.d.ts +1 -1
- package/dist/components/chat/time.mjs +16 -0
- package/dist/components/chat/types.d.ts +1 -1
- package/dist/components/chat/types.mjs +0 -0
- package/dist/components/chat/unread-notification.d.ts +2 -2
- package/dist/components/chat/unread-notification.mjs +43 -0
- package/dist/components/chat/user-search.d.ts +2 -1
- package/dist/components/chat/user-search.mjs +143 -0
- package/dist/components/check-mark.d.ts +2 -1
- package/dist/components/check-mark.mjs +98 -0
- package/dist/components/confirm.d.ts +4 -4
- package/dist/components/confirm.mjs +103 -0
- package/dist/components/dayjs.d.ts +1 -1
- package/dist/components/dayjs.mjs +4 -0
- package/dist/components/default-editor-config-provider.d.ts +3 -2
- package/dist/components/default-editor-config-provider.mjs +107 -0
- package/dist/components/dirty-prompt.d.ts +3 -2
- package/dist/components/dirty-prompt.mjs +117 -0
- package/dist/components/editor/editor.d.ts +4 -3
- package/dist/{editor-B3z0rXVh.mjs → components/editor/editor.mjs} +7 -8
- package/dist/components/editor/index.mjs +2 -0
- package/dist/components/editor/lazy-editor.d.ts +3 -2
- package/dist/components/editor/lazy-editor.mjs +14 -0
- package/dist/components/editor/plugins/video-path-fixer-plugin.mjs +29 -0
- package/dist/components/editor/preview.d.ts +4 -3
- package/dist/components/editor/preview.mjs +32 -0
- package/dist/components/emoji-icon.d.ts +2 -1
- package/dist/components/emoji-icon.mjs +62 -0
- package/dist/components/empty-status/empty-status.d.ts +2 -1
- package/dist/components/empty-status/empty-status.mjs +24 -0
- package/dist/components/empty-status/index.mjs +1 -0
- package/dist/components/hooks/changed.mjs +34 -0
- package/dist/components/hooks/index.mjs +6 -0
- package/dist/components/hooks/interval.mjs +16 -0
- package/dist/components/hooks/locale-context.mjs +12 -0
- package/dist/components/hooks/measure.mjs +8 -0
- package/dist/components/hooks/now.mjs +10 -0
- package/dist/components/hooks/responsive.d.ts +1 -1
- package/dist/components/hooks/responsive.mjs +25 -0
- package/dist/components/hooks/session.d.ts +1 -0
- package/dist/components/hooks/session.mjs +41 -0
- package/dist/components/hooks/use-event-callback.mjs +14 -0
- package/dist/components/icon-button.d.ts +4 -3
- package/dist/components/icon-button.mjs +37 -0
- package/dist/components/input/auto-clear-plugin.mjs +26 -0
- package/dist/components/input/comment-input.d.ts +2 -1
- package/dist/components/input/comment-input.mjs +107 -0
- package/dist/components/input/image-path-fixer-plugin.mjs +29 -0
- package/dist/components/input/index.mjs +4 -0
- package/dist/components/input/input.d.ts +4 -4
- package/dist/components/input/input.mjs +152 -0
- package/dist/components/input/post-edit.d.ts +2 -1
- package/dist/components/input/post-edit.mjs +49 -0
- package/dist/components/input/scrollable-editor-wrapper.d.ts +2 -1
- package/dist/components/input/scrollable-editor-wrapper.mjs +18 -0
- package/dist/components/input/shortcut-plugin.mjs +28 -0
- package/dist/components/label-picker.d.ts +2 -1
- package/dist/components/label-picker.mjs +41 -0
- package/dist/components/lexical.mjs +69 -0
- package/dist/components/locale/en.mjs +92 -0
- package/dist/components/locale/index.mjs +3 -0
- package/dist/components/locale/zh.mjs +94 -0
- package/dist/components/pagination.d.ts +3 -2
- package/dist/components/pagination.mjs +44 -0
- package/dist/components/paywall.d.ts +2 -2
- package/dist/components/paywall.mjs +110 -0
- package/dist/components/point-up/{box-animation.json.d.ts → box-animation.json} +1 -4
- package/dist/components/point-up/index.d.ts +3 -2
- package/dist/components/point-up/index.mjs +153 -0
- package/dist/components/point-up/lottie-component.d.ts +2 -1
- package/dist/components/point-up/lottie-component.mjs +7 -0
- package/dist/components/posts/comment-list/comment-list.d.ts +2 -1
- package/dist/components/posts/comment-list/comment-list.mjs +163 -0
- package/dist/components/posts/comment-list/context.d.ts +4 -4
- package/dist/components/posts/comment-list/context.mjs +318 -0
- package/dist/components/posts/comment.d.ts +3 -2
- package/dist/components/posts/comment.mjs +184 -0
- package/dist/components/posts/index.mjs +6 -0
- package/dist/components/posts/menu.d.ts +3 -2
- package/dist/components/posts/menu.mjs +83 -0
- package/dist/components/posts/post-content.d.ts +2 -1
- package/dist/components/posts/post-content.mjs +86 -0
- package/dist/components/posts/post.d.ts +4 -4
- package/dist/components/posts/post.mjs +198 -0
- package/dist/components/profile-card/index.mjs +1 -0
- package/dist/components/profile-card/profile-card.d.ts +4 -3
- package/dist/components/profile-card/profile-card.mjs +162 -0
- package/dist/components/rating/binary-thumb.d.ts +4 -3
- package/dist/components/rating/binary-thumb.mjs +157 -0
- package/dist/components/rating/github-reaction-container.d.ts +2 -1
- package/dist/components/rating/github-reaction-container.mjs +46 -0
- package/dist/components/rating/github-reaction.d.ts +3 -2
- package/dist/components/rating/github-reaction.mjs +173 -0
- package/dist/components/rating/index.mjs +3 -0
- package/dist/components/rating/rater-list.d.ts +3 -2
- package/dist/components/rating/rater-list.mjs +33 -0
- package/dist/components/rating/rating.d.ts +1 -1
- package/dist/components/rating/rating.mjs +50 -0
- package/dist/components/routes.d.ts +1 -1
- package/dist/components/routes.mjs +27 -0
- package/dist/components/segmented-control.d.ts +3 -2
- package/dist/components/segmented-control.mjs +55 -0
- package/dist/components/shared/relative-time.d.ts +2 -1
- package/dist/components/shared/relative-time.mjs +21 -0
- package/dist/components/toast.d.ts +1 -1
- package/dist/components/toast.mjs +44 -0
- package/dist/components/uploader/index.d.ts +3 -3
- package/dist/components/uploader/index.mjs +70 -0
- package/dist/components/uploader/utils.mjs +16 -0
- package/dist/components/utils.d.ts +4 -4
- package/dist/components/utils.mjs +139 -0
- package/dist/components/view-more.d.ts +1 -1
- package/dist/components/view-more.mjs +50 -0
- package/dist/constants.mjs +14 -0
- package/dist/global.d.ts +1 -0
- package/dist/index.mjs +37 -0
- package/dist/preferences.mjs +9 -0
- package/dist/theme/index.d.ts +3 -3
- package/dist/theme/index.mjs +96 -0
- package/dist/theme/typography.d.ts +1 -1
- package/dist/theme/typography.mjs +66 -0
- package/dist/type-override.d.ts +7 -0
- package/dist/types.mjs +0 -0
- package/dist/vite-env.d.ts +1 -0
- package/dist/ws.d.ts +2 -2
- package/dist/ws.mjs +39 -0
- package/package.json +18 -25
- package/dist/components/avatars/Avatars.stories.d.ts +0 -5
- package/dist/components/posts/Post.stories.d.ts +0 -7
- package/dist/index-BlqRGWgQ.mjs +0 -7631
- package/dist/index.es.js +0 -118
- package/dist/index.umd.js +0 -7589
- package/dist/test/fixtures/index.d.ts +0 -4
- package/dist/test/fixtures/mock-session.d.ts +0 -3
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Button, CircularProgress, Typography } from "@mui/material";
|
|
3
|
+
import { useRequest } from "ahooks";
|
|
4
|
+
import { joinURL } from "ufo";
|
|
5
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
6
|
+
import { getPaymentKitMountPoint } from "./utils.mjs";
|
|
7
|
+
import { useSessionContext } from "./hooks/session.mjs";
|
|
8
|
+
const paymentKitMountPoint = getPaymentKitMountPoint();
|
|
9
|
+
const buttonDisabledProps = {
|
|
10
|
+
color: "inherit",
|
|
11
|
+
variant: "contained",
|
|
12
|
+
sx: {
|
|
13
|
+
color: "grey.800",
|
|
14
|
+
cursor: "not-allowed"
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
const isBlurSubscriptionPublicType = window?.blocklet?.preferences?.subscriptionPublicType === "blur";
|
|
18
|
+
export function Paywall({ children, cta, ...rest }) {
|
|
19
|
+
return /* @__PURE__ */ jsxs(Box, { ...rest, children: [
|
|
20
|
+
/* @__PURE__ */ jsx(
|
|
21
|
+
Box,
|
|
22
|
+
{
|
|
23
|
+
sx: {
|
|
24
|
+
...isBlurSubscriptionPublicType && {
|
|
25
|
+
maxHeight: "70vh",
|
|
26
|
+
overflow: "hidden",
|
|
27
|
+
position: "relative"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
children
|
|
31
|
+
}
|
|
32
|
+
),
|
|
33
|
+
/* @__PURE__ */ jsx(
|
|
34
|
+
Box,
|
|
35
|
+
{
|
|
36
|
+
className: "paywall",
|
|
37
|
+
sx: {
|
|
38
|
+
display: "flex",
|
|
39
|
+
flexDirection: "column",
|
|
40
|
+
alignItems: "center",
|
|
41
|
+
py: 6,
|
|
42
|
+
color: "#fff",
|
|
43
|
+
bgcolor: "#000",
|
|
44
|
+
borderRadius: 2,
|
|
45
|
+
position: "sticky",
|
|
46
|
+
bottom: 16,
|
|
47
|
+
// 向上白色渐变背景
|
|
48
|
+
":before": {
|
|
49
|
+
content: '""',
|
|
50
|
+
position: "absolute",
|
|
51
|
+
left: 0,
|
|
52
|
+
right: 0,
|
|
53
|
+
top: "-50%",
|
|
54
|
+
height: "50%",
|
|
55
|
+
background: "linear-gradient(transparent, rgba(255, 255, 255, 0.9) 85%)"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
children: cta
|
|
59
|
+
}
|
|
60
|
+
)
|
|
61
|
+
] });
|
|
62
|
+
}
|
|
63
|
+
export function SubscriptionPaywall({ type, fetchPaymentLink, ...rest }) {
|
|
64
|
+
const { session } = useSessionContext();
|
|
65
|
+
const { t } = useLocaleContext();
|
|
66
|
+
const { data, loading } = useRequest(() => fetchPaymentLink({ type, redirect: window.location.href }));
|
|
67
|
+
const paymentLink = paymentKitMountPoint && data?.link ? joinURL(paymentKitMountPoint, data.link) : null;
|
|
68
|
+
const loginAndReloadPage = () => {
|
|
69
|
+
session.login(() => {
|
|
70
|
+
window.location.reload();
|
|
71
|
+
});
|
|
72
|
+
};
|
|
73
|
+
const isDisabled = !paymentLink && !loading;
|
|
74
|
+
return /* @__PURE__ */ jsx(
|
|
75
|
+
Paywall,
|
|
76
|
+
{
|
|
77
|
+
...rest,
|
|
78
|
+
cta: /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
79
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h2", sx: { fontWeight: "bold" }, children: t("paywall.subscription.title") }),
|
|
80
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body1", sx: { maxWidth: 600, mt: 1, mx: 4, textAlign: "center" }, children: t("paywall.subscription.desc") }),
|
|
81
|
+
/* @__PURE__ */ jsx(Box, { sx: { mt: 6 }, children: /* @__PURE__ */ jsxs(
|
|
82
|
+
Button,
|
|
83
|
+
{
|
|
84
|
+
href: paymentLink || "#",
|
|
85
|
+
color: "primary",
|
|
86
|
+
variant: "contained",
|
|
87
|
+
size: "large",
|
|
88
|
+
...isDisabled ? buttonDisabledProps : {},
|
|
89
|
+
children: [
|
|
90
|
+
t("paywall.subscription.subscribeNow"),
|
|
91
|
+
loading && /* @__PURE__ */ jsx(CircularProgress, { size: 16, sx: { ml: 1, color: "#fff" } })
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
) }),
|
|
95
|
+
!session?.user && /* @__PURE__ */ jsxs(Typography, { variant: "body1", sx: { mt: 2, color: "grey.400" }, children: [
|
|
96
|
+
/* @__PURE__ */ jsx(Box, { component: "span", sx: { display: "inline-block", mr: 1 }, children: t("paywall.subscription.alreadySubscribe") }),
|
|
97
|
+
/* @__PURE__ */ jsx(
|
|
98
|
+
Box,
|
|
99
|
+
{
|
|
100
|
+
component: "span",
|
|
101
|
+
sx: { textDecoration: "underline", fontWeight: "bold", cursor: "pointer" },
|
|
102
|
+
onClick: loginAndReloadPage,
|
|
103
|
+
children: t("common.connect")
|
|
104
|
+
}
|
|
105
|
+
)
|
|
106
|
+
] })
|
|
107
|
+
] })
|
|
108
|
+
}
|
|
109
|
+
);
|
|
110
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
export declare const usePointUpContext: () => {};
|
|
2
3
|
type PointUpProps = {
|
|
3
4
|
points: number;
|
|
4
5
|
};
|
|
5
|
-
export default function PointUp({ points }: PointUpProps): import("react
|
|
6
|
-
export declare function PointUpProvider({ children }: any): import("react
|
|
6
|
+
export default function PointUp({ points }: PointUpProps): import("react").JSX.Element;
|
|
7
|
+
export declare function PointUpProvider({ children }: any): import("react").JSX.Element;
|
|
7
8
|
export {};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useCallback, useContext, useEffect, useMemo } from "react";
|
|
3
|
+
import { createPortal } from "react-dom";
|
|
4
|
+
import { useReactive } from "ahooks";
|
|
5
|
+
import Box from "@mui/material/Box";
|
|
6
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
7
|
+
import joinUrl from "url-join";
|
|
8
|
+
import LottieComponent from "./lottie-component.mjs";
|
|
9
|
+
import boxAnimation from "./box-animation.json";
|
|
10
|
+
import { getWsClient, useSubscription } from "../../ws.mjs";
|
|
11
|
+
import { useSessionContext } from "../hooks/index.mjs";
|
|
12
|
+
import { getDiscussKitClientId } from "../utils.mjs";
|
|
13
|
+
const id = "point-up-component";
|
|
14
|
+
const PointUpContext = createContext({});
|
|
15
|
+
const WsEvents = Object.freeze({
|
|
16
|
+
POINT_UP: "point.up"
|
|
17
|
+
});
|
|
18
|
+
export const usePointUpContext = () => useContext(PointUpContext);
|
|
19
|
+
export default function PointUp({ points }) {
|
|
20
|
+
const { t } = useLocaleContext();
|
|
21
|
+
return /* @__PURE__ */ jsxs(
|
|
22
|
+
Box,
|
|
23
|
+
{
|
|
24
|
+
sx: {
|
|
25
|
+
display: "inline-flex",
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
justifyContent: "center",
|
|
28
|
+
flexDirection: "column"
|
|
29
|
+
},
|
|
30
|
+
children: [
|
|
31
|
+
/* @__PURE__ */ jsx(
|
|
32
|
+
LottieComponent,
|
|
33
|
+
{
|
|
34
|
+
src: boxAnimation,
|
|
35
|
+
style: {
|
|
36
|
+
width: 120,
|
|
37
|
+
height: 120,
|
|
38
|
+
marginTop: -28
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
),
|
|
42
|
+
/* @__PURE__ */ jsx(
|
|
43
|
+
Box,
|
|
44
|
+
{
|
|
45
|
+
sx: {
|
|
46
|
+
mt: 1,
|
|
47
|
+
bgcolor: "primary.main",
|
|
48
|
+
px: 1,
|
|
49
|
+
py: 0.25,
|
|
50
|
+
color: "#fff",
|
|
51
|
+
borderRadius: 4,
|
|
52
|
+
fontSize: 13,
|
|
53
|
+
fontWeight: "bold"
|
|
54
|
+
},
|
|
55
|
+
children: t("common.pointUp", {
|
|
56
|
+
points: `${points}`
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
export function PointUpProvider({ children }) {
|
|
65
|
+
const state = useReactive({
|
|
66
|
+
pointsList: [],
|
|
67
|
+
visible: false,
|
|
68
|
+
currentPoints: 0
|
|
69
|
+
});
|
|
70
|
+
const { session } = useSessionContext();
|
|
71
|
+
const wsClient = getWsClient();
|
|
72
|
+
const pointUp = useCallback(({ points }) => {
|
|
73
|
+
state.pointsList.push(points);
|
|
74
|
+
}, []);
|
|
75
|
+
const pointUpComponent = window.blocklet?.componentMountPoints?.find?.(
|
|
76
|
+
(item) => item.did === "z2qa2ZST7Frp8w1XGqyw9v85u12R3mBbB2oaA"
|
|
77
|
+
);
|
|
78
|
+
const handlers = {
|
|
79
|
+
[WsEvents.POINT_UP]: (payload) => {
|
|
80
|
+
pointUp(payload);
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
wsClient.connect();
|
|
85
|
+
return () => {
|
|
86
|
+
if (wsClient.isConnected()) {
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}, []);
|
|
90
|
+
const value = useMemo(() => {
|
|
91
|
+
return {
|
|
92
|
+
pointUp
|
|
93
|
+
};
|
|
94
|
+
}, []);
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (state.pointsList.length > 0) {
|
|
97
|
+
state.visible = true;
|
|
98
|
+
state.currentPoints = +state.pointsList[0];
|
|
99
|
+
const waitToClosePointUp = (ms = 5e3) => {
|
|
100
|
+
setTimeout(() => {
|
|
101
|
+
const el = document.getElementById(id);
|
|
102
|
+
if (el && el.matches(":hover")) {
|
|
103
|
+
waitToClosePointUp(ms / 2);
|
|
104
|
+
} else {
|
|
105
|
+
state.pointsList.shift();
|
|
106
|
+
}
|
|
107
|
+
}, ms);
|
|
108
|
+
};
|
|
109
|
+
waitToClosePointUp();
|
|
110
|
+
} else {
|
|
111
|
+
state.visible = false;
|
|
112
|
+
}
|
|
113
|
+
}, [JSON.stringify(state.pointsList)]);
|
|
114
|
+
useSubscription(
|
|
115
|
+
session?.user?.did,
|
|
116
|
+
({ event, clientId, data }) => {
|
|
117
|
+
if (clientId === getDiscussKitClientId()) {
|
|
118
|
+
handlers[event]?.(data);
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
[]
|
|
122
|
+
);
|
|
123
|
+
return /* @__PURE__ */ jsxs(PointUpContext.Provider, { value, children: [
|
|
124
|
+
pointUpComponent?.mountPoint && createPortal(
|
|
125
|
+
/* @__PURE__ */ jsx(
|
|
126
|
+
Box,
|
|
127
|
+
{
|
|
128
|
+
onClick: () => {
|
|
129
|
+
window.open(joinUrl(window.location.origin, pointUpComponent.mountPoint, "my"));
|
|
130
|
+
},
|
|
131
|
+
id,
|
|
132
|
+
sx: {
|
|
133
|
+
position: "fixed",
|
|
134
|
+
bottom: 12,
|
|
135
|
+
left: 12,
|
|
136
|
+
zIndex: 9999,
|
|
137
|
+
opacity: state.visible ? 0.8 : 0,
|
|
138
|
+
transition: "all 0.3s",
|
|
139
|
+
pointerEvents: state.visible ? "auto" : "none",
|
|
140
|
+
cursor: "pointer",
|
|
141
|
+
"&:hover": {
|
|
142
|
+
opacity: state.visible ? 1 : 0,
|
|
143
|
+
transform: "translateY(-4px)"
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
children: state.visible && /* @__PURE__ */ jsx(PointUp, { points: state.currentPoints })
|
|
147
|
+
}
|
|
148
|
+
),
|
|
149
|
+
document.body
|
|
150
|
+
),
|
|
151
|
+
children
|
|
152
|
+
] });
|
|
153
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
export interface LottieProps {
|
|
2
3
|
src: any;
|
|
3
4
|
style: any;
|
|
4
5
|
}
|
|
5
|
-
export default function LottieComponent({ src, ...restProps }: LottieProps): import("react
|
|
6
|
+
export default function LottieComponent({ src, ...restProps }: LottieProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { lazyRetry as lazy } from "@arcblock/ux/lib/Util";
|
|
3
|
+
import { Suspense } from "react";
|
|
4
|
+
const Lottie = lazy(() => import("lottie-react"));
|
|
5
|
+
export default function LottieComponent({ src, ...restProps }) {
|
|
6
|
+
return /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(Lottie, { animationData: src, loop: true, ...restProps }) });
|
|
7
|
+
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment } from "react";
|
|
3
|
+
import Box from "@mui/material/Box";
|
|
4
|
+
import Button from "@mui/material/Button";
|
|
5
|
+
import { NavigateNext as NavigateNextIcon } from "@mui/icons-material";
|
|
6
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
7
|
+
import { styled } from "@mui/material/styles";
|
|
8
|
+
import { useCommentsContext } from "./context.mjs";
|
|
9
|
+
import Comment from "../comment.mjs";
|
|
10
|
+
const LoadMoreButtonWrapper = styled(Box)`
|
|
11
|
+
background-image: url("data:image/svg+xml,%3Csvg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 11L8 5L16 11' stroke='%23e1e4e8' stroke-linecap='square' stroke-width='1.5' /%3E%3C/svg%3E");
|
|
12
|
+
background-repeat: repeat-x;
|
|
13
|
+
background-position: center;
|
|
14
|
+
`;
|
|
15
|
+
function SegmentalList({ ...rest }) {
|
|
16
|
+
const { t } = useLocaleContext();
|
|
17
|
+
const {
|
|
18
|
+
state: { comments, nextCursor, highlighted },
|
|
19
|
+
autoCollapse,
|
|
20
|
+
allowCopyLink,
|
|
21
|
+
showProfileCard,
|
|
22
|
+
interactive,
|
|
23
|
+
loadMore,
|
|
24
|
+
loadMoreForTailSection,
|
|
25
|
+
updateComment,
|
|
26
|
+
deleteComment,
|
|
27
|
+
reply,
|
|
28
|
+
togglePin,
|
|
29
|
+
loadMoreReplies,
|
|
30
|
+
api
|
|
31
|
+
} = useCommentsContext();
|
|
32
|
+
if (!highlighted) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
const headIndex = comments.findIndex((item) => item.id === highlighted.head);
|
|
36
|
+
const hiddenComments = highlighted.position - comments.findIndex((item) => item.id === highlighted.id) + headIndex;
|
|
37
|
+
return /* @__PURE__ */ jsxs("div", { ...rest, className: "comment-list", children: [
|
|
38
|
+
comments.map((comment) => {
|
|
39
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
40
|
+
comment.id === highlighted?.id && hiddenComments > 0 && nextCursor && /* @__PURE__ */ jsx(LoadMoreButtonWrapper, { sx: { my: 4, textAlign: "center" }, children: /* @__PURE__ */ jsxs(
|
|
41
|
+
Box,
|
|
42
|
+
{
|
|
43
|
+
sx: {
|
|
44
|
+
display: "inline-flex",
|
|
45
|
+
flexDirection: "column",
|
|
46
|
+
justifyContent: "center",
|
|
47
|
+
alignItems: "center",
|
|
48
|
+
px: 4,
|
|
49
|
+
pt: 1,
|
|
50
|
+
pb: 2,
|
|
51
|
+
border: 1,
|
|
52
|
+
borderColor: "grey.300",
|
|
53
|
+
borderRadius: 1,
|
|
54
|
+
bgcolor: "#fff"
|
|
55
|
+
},
|
|
56
|
+
children: [
|
|
57
|
+
/* @__PURE__ */ jsx(Button, { onClick: () => loadMore(nextCursor), variant: "text", color: "primary", sx: { fontSize: 13 }, children: t("loadMore") }),
|
|
58
|
+
/* @__PURE__ */ jsxs(Box, { sx: { fontSize: 12, color: "grey.500" }, children: [
|
|
59
|
+
hiddenComments,
|
|
60
|
+
" Comments"
|
|
61
|
+
] })
|
|
62
|
+
]
|
|
63
|
+
}
|
|
64
|
+
) }),
|
|
65
|
+
/* @__PURE__ */ jsx(
|
|
66
|
+
Comment,
|
|
67
|
+
{
|
|
68
|
+
post: comment,
|
|
69
|
+
onDelete: deleteComment,
|
|
70
|
+
onContentUpdate: updateComment,
|
|
71
|
+
onRate: api.rate,
|
|
72
|
+
onUnrate: api.unrate,
|
|
73
|
+
onReply: reply,
|
|
74
|
+
onTogglePin: togglePin,
|
|
75
|
+
onLoadMoreReplies: loadMoreReplies,
|
|
76
|
+
autoCollapse,
|
|
77
|
+
allowCopyLink,
|
|
78
|
+
showProfileCard,
|
|
79
|
+
interactive
|
|
80
|
+
}
|
|
81
|
+
)
|
|
82
|
+
] }, comment.id);
|
|
83
|
+
}),
|
|
84
|
+
highlighted.nextCursor && /* @__PURE__ */ jsx(Box, { sx: { my: 2, textAlign: "center" }, children: /* @__PURE__ */ jsx(
|
|
85
|
+
Button,
|
|
86
|
+
{
|
|
87
|
+
onClick: loadMoreForTailSection,
|
|
88
|
+
variant: "outlined",
|
|
89
|
+
color: "primary",
|
|
90
|
+
endIcon: /* @__PURE__ */ jsx(NavigateNextIcon, {}),
|
|
91
|
+
sx: { fontSize: 13 },
|
|
92
|
+
children: t("loadMore")
|
|
93
|
+
}
|
|
94
|
+
) })
|
|
95
|
+
] });
|
|
96
|
+
}
|
|
97
|
+
export default function CommentList(props) {
|
|
98
|
+
const { t } = useLocaleContext();
|
|
99
|
+
const {
|
|
100
|
+
state: { order, nextCursor, highlighted },
|
|
101
|
+
comments,
|
|
102
|
+
pinned,
|
|
103
|
+
autoCollapse,
|
|
104
|
+
allowCopyLink,
|
|
105
|
+
showProfileCard,
|
|
106
|
+
interactive,
|
|
107
|
+
loadMore,
|
|
108
|
+
updateComment,
|
|
109
|
+
deleteComment,
|
|
110
|
+
reply,
|
|
111
|
+
togglePin,
|
|
112
|
+
loadMoreReplies,
|
|
113
|
+
api,
|
|
114
|
+
renderComments,
|
|
115
|
+
renderDonation,
|
|
116
|
+
renderActions,
|
|
117
|
+
renderEditorPlugins,
|
|
118
|
+
enableAutoTranslate
|
|
119
|
+
} = useCommentsContext();
|
|
120
|
+
if (highlighted) {
|
|
121
|
+
return /* @__PURE__ */ jsx(SegmentalList, { ...props });
|
|
122
|
+
}
|
|
123
|
+
const renderComment = (comment, restProps) => /* @__PURE__ */ jsx(
|
|
124
|
+
Comment,
|
|
125
|
+
{
|
|
126
|
+
post: comment,
|
|
127
|
+
onDelete: deleteComment,
|
|
128
|
+
onContentUpdate: updateComment,
|
|
129
|
+
onRate: api.rate,
|
|
130
|
+
onUnrate: api.unrate,
|
|
131
|
+
onReply: reply,
|
|
132
|
+
onTogglePin: togglePin,
|
|
133
|
+
onLoadMoreReplies: loadMoreReplies,
|
|
134
|
+
autoCollapse,
|
|
135
|
+
allowCopyLink,
|
|
136
|
+
showProfileCard,
|
|
137
|
+
interactive,
|
|
138
|
+
renderDonation,
|
|
139
|
+
renderActions,
|
|
140
|
+
renderEditorPlugins,
|
|
141
|
+
enableAutoTranslate,
|
|
142
|
+
...restProps
|
|
143
|
+
},
|
|
144
|
+
comment.id
|
|
145
|
+
);
|
|
146
|
+
const sortedPinned = pinned.sort((a, b) => (b.pinnedAt?.getTime() ?? 0) - (a.pinnedAt?.getTime() ?? 0));
|
|
147
|
+
return /* @__PURE__ */ jsxs("div", { ...props, children: [
|
|
148
|
+
/* @__PURE__ */ jsx(Box, { children: sortedPinned.map((post) => renderComment(post, {})) }),
|
|
149
|
+
renderComments ? renderComments({ order, comments, renderComment }) : comments?.map(renderComment),
|
|
150
|
+
nextCursor && /* @__PURE__ */ jsx(Box, { sx: { my: 2, textAlign: "center" }, children: /* @__PURE__ */ jsx(
|
|
151
|
+
Button,
|
|
152
|
+
{
|
|
153
|
+
className: "load-more",
|
|
154
|
+
onClick: () => loadMore(nextCursor),
|
|
155
|
+
variant: "outlined",
|
|
156
|
+
color: "primary",
|
|
157
|
+
endIcon: /* @__PURE__ */ jsx(NavigateNextIcon, {}),
|
|
158
|
+
sx: { fontSize: 13 },
|
|
159
|
+
children: t("loadMore")
|
|
160
|
+
}
|
|
161
|
+
) })
|
|
162
|
+
] });
|
|
163
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Post, Target, CommentAPI } from '../../../types';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Post, Target, CommentAPI } from '../../../types';
|
|
3
3
|
type Order = 'asc' | 'desc';
|
|
4
4
|
export type CommentsRender = (value: {
|
|
5
5
|
comments: Post[];
|
|
@@ -70,7 +70,7 @@ interface CommentsContextValue {
|
|
|
70
70
|
enableAutoTranslate?: boolean;
|
|
71
71
|
renderInnerFooter?: (post: Post) => React.ReactElement<any>;
|
|
72
72
|
}
|
|
73
|
-
export declare const CommentsContext:
|
|
73
|
+
export declare const CommentsContext: import("react").Context<CommentsContextValue>;
|
|
74
74
|
export declare const useCommentsContext: () => CommentsContextValue;
|
|
75
|
-
export declare function CommentsProvider({ target, api, flatView, children, order, autoLoadComments, autoCollapse, allowCopyLink, showProfileCard, interactive, containerRef, renderComments, renderDonation, renderActions, renderEditorPlugins, enableAutoTranslate, renderInnerFooter, }: CommentsProviderProps):
|
|
75
|
+
export declare function CommentsProvider({ target, api, flatView, children, order, autoLoadComments, autoCollapse, allowCopyLink, showProfileCard, interactive, containerRef, renderComments, renderDonation, renderActions, renderEditorPlugins, enableAutoTranslate, renderInnerFooter, }: CommentsProviderProps): JSX.Element;
|
|
76
76
|
export {};
|