@blocklet/discuss-kit-ux 2.6.13 → 2.6.14
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Fragment } from "react";
|
|
2
|
+
import { Fragment, useMemo } from "react";
|
|
3
3
|
import Box from "@mui/material/Box";
|
|
4
4
|
import Button from "@mui/material/Button";
|
|
5
5
|
import { NavigateNext as NavigateNextIcon } from "@mui/icons-material";
|
|
@@ -15,7 +15,9 @@ const LoadMoreButtonWrapper = styled(Box)`
|
|
|
15
15
|
function SegmentalList({ ...rest }) {
|
|
16
16
|
const { t } = useLocaleContext();
|
|
17
17
|
const {
|
|
18
|
-
state: {
|
|
18
|
+
state: { nextCursor, highlighted },
|
|
19
|
+
comments,
|
|
20
|
+
pinned,
|
|
19
21
|
autoCollapse,
|
|
20
22
|
allowCopyLink,
|
|
21
23
|
showProfileCard,
|
|
@@ -28,14 +30,46 @@ function SegmentalList({ ...rest }) {
|
|
|
28
30
|
togglePin,
|
|
29
31
|
loadMoreReplies,
|
|
30
32
|
api,
|
|
31
|
-
profileUrl
|
|
33
|
+
profileUrl,
|
|
34
|
+
renderDonation,
|
|
35
|
+
renderActions,
|
|
36
|
+
renderEditorPlugins,
|
|
37
|
+
enableAutoTranslate
|
|
32
38
|
} = useCommentsContext();
|
|
39
|
+
const sortedPinned = useMemo(
|
|
40
|
+
() => [...pinned].sort((a, b) => (b.pinnedAt?.getTime() ?? 0) - (a.pinnedAt?.getTime() ?? 0)),
|
|
41
|
+
[pinned]
|
|
42
|
+
);
|
|
33
43
|
if (!highlighted) {
|
|
34
44
|
return null;
|
|
35
45
|
}
|
|
36
46
|
const headIndex = comments.findIndex((item) => item.id === highlighted.head);
|
|
37
47
|
const hiddenComments = highlighted.position - comments.findIndex((item) => item.id === highlighted.id) + headIndex;
|
|
48
|
+
const renderComment = (comment) => /* @__PURE__ */ jsx(
|
|
49
|
+
Comment,
|
|
50
|
+
{
|
|
51
|
+
post: comment,
|
|
52
|
+
onDelete: deleteComment,
|
|
53
|
+
onContentUpdate: updateComment,
|
|
54
|
+
onRate: api.rate,
|
|
55
|
+
onUnrate: api.unrate,
|
|
56
|
+
onReply: reply,
|
|
57
|
+
onTogglePin: togglePin,
|
|
58
|
+
onLoadMoreReplies: loadMoreReplies,
|
|
59
|
+
autoCollapse,
|
|
60
|
+
allowCopyLink,
|
|
61
|
+
showProfileCard,
|
|
62
|
+
interactive,
|
|
63
|
+
renderDonation,
|
|
64
|
+
renderActions,
|
|
65
|
+
renderEditorPlugins,
|
|
66
|
+
enableAutoTranslate,
|
|
67
|
+
profileUrl
|
|
68
|
+
},
|
|
69
|
+
comment.id
|
|
70
|
+
);
|
|
38
71
|
return /* @__PURE__ */ jsxs("div", { ...rest, className: "comment-list", children: [
|
|
72
|
+
sortedPinned.map(renderComment),
|
|
39
73
|
comments.map((comment) => {
|
|
40
74
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
41
75
|
comment.id === highlighted?.id && hiddenComments > 0 && nextCursor && /* @__PURE__ */ jsx(LoadMoreButtonWrapper, { sx: { my: 4, textAlign: "center" }, children: /* @__PURE__ */ jsxs(
|
|
@@ -63,24 +97,7 @@ function SegmentalList({ ...rest }) {
|
|
|
63
97
|
]
|
|
64
98
|
}
|
|
65
99
|
) }),
|
|
66
|
-
|
|
67
|
-
Comment,
|
|
68
|
-
{
|
|
69
|
-
post: comment,
|
|
70
|
-
onDelete: deleteComment,
|
|
71
|
-
onContentUpdate: updateComment,
|
|
72
|
-
onRate: api.rate,
|
|
73
|
-
onUnrate: api.unrate,
|
|
74
|
-
onReply: reply,
|
|
75
|
-
onTogglePin: togglePin,
|
|
76
|
-
onLoadMoreReplies: loadMoreReplies,
|
|
77
|
-
autoCollapse,
|
|
78
|
-
allowCopyLink,
|
|
79
|
-
showProfileCard,
|
|
80
|
-
interactive,
|
|
81
|
-
profileUrl
|
|
82
|
-
}
|
|
83
|
-
)
|
|
100
|
+
renderComment(comment)
|
|
84
101
|
] }, comment.id);
|
|
85
102
|
}),
|
|
86
103
|
highlighted.nextCursor && /* @__PURE__ */ jsx(Box, { sx: { my: 2, textAlign: "center" }, children: /* @__PURE__ */ jsx(
|
|
@@ -120,6 +137,10 @@ export default function CommentList(props) {
|
|
|
120
137
|
enableAutoTranslate,
|
|
121
138
|
profileUrl
|
|
122
139
|
} = useCommentsContext();
|
|
140
|
+
const sortedPinned = useMemo(
|
|
141
|
+
() => [...pinned].sort((a, b) => (b.pinnedAt?.getTime() ?? 0) - (a.pinnedAt?.getTime() ?? 0)),
|
|
142
|
+
[pinned]
|
|
143
|
+
);
|
|
123
144
|
if (highlighted) {
|
|
124
145
|
return /* @__PURE__ */ jsx(SegmentalList, { ...props });
|
|
125
146
|
}
|
|
@@ -147,9 +168,8 @@ export default function CommentList(props) {
|
|
|
147
168
|
},
|
|
148
169
|
comment.id
|
|
149
170
|
);
|
|
150
|
-
const sortedPinned = pinned.sort((a, b) => (b.pinnedAt?.getTime() ?? 0) - (a.pinnedAt?.getTime() ?? 0));
|
|
151
171
|
return /* @__PURE__ */ jsxs("div", { ...props, children: [
|
|
152
|
-
|
|
172
|
+
sortedPinned.map(renderComment),
|
|
153
173
|
renderComments ? renderComments({ order, comments, renderComment }) : comments?.map(renderComment),
|
|
154
174
|
nextCursor && /* @__PURE__ */ jsx(Box, { sx: { my: 2, textAlign: "center" }, children: /* @__PURE__ */ jsx(
|
|
155
175
|
Button,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/discuss-kit-ux",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.14",
|
|
4
4
|
"files": [
|
|
5
5
|
"dist"
|
|
6
6
|
],
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"unstated-next": "^1.1.0",
|
|
48
48
|
"url-join": "^4.0.1",
|
|
49
49
|
"zustand": "^4.5.5",
|
|
50
|
-
"@blocklet/
|
|
51
|
-
"@blocklet/
|
|
50
|
+
"@blocklet/labels": "2.6.14",
|
|
51
|
+
"@blocklet/editor": "2.6.14"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@arcblock/did-connect-react": "^3.1.5",
|