@blocklet/discuss-kit-ux 2.4.36 → 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-BsHdgrDc.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 +10 -17
- package/dist/components/avatars/Avatars.stories.d.ts +0 -5
- package/dist/components/posts/Post.stories.d.ts +0 -7
- package/dist/index-BZDpbkvV.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,58 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Box from "@mui/material/Box";
|
|
3
|
+
import DID from "@arcblock/ux/lib/DID";
|
|
4
|
+
import NotificationsActiveOutlinedIcon from "@mui/icons-material/NotificationsActiveOutlined";
|
|
5
|
+
export default function SystemUser({
|
|
6
|
+
name = "System",
|
|
7
|
+
showDidAddress = true,
|
|
8
|
+
showIcon = true,
|
|
9
|
+
size = "normal",
|
|
10
|
+
icon,
|
|
11
|
+
...rest
|
|
12
|
+
}) {
|
|
13
|
+
const sm = size === "sm";
|
|
14
|
+
const iconSize = sm ? 40 : 48;
|
|
15
|
+
return /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 1, fontSize: 14 }, ...rest, children: [
|
|
16
|
+
showIcon && /* @__PURE__ */ jsx(
|
|
17
|
+
Box,
|
|
18
|
+
{
|
|
19
|
+
sx: {
|
|
20
|
+
flex: "0 0 auto",
|
|
21
|
+
display: "flex",
|
|
22
|
+
justifyContent: "center",
|
|
23
|
+
alignItems: "center",
|
|
24
|
+
width: iconSize,
|
|
25
|
+
height: iconSize,
|
|
26
|
+
p: 1,
|
|
27
|
+
color: "#fff",
|
|
28
|
+
bgcolor: "secondary.main",
|
|
29
|
+
borderRadius: "100%"
|
|
30
|
+
},
|
|
31
|
+
children: icon || /* @__PURE__ */ jsx(NotificationsActiveOutlinedIcon, { sx: { fontSize: size === "sm" ? 16 : 18 } })
|
|
32
|
+
}
|
|
33
|
+
),
|
|
34
|
+
/* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column", overflow: "hidden" }, children: [
|
|
35
|
+
/* @__PURE__ */ jsx(
|
|
36
|
+
Box,
|
|
37
|
+
{
|
|
38
|
+
sx: {
|
|
39
|
+
lineHeight: 1.5,
|
|
40
|
+
display: "flex",
|
|
41
|
+
alignItems: "center"
|
|
42
|
+
},
|
|
43
|
+
children: /* @__PURE__ */ jsx(Box, { component: "span", sx: { fontWeight: "bold" }, children: name })
|
|
44
|
+
}
|
|
45
|
+
),
|
|
46
|
+
showDidAddress && /* @__PURE__ */ jsx(
|
|
47
|
+
DID,
|
|
48
|
+
{
|
|
49
|
+
style: { lineHeight: 1.5, minHeight: 20, maxWidth: 200 },
|
|
50
|
+
size: 14,
|
|
51
|
+
did: window.blocklet.appId,
|
|
52
|
+
copyable: false,
|
|
53
|
+
compact: true
|
|
54
|
+
}
|
|
55
|
+
)
|
|
56
|
+
] })
|
|
57
|
+
] });
|
|
58
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { SxProps, ButtonProps } from '@mui/material';
|
|
2
3
|
interface BackProps {
|
|
3
4
|
url?: string;
|
|
@@ -6,5 +7,5 @@ interface BackProps {
|
|
|
6
7
|
sx?: SxProps;
|
|
7
8
|
icon?: React.ReactNode;
|
|
8
9
|
}
|
|
9
|
-
export declare function Back({ url, fallbackUrl, iconOnly, sx, icon, ...rest }: BackProps & ButtonProps): import("react
|
|
10
|
+
export declare function Back({ url, fallbackUrl, iconOnly, sx, icon, ...rest }: BackProps & ButtonProps): import("react").JSX.Element | null;
|
|
10
11
|
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useLocation, useNavigate } from "react-router-dom";
|
|
3
|
+
import { ArrowBackIos as ArrowBackIosIcon } from "@mui/icons-material";
|
|
4
|
+
import { Button } from "@mui/material";
|
|
5
|
+
import { isInArcSphere } from "./arcsphere/index.mjs";
|
|
6
|
+
export function Back({ url, fallbackUrl, iconOnly, sx, icon, ...rest }) {
|
|
7
|
+
const navigate = useNavigate();
|
|
8
|
+
const location = useLocation();
|
|
9
|
+
const mergedSx = [{}, ...Array.isArray(sx) ? sx : [sx]];
|
|
10
|
+
if (isInArcSphere) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
const handleClick = () => {
|
|
14
|
+
if (url) {
|
|
15
|
+
navigate(url, { replace: true });
|
|
16
|
+
} else if (location.state?.from) {
|
|
17
|
+
navigate(-1);
|
|
18
|
+
} else {
|
|
19
|
+
navigate(fallbackUrl || "/");
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
icon = icon || /* @__PURE__ */ jsx(ArrowBackIosIcon, { style: { fontSize: 13 } });
|
|
23
|
+
if (iconOnly) {
|
|
24
|
+
mergedSx.push({ minWidth: "initial", py: 1 });
|
|
25
|
+
return /* @__PURE__ */ jsx(Button, { onClick: handleClick, variant: "text", color: "inherit", sx: mergedSx, ...rest, children: icon });
|
|
26
|
+
}
|
|
27
|
+
return /* @__PURE__ */ jsx(Button, { onClick: handleClick, variant: "outlined", color: "primary", startIcon: icon, sx: mergedSx, ...rest, children: "Back" });
|
|
28
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import dayjs from "../dayjs.mjs";
|
|
2
|
+
import { blogPath } from "../routes.mjs";
|
|
3
|
+
export const getBlogLink = (post, locale) => {
|
|
4
|
+
const mergedLocale = locale || post.locale || "en";
|
|
5
|
+
const slug = post.slug || post.id;
|
|
6
|
+
const datePrefix = `${dayjs(post.createdAt).format("YYYY-MM-DD")}-`;
|
|
7
|
+
if (slug.startsWith(datePrefix)) {
|
|
8
|
+
return blogPath(
|
|
9
|
+
`/${mergedLocale || "en"}/post/${dayjs(post.createdAt).format("YYYY/MM/DD")}/${slug.replace(datePrefix, "")}`
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
if (mergedLocale) {
|
|
13
|
+
return blogPath(`/${mergedLocale}/${slug}`);
|
|
14
|
+
}
|
|
15
|
+
return blogPath(`/${slug}`);
|
|
16
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { BlogPost } from './types';
|
|
2
3
|
interface BlogListProps {
|
|
3
4
|
posts: BlogPost[];
|
|
4
5
|
boardId?: string;
|
|
@@ -21,8 +22,8 @@ type CardProps = {
|
|
|
21
22
|
};
|
|
22
23
|
export declare function BlogCard({ ref, post, hideAuthor, linkTarget, compactLayout, loading, }: CardProps & {
|
|
23
24
|
ref?: React.RefObject<HTMLDivElement | null>;
|
|
24
|
-
}): import("react
|
|
25
|
+
}): import("react").JSX.Element;
|
|
25
26
|
export default function BlogListWrapper({ variant, cardsLayout, ...rest }: BlogListProps & {
|
|
26
27
|
variant?: 'card' | 'list';
|
|
27
|
-
}): import("react
|
|
28
|
+
}): import("react").JSX.Element;
|
|
28
29
|
export {};
|
|
@@ -0,0 +1,441 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Link, useNavigate } from "react-router-dom";
|
|
3
|
+
import Box from "@mui/material/Box";
|
|
4
|
+
import Typography from "@mui/material/Typography";
|
|
5
|
+
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
6
|
+
import { useTheme } from "@mui/material/styles";
|
|
7
|
+
import { ChatBubbleOutlineOutlined as ChatBubbleOutlineOutlinedIcon } from "@mui/icons-material";
|
|
8
|
+
import Skeleton from "@mui/material/Skeleton";
|
|
9
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
10
|
+
import { Labels2 } from "@blocklet/labels";
|
|
11
|
+
import RelativeTime from "../shared/relative-time.mjs";
|
|
12
|
+
import { AuthorInfo } from "../avatars/index.mjs";
|
|
13
|
+
import { CoverImage } from "./cover-image.mjs";
|
|
14
|
+
import { getBlogLink } from "./blog-link.mjs";
|
|
15
|
+
import useMeasure from "../hooks/measure.mjs";
|
|
16
|
+
import { useResponsiveValue } from "../hooks/responsive.mjs";
|
|
17
|
+
const lineClamp2 = {
|
|
18
|
+
overflow: "hidden",
|
|
19
|
+
textOverflow: "ellipsis",
|
|
20
|
+
wordBreak: "break-word",
|
|
21
|
+
display: "-webkit-box",
|
|
22
|
+
WebkitLineClamp: 2,
|
|
23
|
+
WebkitBoxOrient: "vertical"
|
|
24
|
+
};
|
|
25
|
+
function BlogItem({
|
|
26
|
+
data: item,
|
|
27
|
+
hideAuthor,
|
|
28
|
+
itemLinkTarget,
|
|
29
|
+
prepend,
|
|
30
|
+
loading = false,
|
|
31
|
+
displayLabels = true
|
|
32
|
+
}) {
|
|
33
|
+
const theme = useTheme();
|
|
34
|
+
const downMd = useMediaQuery(theme.breakpoints.down("md"));
|
|
35
|
+
const { locale } = useLocaleContext();
|
|
36
|
+
const navigate = useNavigate();
|
|
37
|
+
const coverImgWidths = { xs: 84, md: 180, lg: 200 };
|
|
38
|
+
const coverImgWidth = useResponsiveValue(coverImgWidths);
|
|
39
|
+
if (loading) {
|
|
40
|
+
return /* @__PURE__ */ jsx(Box, { sx: { display: "block", color: "inherit", textDecoration: "none", "& + &": { mt: { xs: 2.5, md: 6 } } }, children: /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
|
|
41
|
+
/* @__PURE__ */ jsxs(Box, { sx: { flex: 1, pr: { xs: 2, md: 4 } }, children: [
|
|
42
|
+
hideAuthor === "1" || /* @__PURE__ */ jsxs(
|
|
43
|
+
Box,
|
|
44
|
+
{
|
|
45
|
+
sx: {
|
|
46
|
+
flex: 1,
|
|
47
|
+
display: "flex"
|
|
48
|
+
},
|
|
49
|
+
children: [
|
|
50
|
+
/* @__PURE__ */ jsx(Skeleton, { variant: "circular", width: 40, height: 40 }),
|
|
51
|
+
/* @__PURE__ */ jsxs(
|
|
52
|
+
Box,
|
|
53
|
+
{
|
|
54
|
+
sx: {
|
|
55
|
+
flex: 1,
|
|
56
|
+
ml: 1
|
|
57
|
+
},
|
|
58
|
+
children: [
|
|
59
|
+
/* @__PURE__ */ jsx(Skeleton, { height: 20, width: 40 }),
|
|
60
|
+
/* @__PURE__ */ jsx(Skeleton, { height: 20, width: 100 })
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
),
|
|
67
|
+
/* @__PURE__ */ jsx(Skeleton, { height: 30 }),
|
|
68
|
+
/* @__PURE__ */ jsx(
|
|
69
|
+
Box,
|
|
70
|
+
{
|
|
71
|
+
sx: {
|
|
72
|
+
display: { xs: "inline-block", md: "none" },
|
|
73
|
+
mt: 0.5,
|
|
74
|
+
fontSize: 12,
|
|
75
|
+
color: "grey.500",
|
|
76
|
+
lineHeight: 1
|
|
77
|
+
},
|
|
78
|
+
children: /* @__PURE__ */ jsx(Skeleton, { height: 14, width: 60 })
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
] }),
|
|
82
|
+
/* @__PURE__ */ jsx(Box, { sx: { flex: "0 0 auto", width: { xs: 84, md: 180, lg: 200 } }, children: /* @__PURE__ */ jsx(Skeleton, { height: 130 }) })
|
|
83
|
+
] }) });
|
|
84
|
+
}
|
|
85
|
+
return /* @__PURE__ */ jsx(
|
|
86
|
+
Box,
|
|
87
|
+
{
|
|
88
|
+
component: Link,
|
|
89
|
+
target: itemLinkTarget,
|
|
90
|
+
to: getBlogLink(item),
|
|
91
|
+
sx: { display: "block", color: "inherit", textDecoration: "none", "& + &": { mt: { xs: 2.5, md: 6 } } },
|
|
92
|
+
className: "blog-list-item",
|
|
93
|
+
children: /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", justifyContent: "space-between" }, children: [
|
|
94
|
+
/* @__PURE__ */ jsxs(Box, { sx: { flex: 1, minWidth: 0, pr: { xs: 2, md: 4 } }, children: [
|
|
95
|
+
typeof prepend === "function" ? prepend(item) : prepend,
|
|
96
|
+
hideAuthor === "1" || /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(AuthorInfo, { user: item.author, createdAt: downMd ? void 0 : item.publishTime, size: "sm", responsive: true }) }),
|
|
97
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h4", component: "h3", sx: { ...lineClamp2, my: 0.5 }, className: "item-title", children: item.title }),
|
|
98
|
+
item.excerpt && /* @__PURE__ */ jsxs(
|
|
99
|
+
Typography,
|
|
100
|
+
{
|
|
101
|
+
className: "item-excerpt",
|
|
102
|
+
variant: "body1",
|
|
103
|
+
sx: {
|
|
104
|
+
...lineClamp2,
|
|
105
|
+
WebkitLineClamp: { xs: 2, md: 3 },
|
|
106
|
+
fontSize: { xs: 12, md: 14 },
|
|
107
|
+
color: "text.secondary"
|
|
108
|
+
},
|
|
109
|
+
children: [
|
|
110
|
+
item.excerpt,
|
|
111
|
+
"..."
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
),
|
|
115
|
+
displayLabels && !!item.labels?.length && /* @__PURE__ */ jsx(
|
|
116
|
+
Labels2,
|
|
117
|
+
{
|
|
118
|
+
labels: item.labels,
|
|
119
|
+
renderLabel: (node, element) => {
|
|
120
|
+
const { id } = node.data;
|
|
121
|
+
return /* @__PURE__ */ jsx(
|
|
122
|
+
Box,
|
|
123
|
+
{
|
|
124
|
+
onClick: (e) => {
|
|
125
|
+
e.preventDefault();
|
|
126
|
+
navigate(`/tags/${locale}/${id}`);
|
|
127
|
+
},
|
|
128
|
+
children: element
|
|
129
|
+
},
|
|
130
|
+
id
|
|
131
|
+
);
|
|
132
|
+
},
|
|
133
|
+
sx: { display: "inline-flex", mt: 1 }
|
|
134
|
+
}
|
|
135
|
+
),
|
|
136
|
+
/* @__PURE__ */ jsx(
|
|
137
|
+
Box,
|
|
138
|
+
{
|
|
139
|
+
sx: {
|
|
140
|
+
display: { xs: "inline-block", md: "none" },
|
|
141
|
+
mt: 0.5,
|
|
142
|
+
fontSize: 12,
|
|
143
|
+
color: "grey.500",
|
|
144
|
+
lineHeight: 1
|
|
145
|
+
},
|
|
146
|
+
children: /* @__PURE__ */ jsx(RelativeTime, { value: item.publishTime })
|
|
147
|
+
}
|
|
148
|
+
)
|
|
149
|
+
] }),
|
|
150
|
+
item.cover && /* @__PURE__ */ jsx(Box, { sx: { flex: "0 0 auto", width: coverImgWidths }, children: /* @__PURE__ */ jsx(CoverImage, { url: item.cover, aspectRatio: downMd ? 1 : 3 / 2, loading: "lazy", width: coverImgWidth * 2 }) })
|
|
151
|
+
] })
|
|
152
|
+
},
|
|
153
|
+
item.id
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
function BlogList({
|
|
157
|
+
posts,
|
|
158
|
+
loadMore,
|
|
159
|
+
boardId,
|
|
160
|
+
hideAuthor,
|
|
161
|
+
itemLinkTarget,
|
|
162
|
+
prepend,
|
|
163
|
+
loading = false,
|
|
164
|
+
displayLabels = true,
|
|
165
|
+
defaultLoadingCount = 4,
|
|
166
|
+
...rest
|
|
167
|
+
}) {
|
|
168
|
+
let content = null;
|
|
169
|
+
if (loading) {
|
|
170
|
+
content = Array(defaultLoadingCount).fill("").map((item, index) => /* @__PURE__ */ jsx(
|
|
171
|
+
BlogItem,
|
|
172
|
+
{
|
|
173
|
+
loading: true,
|
|
174
|
+
data: item,
|
|
175
|
+
hideAuthor,
|
|
176
|
+
itemLinkTarget,
|
|
177
|
+
prepend
|
|
178
|
+
},
|
|
179
|
+
index
|
|
180
|
+
));
|
|
181
|
+
} else {
|
|
182
|
+
content = posts.map((item) => /* @__PURE__ */ jsx(
|
|
183
|
+
BlogItem,
|
|
184
|
+
{
|
|
185
|
+
data: item,
|
|
186
|
+
hideAuthor,
|
|
187
|
+
itemLinkTarget,
|
|
188
|
+
prepend,
|
|
189
|
+
displayLabels
|
|
190
|
+
},
|
|
191
|
+
item.id
|
|
192
|
+
));
|
|
193
|
+
}
|
|
194
|
+
return /* @__PURE__ */ jsx(Box, { ...rest, children: content });
|
|
195
|
+
}
|
|
196
|
+
export function BlogCard({
|
|
197
|
+
ref = void 0,
|
|
198
|
+
post,
|
|
199
|
+
hideAuthor,
|
|
200
|
+
linkTarget,
|
|
201
|
+
compactLayout,
|
|
202
|
+
loading = false
|
|
203
|
+
}) {
|
|
204
|
+
if (loading) {
|
|
205
|
+
return /* @__PURE__ */ jsx(Box, { sx: { display: "flex", justifyContent: "center", color: "inherit", textDecoration: "none" }, children: /* @__PURE__ */ jsxs(
|
|
206
|
+
Box,
|
|
207
|
+
{
|
|
208
|
+
sx: {
|
|
209
|
+
display: "flex",
|
|
210
|
+
flexDirection: "column",
|
|
211
|
+
width: 320,
|
|
212
|
+
maxWidth: 320,
|
|
213
|
+
borderRadius: 1,
|
|
214
|
+
overflow: "hidden",
|
|
215
|
+
boxShadow: "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)"
|
|
216
|
+
},
|
|
217
|
+
children: [
|
|
218
|
+
/* @__PURE__ */ jsx(Box, { sx: { flex: "0 0 auto" }, children: /* @__PURE__ */ jsx(Skeleton, { variant: "rectangular", width: "100%", height: 180 }) }),
|
|
219
|
+
/* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column", flex: 1, mt: 1, p: 2, pt: 0 }, children: [
|
|
220
|
+
/* @__PURE__ */ jsx(Skeleton, { width: "60%" }),
|
|
221
|
+
/* @__PURE__ */ jsx(Skeleton, {})
|
|
222
|
+
] }),
|
|
223
|
+
compactLayout === "1" || /* @__PURE__ */ jsxs(Box, { sx: { mt: "auto", px: 2 }, children: [
|
|
224
|
+
/* @__PURE__ */ jsx(Skeleton, { width: "30%" }),
|
|
225
|
+
/* @__PURE__ */ jsxs(
|
|
226
|
+
Box,
|
|
227
|
+
{
|
|
228
|
+
sx: {
|
|
229
|
+
display: "flex",
|
|
230
|
+
justifyContent: "space-between",
|
|
231
|
+
alignItems: "center",
|
|
232
|
+
mt: 2,
|
|
233
|
+
py: 2,
|
|
234
|
+
borderTop: "1px solid #eee"
|
|
235
|
+
},
|
|
236
|
+
children: [
|
|
237
|
+
hideAuthor === "1" || /* @__PURE__ */ jsxs(
|
|
238
|
+
Box,
|
|
239
|
+
{
|
|
240
|
+
sx: {
|
|
241
|
+
flex: 1,
|
|
242
|
+
display: "flex"
|
|
243
|
+
},
|
|
244
|
+
children: [
|
|
245
|
+
/* @__PURE__ */ jsx(Skeleton, { variant: "circular", width: 40, height: 40 }),
|
|
246
|
+
/* @__PURE__ */ jsxs(
|
|
247
|
+
Box,
|
|
248
|
+
{
|
|
249
|
+
sx: {
|
|
250
|
+
flex: 1,
|
|
251
|
+
ml: 1
|
|
252
|
+
},
|
|
253
|
+
children: [
|
|
254
|
+
/* @__PURE__ */ jsx(Skeleton, { height: 20, width: 40 }),
|
|
255
|
+
/* @__PURE__ */ jsx(Skeleton, { height: 20, width: 100 })
|
|
256
|
+
]
|
|
257
|
+
}
|
|
258
|
+
)
|
|
259
|
+
]
|
|
260
|
+
}
|
|
261
|
+
),
|
|
262
|
+
/* @__PURE__ */ jsxs(
|
|
263
|
+
Box,
|
|
264
|
+
{
|
|
265
|
+
sx: {
|
|
266
|
+
display: "flex",
|
|
267
|
+
alignItems: "center",
|
|
268
|
+
gap: 0.5,
|
|
269
|
+
color: "grey.500"
|
|
270
|
+
},
|
|
271
|
+
children: [
|
|
272
|
+
/* @__PURE__ */ jsx(ChatBubbleOutlineOutlinedIcon, { sx: { mt: 0.25, fontSize: 18, color: "grey.600" } }),
|
|
273
|
+
/* @__PURE__ */ jsx(Box, { component: "span", sx: { fontSize: 12 }, children: /* @__PURE__ */ jsx(Skeleton, { width: 20 }) })
|
|
274
|
+
]
|
|
275
|
+
}
|
|
276
|
+
)
|
|
277
|
+
]
|
|
278
|
+
}
|
|
279
|
+
)
|
|
280
|
+
] })
|
|
281
|
+
]
|
|
282
|
+
}
|
|
283
|
+
) });
|
|
284
|
+
}
|
|
285
|
+
return /* @__PURE__ */ jsx(
|
|
286
|
+
Box,
|
|
287
|
+
{
|
|
288
|
+
ref,
|
|
289
|
+
component: Link,
|
|
290
|
+
target: linkTarget,
|
|
291
|
+
to: getBlogLink(post),
|
|
292
|
+
sx: { display: "flex", justifyContent: "center", color: "inherit", textDecoration: "none" },
|
|
293
|
+
children: /* @__PURE__ */ jsxs(
|
|
294
|
+
Box,
|
|
295
|
+
{
|
|
296
|
+
sx: {
|
|
297
|
+
display: "flex",
|
|
298
|
+
flexDirection: "column",
|
|
299
|
+
width: 320,
|
|
300
|
+
maxWidth: 320,
|
|
301
|
+
borderRadius: 1,
|
|
302
|
+
overflow: "hidden",
|
|
303
|
+
boxShadow: "0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)"
|
|
304
|
+
},
|
|
305
|
+
children: [
|
|
306
|
+
/* @__PURE__ */ jsx(Box, { sx: { flex: "0 0 auto" }, children: /* @__PURE__ */ jsx(CoverImage, { url: post.cover, sx: { borderRadius: 0 }, loading: "lazy", width: 640 }) }),
|
|
307
|
+
/* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column", flex: 1, mt: 1, p: 2, pt: 0 }, children: [
|
|
308
|
+
/* @__PURE__ */ jsx(Typography, { variant: "h4", sx: { ...lineClamp2, my: 0.5 }, children: post.title }),
|
|
309
|
+
post.excerpt && /* @__PURE__ */ jsxs(Typography, { variant: "body1", sx: { ...lineClamp2, fontSize: { xs: 13, md: 14 }, color: "grey.600" }, children: [
|
|
310
|
+
post.excerpt,
|
|
311
|
+
"..."
|
|
312
|
+
] }),
|
|
313
|
+
compactLayout === "1" || /* @__PURE__ */ jsxs(Box, { sx: { mt: "auto" }, children: [
|
|
314
|
+
/* @__PURE__ */ jsxs(
|
|
315
|
+
Box,
|
|
316
|
+
{
|
|
317
|
+
sx: {
|
|
318
|
+
mt: 2,
|
|
319
|
+
fontSize: 12,
|
|
320
|
+
color: "grey.500",
|
|
321
|
+
lineHeight: 1
|
|
322
|
+
},
|
|
323
|
+
children: [
|
|
324
|
+
/* @__PURE__ */ jsx("span", { children: "posted" }),
|
|
325
|
+
" ",
|
|
326
|
+
/* @__PURE__ */ jsx(RelativeTime, { value: post.publishTime })
|
|
327
|
+
]
|
|
328
|
+
}
|
|
329
|
+
),
|
|
330
|
+
/* @__PURE__ */ jsxs(
|
|
331
|
+
Box,
|
|
332
|
+
{
|
|
333
|
+
sx: {
|
|
334
|
+
display: "flex",
|
|
335
|
+
justifyContent: "space-between",
|
|
336
|
+
alignItems: "center",
|
|
337
|
+
mt: 2,
|
|
338
|
+
pt: 2,
|
|
339
|
+
borderTop: "1px solid #eee"
|
|
340
|
+
},
|
|
341
|
+
children: [
|
|
342
|
+
hideAuthor === "1" || /* @__PURE__ */ jsx(AuthorInfo, { user: post.author, size: "sm", responsive: true }),
|
|
343
|
+
/* @__PURE__ */ jsxs(
|
|
344
|
+
Box,
|
|
345
|
+
{
|
|
346
|
+
sx: {
|
|
347
|
+
display: "flex",
|
|
348
|
+
alignItems: "center",
|
|
349
|
+
gap: 0.5,
|
|
350
|
+
color: "grey.500"
|
|
351
|
+
},
|
|
352
|
+
children: [
|
|
353
|
+
/* @__PURE__ */ jsx(ChatBubbleOutlineOutlinedIcon, { sx: { mt: 0.25, fontSize: 18, color: "grey.600" } }),
|
|
354
|
+
/* @__PURE__ */ jsx(Box, { component: "span", sx: { fontSize: 12 }, children: post.commentCount || 0 })
|
|
355
|
+
]
|
|
356
|
+
}
|
|
357
|
+
)
|
|
358
|
+
]
|
|
359
|
+
}
|
|
360
|
+
)
|
|
361
|
+
] })
|
|
362
|
+
] })
|
|
363
|
+
]
|
|
364
|
+
},
|
|
365
|
+
post.id
|
|
366
|
+
)
|
|
367
|
+
}
|
|
368
|
+
);
|
|
369
|
+
}
|
|
370
|
+
function BlogCardList({
|
|
371
|
+
posts,
|
|
372
|
+
loadMore,
|
|
373
|
+
hideAuthor,
|
|
374
|
+
boardId,
|
|
375
|
+
itemLinkTarget,
|
|
376
|
+
cardsLayout = "multiRow",
|
|
377
|
+
compactLayout,
|
|
378
|
+
loading = false,
|
|
379
|
+
...rest
|
|
380
|
+
}) {
|
|
381
|
+
const theme = useTheme();
|
|
382
|
+
const downLg = useMediaQuery(theme.breakpoints.down("md"));
|
|
383
|
+
const [containerRef, { width }] = useMeasure();
|
|
384
|
+
if (!posts) {
|
|
385
|
+
return null;
|
|
386
|
+
}
|
|
387
|
+
const capacity = Math.floor(width / (280 + 16));
|
|
388
|
+
const fewPosts = posts.length < capacity && !loading;
|
|
389
|
+
const singleRowLayout = cardsLayout === "singleRow" && !fewPosts;
|
|
390
|
+
const visiblePosts = singleRowLayout ? posts.slice(0, capacity) : posts;
|
|
391
|
+
let content = null;
|
|
392
|
+
if (loading) {
|
|
393
|
+
content = Array(capacity).fill("").map((item, index) => /* @__PURE__ */ jsx(
|
|
394
|
+
BlogCard,
|
|
395
|
+
{
|
|
396
|
+
post: item,
|
|
397
|
+
loading: true,
|
|
398
|
+
linkTarget: itemLinkTarget,
|
|
399
|
+
hideAuthor,
|
|
400
|
+
compactLayout
|
|
401
|
+
},
|
|
402
|
+
index
|
|
403
|
+
));
|
|
404
|
+
} else {
|
|
405
|
+
content = visiblePosts.map((item) => {
|
|
406
|
+
return /* @__PURE__ */ jsx(
|
|
407
|
+
BlogCard,
|
|
408
|
+
{
|
|
409
|
+
post: item,
|
|
410
|
+
linkTarget: itemLinkTarget,
|
|
411
|
+
hideAuthor,
|
|
412
|
+
compactLayout
|
|
413
|
+
},
|
|
414
|
+
item.id
|
|
415
|
+
);
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
return /* @__PURE__ */ jsx(Box, { ...rest, sx: [{}, ...Array.isArray(rest.sx) ? rest.sx : [rest.sx]], children: /* @__PURE__ */ jsx(
|
|
419
|
+
Box,
|
|
420
|
+
{
|
|
421
|
+
ref: containerRef,
|
|
422
|
+
sx: {
|
|
423
|
+
boxSizing: "border-box",
|
|
424
|
+
display: fewPosts && !downLg ? "flex" : "grid",
|
|
425
|
+
gridTemplateColumns: "repeat(auto-fit, minmax(280px, 1fr))",
|
|
426
|
+
gap: 2
|
|
427
|
+
},
|
|
428
|
+
children: content
|
|
429
|
+
}
|
|
430
|
+
) });
|
|
431
|
+
}
|
|
432
|
+
export default function BlogListWrapper({
|
|
433
|
+
variant = "list",
|
|
434
|
+
cardsLayout,
|
|
435
|
+
...rest
|
|
436
|
+
}) {
|
|
437
|
+
if (variant === "card") {
|
|
438
|
+
return /* @__PURE__ */ jsx(BlogCardList, { ...rest, cardsLayout });
|
|
439
|
+
}
|
|
440
|
+
return /* @__PURE__ */ jsx(BlogList, { ...rest });
|
|
441
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { BoxProps } from '@mui/material/Box';
|
|
2
3
|
interface CoverImageUploadProps extends Omit<BoxProps, 'onChange'> {
|
|
3
4
|
url?: string;
|
|
4
5
|
onChange: (url: string | null) => void;
|
|
@@ -13,6 +14,6 @@ export declare function CoverImage({ url, aspectRatio, width, sx, fetchpriority,
|
|
|
13
14
|
shadow?: boolean;
|
|
14
15
|
fallback?: React.ReactNode;
|
|
15
16
|
onClick?: () => void;
|
|
16
|
-
} & BoxProps): import("react
|
|
17
|
-
export declare function CoverImageUpload({ url, onChange, width, ...rest }: CoverImageUploadProps): import("react
|
|
17
|
+
} & BoxProps): import("react").JSX.Element;
|
|
18
|
+
export declare function CoverImageUpload({ url, onChange, width, ...rest }: CoverImageUploadProps): import("react").JSX.Element;
|
|
18
19
|
export {};
|