@blocklet/discuss-kit-ux 2.4.36 → 2.4.38
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 +14 -21
- 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,160 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, IconButton, Skeleton } from "@mui/material";
|
|
3
|
+
import UploadIcon from "virtual:icons/material-symbols/upload";
|
|
4
|
+
import { useState } from "react";
|
|
5
|
+
import { DeleteOutlineOutlined as DeleteOutlineOutlinedIcon } from "@mui/icons-material";
|
|
6
|
+
import { UploaderTrigger, getUploadedImageUrl } from "../uploader/index.mjs";
|
|
7
|
+
export function CoverImage({
|
|
8
|
+
url,
|
|
9
|
+
aspectRatio = 16 / 9,
|
|
10
|
+
width = 320,
|
|
11
|
+
sx,
|
|
12
|
+
fetchpriority = "auto",
|
|
13
|
+
loading = "eager",
|
|
14
|
+
shadow = false,
|
|
15
|
+
fallback,
|
|
16
|
+
onClick,
|
|
17
|
+
...rest
|
|
18
|
+
}) {
|
|
19
|
+
const [loaded, setLoaded] = useState(false);
|
|
20
|
+
const [errored, setErrored] = useState(false);
|
|
21
|
+
return /* @__PURE__ */ jsxs(
|
|
22
|
+
Box,
|
|
23
|
+
{
|
|
24
|
+
sx: [
|
|
25
|
+
{
|
|
26
|
+
height: 0,
|
|
27
|
+
pt: `${100 / aspectRatio}%`,
|
|
28
|
+
overflow: "hidden",
|
|
29
|
+
position: "relative",
|
|
30
|
+
borderRadius: 1,
|
|
31
|
+
...shadow && { boxShadow: "rgb(0 0 0 / 12%) 0px 8px 30px" },
|
|
32
|
+
// https://stackoverflow.com/questions/49066011/overflow-hidden-with-border-radius-not-working-on-safari
|
|
33
|
+
transform: "translateZ(0)"
|
|
34
|
+
},
|
|
35
|
+
...Array.isArray(sx) ? sx : [sx]
|
|
36
|
+
],
|
|
37
|
+
...rest,
|
|
38
|
+
children: [
|
|
39
|
+
(!loaded || !url) && /* @__PURE__ */ jsx(
|
|
40
|
+
Skeleton,
|
|
41
|
+
{
|
|
42
|
+
variant: "rectangular",
|
|
43
|
+
animation: "wave",
|
|
44
|
+
sx: {
|
|
45
|
+
position: "absolute",
|
|
46
|
+
top: 0,
|
|
47
|
+
left: 0,
|
|
48
|
+
width: "100%",
|
|
49
|
+
height: "100%"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
!!url && // add box because img can't add :after
|
|
54
|
+
/* @__PURE__ */ jsx(Box, { onClick: () => onClick?.(), sx: { cursor: onClick ? "pointer" : "inherit" }, children: /* @__PURE__ */ jsx(
|
|
55
|
+
"img",
|
|
56
|
+
{
|
|
57
|
+
src: url ? getUploadedImageUrl(url, width) : "",
|
|
58
|
+
loading,
|
|
59
|
+
fetchpriority,
|
|
60
|
+
style: {
|
|
61
|
+
position: "absolute",
|
|
62
|
+
top: 0,
|
|
63
|
+
left: 0,
|
|
64
|
+
width: "100%",
|
|
65
|
+
height: "100%",
|
|
66
|
+
objectFit: "cover",
|
|
67
|
+
objectPosition: "center",
|
|
68
|
+
visibility: loaded ? "visible" : "hidden"
|
|
69
|
+
},
|
|
70
|
+
alt: "cover",
|
|
71
|
+
onLoad: () => setLoaded(true),
|
|
72
|
+
onError: () => setErrored(true)
|
|
73
|
+
}
|
|
74
|
+
) }),
|
|
75
|
+
(!url || errored) && /* @__PURE__ */ jsx(
|
|
76
|
+
Box,
|
|
77
|
+
{
|
|
78
|
+
onClick: () => onClick?.(),
|
|
79
|
+
sx: {
|
|
80
|
+
cursor: onClick ? "pointer" : "inherit",
|
|
81
|
+
position: "absolute",
|
|
82
|
+
top: 0,
|
|
83
|
+
left: 0,
|
|
84
|
+
width: "100%",
|
|
85
|
+
height: "100%"
|
|
86
|
+
},
|
|
87
|
+
children: fallback
|
|
88
|
+
}
|
|
89
|
+
)
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
export function CoverImageUpload({ url, onChange, width, ...rest }) {
|
|
95
|
+
return /* @__PURE__ */ jsx(Box, { ...rest, children: /* @__PURE__ */ jsxs(
|
|
96
|
+
UploaderTrigger,
|
|
97
|
+
{
|
|
98
|
+
onChange: ({ response }) => {
|
|
99
|
+
const filename = response?.data?.filename;
|
|
100
|
+
onChange(`/${filename}`);
|
|
101
|
+
},
|
|
102
|
+
children: [
|
|
103
|
+
/* @__PURE__ */ jsx(
|
|
104
|
+
Box,
|
|
105
|
+
{
|
|
106
|
+
sx: {
|
|
107
|
+
display: url ? "none" : "block",
|
|
108
|
+
position: "relative",
|
|
109
|
+
height: 0,
|
|
110
|
+
pt: "56%",
|
|
111
|
+
overflow: "hidden",
|
|
112
|
+
borderRadius: 1,
|
|
113
|
+
bgcolor: "grey.300",
|
|
114
|
+
cursor: "pointer"
|
|
115
|
+
},
|
|
116
|
+
children: /* @__PURE__ */ jsx(
|
|
117
|
+
Box,
|
|
118
|
+
{
|
|
119
|
+
sx: {
|
|
120
|
+
position: "absolute",
|
|
121
|
+
top: "50%",
|
|
122
|
+
left: "50%",
|
|
123
|
+
transform: "translate(-50%, -50%)",
|
|
124
|
+
color: "grey.500"
|
|
125
|
+
},
|
|
126
|
+
children: /* @__PURE__ */ jsx(UploadIcon, { style: { fontSize: 24 } })
|
|
127
|
+
}
|
|
128
|
+
)
|
|
129
|
+
}
|
|
130
|
+
),
|
|
131
|
+
/* @__PURE__ */ jsxs(
|
|
132
|
+
Box,
|
|
133
|
+
{
|
|
134
|
+
sx: {
|
|
135
|
+
display: url ? "block" : "none",
|
|
136
|
+
position: "relative",
|
|
137
|
+
cursor: "pointer",
|
|
138
|
+
"&:hover .cover-image-delete": { display: "block" }
|
|
139
|
+
},
|
|
140
|
+
children: [
|
|
141
|
+
/* @__PURE__ */ jsx(CoverImage, { url, width }),
|
|
142
|
+
/* @__PURE__ */ jsx(Box, { sx: { position: "absolute", top: 8, right: 8, display: "none" }, className: "cover-image-delete", children: /* @__PURE__ */ jsx(
|
|
143
|
+
IconButton,
|
|
144
|
+
{
|
|
145
|
+
color: "inherit",
|
|
146
|
+
sx: { ml: 1, bgcolor: "grey.100", borderRadius: 1, "&:hover": { bgcolor: "grey.200" } },
|
|
147
|
+
onClick: (e) => {
|
|
148
|
+
e.stopPropagation();
|
|
149
|
+
onChange(null);
|
|
150
|
+
},
|
|
151
|
+
children: /* @__PURE__ */ jsx(DeleteOutlineOutlinedIcon, { sx: { fontSize: 18, color: "grey.700" } })
|
|
152
|
+
}
|
|
153
|
+
) })
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
)
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
) });
|
|
160
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { BoxProps } from '@mui/material';
|
|
2
3
|
interface Props extends Omit<BoxProps, 'onChange'> {
|
|
3
4
|
slug: string;
|
|
4
5
|
onChange: (slug: string) => void;
|
|
5
6
|
prefix?: string;
|
|
6
7
|
}
|
|
7
|
-
export declare function PostPermaLink({ slug, onChange, prefix, ...rest }: Props): import("react
|
|
8
|
+
export declare function PostPermaLink({ slug, onChange, prefix, ...rest }: Props): import("react").JSX.Element;
|
|
8
9
|
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, InputBase, IconButton } from "@mui/material";
|
|
3
|
+
import { ContentCopy as ContentCopyIcon } from "@mui/icons-material";
|
|
4
|
+
import { joinURL } from "ufo";
|
|
5
|
+
import { discussKitMountPoint, copy } from "../utils.mjs";
|
|
6
|
+
const baseURL = joinURL(window.location.origin, discussKitMountPoint || "");
|
|
7
|
+
const SLUG_VALIDATION_REGEX = /^[a-zA-Z0-9-]+$/;
|
|
8
|
+
export function PostPermaLink({ slug, onChange, prefix = "blog", ...rest }) {
|
|
9
|
+
return /* @__PURE__ */ jsx(Box, { ...rest, className: "blog-permalink-container", children: /* @__PURE__ */ jsxs(
|
|
10
|
+
Box,
|
|
11
|
+
{
|
|
12
|
+
component: "form",
|
|
13
|
+
sx: {
|
|
14
|
+
display: "flex",
|
|
15
|
+
alignItems: "center",
|
|
16
|
+
border: "1px solid #bbb",
|
|
17
|
+
borderRadius: 1,
|
|
18
|
+
overflow: "hidden"
|
|
19
|
+
},
|
|
20
|
+
children: [
|
|
21
|
+
/* @__PURE__ */ jsx(
|
|
22
|
+
Box,
|
|
23
|
+
{
|
|
24
|
+
sx: {
|
|
25
|
+
display: "flex",
|
|
26
|
+
alignItems: "center",
|
|
27
|
+
width: 140,
|
|
28
|
+
alignSelf: "stretch",
|
|
29
|
+
px: 1.25,
|
|
30
|
+
bgcolor: "grey.100"
|
|
31
|
+
},
|
|
32
|
+
children: /* @__PURE__ */ jsx(
|
|
33
|
+
Box,
|
|
34
|
+
{
|
|
35
|
+
component: "input",
|
|
36
|
+
value: joinURL(baseURL, prefix),
|
|
37
|
+
readOnly: true,
|
|
38
|
+
sx: {
|
|
39
|
+
width: 1,
|
|
40
|
+
overflow: "hidden",
|
|
41
|
+
whiteSpace: "nowrap",
|
|
42
|
+
border: 0,
|
|
43
|
+
bgcolor: "inherit",
|
|
44
|
+
outline: "none",
|
|
45
|
+
fontSize: 14,
|
|
46
|
+
color: "text.secondary"
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
),
|
|
52
|
+
/* @__PURE__ */ jsx(
|
|
53
|
+
InputBase,
|
|
54
|
+
{
|
|
55
|
+
value: slug,
|
|
56
|
+
onChange: (e) => onChange(e.target.value),
|
|
57
|
+
onKeyDown: (event) => {
|
|
58
|
+
if (!SLUG_VALIDATION_REGEX.test(event.key)) {
|
|
59
|
+
event.preventDefault();
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
sx: { ml: 0.5, flex: 1, bgcolor: "transparent", input: { py: 1, fontSize: 14 } }
|
|
63
|
+
}
|
|
64
|
+
),
|
|
65
|
+
/* @__PURE__ */ jsx(
|
|
66
|
+
IconButton,
|
|
67
|
+
{
|
|
68
|
+
sx: { px: 1 },
|
|
69
|
+
onClick: () => {
|
|
70
|
+
copy(joinURL(baseURL, prefix, slug));
|
|
71
|
+
},
|
|
72
|
+
children: /* @__PURE__ */ jsx(ContentCopyIcon, { sx: { fontSize: 18 } })
|
|
73
|
+
}
|
|
74
|
+
)
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
) });
|
|
78
|
+
}
|
|
File without changes
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
interface ButtonItem {
|
|
2
3
|
id: string;
|
|
3
4
|
title: string;
|
|
@@ -13,5 +14,5 @@ interface Props {
|
|
|
13
14
|
allButton?: boolean;
|
|
14
15
|
urlParams?: boolean;
|
|
15
16
|
}
|
|
16
|
-
export default function ButtonGroup({ data, theme, urlName, defaultButton, urlParams, allButton, onSelectTab, type, ...rest }: Props): import("react
|
|
17
|
+
export default function ButtonGroup({ data, theme, urlName, defaultButton, urlParams, allButton, onSelectTab, type, ...rest }: Props): import("react").JSX.Element;
|
|
17
18
|
export {};
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import useMediaQuery from "@mui/material/useMediaQuery";
|
|
3
|
+
import { Box, Button } from "@mui/material";
|
|
4
|
+
import { css } from "@emotion/css";
|
|
5
|
+
import { useEffect, useState } from "react";
|
|
6
|
+
import IconButton from "@mui/material/IconButton";
|
|
7
|
+
import { Link, useNavigate, useParams, useSearchParams } from "react-router-dom";
|
|
8
|
+
import { BorderColorOutlined as BorderColorOutlinedIcon } from "@mui/icons-material";
|
|
9
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
10
|
+
import { AccessControl } from "../authz/index.mjs";
|
|
11
|
+
export default function ButtonGroup({
|
|
12
|
+
data,
|
|
13
|
+
theme = "dark",
|
|
14
|
+
urlName,
|
|
15
|
+
defaultButton,
|
|
16
|
+
urlParams = true,
|
|
17
|
+
allButton = true,
|
|
18
|
+
onSelectTab,
|
|
19
|
+
type,
|
|
20
|
+
...rest
|
|
21
|
+
}) {
|
|
22
|
+
const { t } = useLocaleContext();
|
|
23
|
+
const downSm = useMediaQuery((mainTheme) => mainTheme.breakpoints.down("sm"));
|
|
24
|
+
const navigate = useNavigate();
|
|
25
|
+
const [searchParams, setSearchParams] = useSearchParams();
|
|
26
|
+
const { boardId } = useParams();
|
|
27
|
+
const selectedString = searchParams.get(urlName);
|
|
28
|
+
const dataWithDefault = defaultButton && data?.length > 0 ? [defaultButton, ...data] : data;
|
|
29
|
+
const selectedArray = selectedString !== null && selectedString !== "" ? selectedString.split(",") : dataWithDefault?.map((item) => item.id);
|
|
30
|
+
const [selectTab, setSelectTab] = useState(urlParams ? selectedArray : [boardId]);
|
|
31
|
+
const [selectAll, setSelectAll] = useState(false);
|
|
32
|
+
const updateUrl = (url, newSelectTab) => {
|
|
33
|
+
const formatNewSelectTab = newSelectTab.filter(Boolean);
|
|
34
|
+
if (urlParams) {
|
|
35
|
+
setSearchParams({
|
|
36
|
+
...searchParams,
|
|
37
|
+
[url]: formatNewSelectTab.join(",")
|
|
38
|
+
});
|
|
39
|
+
} else if (formatNewSelectTab.length === 0) {
|
|
40
|
+
navigate(`/${type}`);
|
|
41
|
+
} else {
|
|
42
|
+
navigate(`/${type}/boards/${formatNewSelectTab.join(",")}`);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const handleClick = (item) => {
|
|
46
|
+
setSelectTab([item.id]);
|
|
47
|
+
updateUrl(urlName, [item.id]);
|
|
48
|
+
};
|
|
49
|
+
const handleSelectAll = () => {
|
|
50
|
+
setSelectAll((prevSelectAll) => {
|
|
51
|
+
const newSelectAll = !prevSelectAll;
|
|
52
|
+
const newSelectTab = newSelectAll ? dataWithDefault?.map((item) => item.id) : [];
|
|
53
|
+
setSelectTab(newSelectTab);
|
|
54
|
+
updateUrl(urlName, [""]);
|
|
55
|
+
return newSelectAll;
|
|
56
|
+
});
|
|
57
|
+
};
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
if (JSON.stringify(selectedArray) !== JSON.stringify(selectTab)) {
|
|
60
|
+
if (urlParams) {
|
|
61
|
+
setSelectTab(selectedArray || []);
|
|
62
|
+
} else if (boardId) {
|
|
63
|
+
if (data?.find((item) => item.id === boardId) || boardId === "default") {
|
|
64
|
+
setSelectTab([boardId]);
|
|
65
|
+
} else {
|
|
66
|
+
navigate(`/${type}/`);
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
setSelectTab(dataWithDefault?.map((item) => item.id));
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}, [data, boardId]);
|
|
73
|
+
useEffect(() => {
|
|
74
|
+
if (urlParams) {
|
|
75
|
+
if (selectedString === null || selectedString === "") {
|
|
76
|
+
setSelectAll(true);
|
|
77
|
+
} else if (selectTab?.length === dataWithDefault?.length) {
|
|
78
|
+
setSelectAll(true);
|
|
79
|
+
} else {
|
|
80
|
+
setSelectAll(false);
|
|
81
|
+
}
|
|
82
|
+
} else if (boardId) {
|
|
83
|
+
setSelectAll(false);
|
|
84
|
+
} else {
|
|
85
|
+
setSelectAll(true);
|
|
86
|
+
}
|
|
87
|
+
if (onSelectTab) onSelectTab(selectTab);
|
|
88
|
+
}, [selectTab, selectedArray, boardId]);
|
|
89
|
+
return (
|
|
90
|
+
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
91
|
+
/* @__PURE__ */ jsxs(Box, { className: Group, children: [
|
|
92
|
+
/* @__PURE__ */ jsxs(
|
|
93
|
+
Box,
|
|
94
|
+
{
|
|
95
|
+
sx: {
|
|
96
|
+
bgcolor: theme === "dark" ? "#F9FAFB" : "",
|
|
97
|
+
width: "fit-content",
|
|
98
|
+
maxWidth: "calc(100% - 16px)",
|
|
99
|
+
borderRadius: "99999px",
|
|
100
|
+
borderTopRightRadius: downSm ? 0 : "99999px",
|
|
101
|
+
borderBottomRightRadius: downSm ? 0 : "99999px",
|
|
102
|
+
overflow: "scroll",
|
|
103
|
+
whiteSpace: "nowrap",
|
|
104
|
+
mr: 2
|
|
105
|
+
},
|
|
106
|
+
children: [
|
|
107
|
+
allButton && /* @__PURE__ */ jsx(
|
|
108
|
+
Button,
|
|
109
|
+
{
|
|
110
|
+
onClick: handleSelectAll,
|
|
111
|
+
sx: {
|
|
112
|
+
backgroundColor: selectAll ? "#ffffff" : "",
|
|
113
|
+
color: selectAll ? "#030712" : "#4b5563",
|
|
114
|
+
border: selectAll ? "1px solid #e5e7eb!important" : "1px solid transparent"
|
|
115
|
+
},
|
|
116
|
+
...rest,
|
|
117
|
+
children: t("all")
|
|
118
|
+
}
|
|
119
|
+
),
|
|
120
|
+
dataWithDefault?.map((item, index) => {
|
|
121
|
+
const isActive = urlParams ? !selectAll && selectTab?.includes(item.id) : boardId === item.id;
|
|
122
|
+
return /* @__PURE__ */ jsx(
|
|
123
|
+
Button,
|
|
124
|
+
{
|
|
125
|
+
onClick: () => handleClick(item),
|
|
126
|
+
sx: {
|
|
127
|
+
...isActive && {
|
|
128
|
+
backgroundColor: "#ffffff",
|
|
129
|
+
color: "#030712",
|
|
130
|
+
border: "1px solid #e5e7eb!important"
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
...rest,
|
|
134
|
+
children: /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center" }, children: [
|
|
135
|
+
item?.icon,
|
|
136
|
+
" ",
|
|
137
|
+
item?.title
|
|
138
|
+
] })
|
|
139
|
+
},
|
|
140
|
+
index
|
|
141
|
+
);
|
|
142
|
+
})
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
),
|
|
146
|
+
urlName !== "type" && /* @__PURE__ */ jsx(AccessControl, { roles: ["admin", "owner"], children: /* @__PURE__ */ jsx(
|
|
147
|
+
IconButton,
|
|
148
|
+
{
|
|
149
|
+
component: Link,
|
|
150
|
+
color: "inherit",
|
|
151
|
+
size: "small",
|
|
152
|
+
to: `/boards?type=${type}`,
|
|
153
|
+
sx: { color: "grey.500" },
|
|
154
|
+
children: /* @__PURE__ */ jsx(BorderColorOutlinedIcon, { sx: { fontSize: 16 } })
|
|
155
|
+
}
|
|
156
|
+
) })
|
|
157
|
+
] })
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
const Group = css`
|
|
161
|
+
display: flex;
|
|
162
|
+
flex-direction: row;
|
|
163
|
+
.MuiButtonBase-root {
|
|
164
|
+
border-radius: 9999px;
|
|
165
|
+
color: #4b5563;
|
|
166
|
+
margin: 5px 8px 5px 5px;
|
|
167
|
+
padding: 5px 12px;
|
|
168
|
+
line-height: 22px;
|
|
169
|
+
font-size: 13px;
|
|
170
|
+
border: 1px solid transparent;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.MuiButtonBase-root:last-of-type {
|
|
174
|
+
margin-right: 0;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.MuiButtonBase-root:first-of-type {
|
|
178
|
+
margin-left: 0;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
.MuiButtonBase-root:hover {
|
|
182
|
+
background-color: #ffffff;
|
|
183
|
+
color: #030712;
|
|
184
|
+
border: 1px solid #e5e7eb;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
* {
|
|
188
|
+
scrollbar-width: none; /* Firefox */
|
|
189
|
+
-ms-overflow-style: none; /* IE and Edge */
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
*::-webkit-scrollbar {
|
|
193
|
+
display: none; /* Chrome, Safari and Opera */
|
|
194
|
+
}
|
|
195
|
+
`;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as ButtonGroup } from "./button-group.mjs";
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { Chat } from './types';
|
|
2
3
|
interface Props {
|
|
3
4
|
chat: Chat;
|
|
4
5
|
size?: 'sm' | 'normal';
|
|
5
6
|
children?: React.ReactNode;
|
|
6
7
|
}
|
|
7
|
-
export default function ChannelGroup({ size, chat, children, ...rest }: Props): import("react
|
|
8
|
+
export default function ChannelGroup({ size, chat, children, ...rest }: Props): import("react").JSX.Element;
|
|
8
9
|
export {};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import Box from "@mui/material/Box";
|
|
3
|
+
import { amber } from "@mui/material/colors";
|
|
4
|
+
import UsersGroupIcon from "virtual:icons/tabler/users-group";
|
|
5
|
+
export default function ChannelGroup({ size = "normal", chat, children, ...rest }) {
|
|
6
|
+
const sm = size === "sm";
|
|
7
|
+
const iconSize = sm ? 40 : 48;
|
|
8
|
+
return /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", gap: 1, fontSize: 14 }, ...rest, children: [
|
|
9
|
+
/* @__PURE__ */ jsx(
|
|
10
|
+
Box,
|
|
11
|
+
{
|
|
12
|
+
sx: {
|
|
13
|
+
display: "flex",
|
|
14
|
+
justifyContent: "center",
|
|
15
|
+
alignItems: "center",
|
|
16
|
+
color: "#fff",
|
|
17
|
+
bgcolor: "rgba(254, 244, 199, 1)",
|
|
18
|
+
width: iconSize,
|
|
19
|
+
height: iconSize,
|
|
20
|
+
p: 0.8,
|
|
21
|
+
borderRadius: "100%"
|
|
22
|
+
},
|
|
23
|
+
children: /* @__PURE__ */ jsx(Box, { component: UsersGroupIcon, sx: { fontSize: 16, color: amber[700], width: iconSize } })
|
|
24
|
+
}
|
|
25
|
+
),
|
|
26
|
+
/* @__PURE__ */ jsxs(Box, { sx: { display: "flex", flexDirection: "column", height: "100%", justifyContent: "space-between" }, children: [
|
|
27
|
+
/* @__PURE__ */ jsx(
|
|
28
|
+
Box,
|
|
29
|
+
{
|
|
30
|
+
sx: {
|
|
31
|
+
lineHeight: 1.5,
|
|
32
|
+
display: "flex",
|
|
33
|
+
alignItems: "center"
|
|
34
|
+
},
|
|
35
|
+
children: /* @__PURE__ */ jsx(Box, { component: "span", sx: { fontWeight: "bold", wordBreak: "break-word" }, children: chat?.name })
|
|
36
|
+
}
|
|
37
|
+
),
|
|
38
|
+
children && /* @__PURE__ */ jsx(Box, { children })
|
|
39
|
+
] })
|
|
40
|
+
] });
|
|
41
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Emitter } from 'mitt';
|
|
2
|
-
import { User } from '../../types';
|
|
3
|
-
import { Chat, Message, Channel, ChannelUpdatePayload } from './types';
|
|
2
|
+
import type { User } from '../../types';
|
|
3
|
+
import type { Chat, Message, Channel, ChannelUpdatePayload } from './types';
|
|
4
4
|
type Events = {
|
|
5
5
|
message: {
|
|
6
6
|
chatId: string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import mitt from "mitt";
|
|
2
|
+
export default class ChatClient {
|
|
3
|
+
// @ts-ignore FIXME: @wangqi
|
|
4
|
+
emitter = mitt();
|
|
5
|
+
// init: () => ChatInitialState;
|
|
6
|
+
async init() {
|
|
7
|
+
const chats = await this.fetchChats();
|
|
8
|
+
return { chats };
|
|
9
|
+
}
|
|
10
|
+
destroy() {
|
|
11
|
+
this.emitter.all.clear();
|
|
12
|
+
}
|
|
13
|
+
onMessage(callback) {
|
|
14
|
+
this.emitter.on("message", callback);
|
|
15
|
+
return () => this.emitter.off("message", callback);
|
|
16
|
+
}
|
|
17
|
+
onJoinChannel(callback) {
|
|
18
|
+
this.emitter.on("joinChannel", callback);
|
|
19
|
+
return () => this.emitter.off("joinChannel", callback);
|
|
20
|
+
}
|
|
21
|
+
onLeaveChannel(callback) {
|
|
22
|
+
this.emitter.on("leaveChannel", callback);
|
|
23
|
+
return () => this.emitter.off("leaveChannel", callback);
|
|
24
|
+
}
|
|
25
|
+
onDeleteChannel(callback) {
|
|
26
|
+
this.emitter.on("deleteChannel", callback);
|
|
27
|
+
return () => this.emitter.off("deleteChannel", callback);
|
|
28
|
+
}
|
|
29
|
+
onUpdateLastAckTime(callback) {
|
|
30
|
+
this.emitter.on("updateLastAckTime", callback);
|
|
31
|
+
return () => this.emitter.off("updateLastAckTime", callback);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
interface Props {
|
|
2
3
|
}
|
|
3
|
-
export default function ChatHeaderAddon({ ...rest }: Props): import("react
|
|
4
|
+
export default function ChatHeaderAddon({ ...rest }: Props): import("react").JSX.Element | null;
|
|
4
5
|
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Link } from "react-router-dom";
|
|
3
|
+
import { Badge } from "@mui/material";
|
|
4
|
+
import { AddonButton } from "@arcblock/ux/lib/Header/addon-button";
|
|
5
|
+
import MessageCircleIcon from "virtual:icons/tabler/message-circle";
|
|
6
|
+
import { useUnreadNotification } from "./unread-notification.mjs";
|
|
7
|
+
import preferences from "../../preferences.mjs";
|
|
8
|
+
export default function ChatHeaderAddon({ ...rest }) {
|
|
9
|
+
const { unread, unreadMessageCount } = useUnreadNotification();
|
|
10
|
+
if (!preferences.enableNotificationBadge || !preferences.chatEnabled) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return (
|
|
14
|
+
// @ts-expect-error
|
|
15
|
+
/* @__PURE__ */ jsx(
|
|
16
|
+
AddonButton,
|
|
17
|
+
{
|
|
18
|
+
size: "medium",
|
|
19
|
+
icon: /* @__PURE__ */ jsx(Badge, { color: "error", invisible: !unread, badgeContent: unreadMessageCount, children: /* @__PURE__ */ jsx(MessageCircleIcon, {}) }),
|
|
20
|
+
...rest,
|
|
21
|
+
component: Link,
|
|
22
|
+
to: "/chat"
|
|
23
|
+
}
|
|
24
|
+
)
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
1
2
|
import { SxProps } from '@mui/material';
|
|
2
3
|
interface ChatProps {
|
|
3
4
|
sx: SxProps;
|
|
4
5
|
}
|
|
5
|
-
export default function ChatInWallet({ sx, ...rest }: ChatProps): import("react
|
|
6
|
+
export default function ChatInWallet({ sx, ...rest }: ChatProps): import("react").JSX.Element;
|
|
6
7
|
export {};
|