elseware-ui 2.31.13 → 2.31.15
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/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +51 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +51 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1508,7 +1508,7 @@ interface CommentItemProps {
|
|
|
1508
1508
|
onDislike?: (comment: CommentEntity) => void;
|
|
1509
1509
|
onReply?: (comment: CommentEntity, content: string) => Promise<void> | void;
|
|
1510
1510
|
onLoadReplies?: (comment: CommentEntity) => Promise<void> | void;
|
|
1511
|
-
onEdit?: (comment: CommentEntity) => void
|
|
1511
|
+
onEdit?: (comment: CommentEntity) => CommentEntity | void | Promise<CommentEntity | void>;
|
|
1512
1512
|
onDelete?: (comment: CommentEntity) => void;
|
|
1513
1513
|
onReport?: (comment: CommentEntity) => void;
|
|
1514
1514
|
}
|
|
@@ -1522,7 +1522,7 @@ interface CommentListProps {
|
|
|
1522
1522
|
onDislike?: (comment: CommentEntity) => void;
|
|
1523
1523
|
onReply?: (comment: CommentEntity, content: string) => Promise<void> | void;
|
|
1524
1524
|
onLoadReplies?: (comment: CommentEntity) => Promise<void> | void;
|
|
1525
|
-
onEdit?: (comment: CommentEntity) => void
|
|
1525
|
+
onEdit?: (comment: CommentEntity) => CommentEntity | void | Promise<CommentEntity | void>;
|
|
1526
1526
|
onDelete?: (comment: CommentEntity) => void;
|
|
1527
1527
|
onReport?: (comment: CommentEntity) => void;
|
|
1528
1528
|
}
|
|
@@ -1533,7 +1533,7 @@ interface CommentThreadProps {
|
|
|
1533
1533
|
loading?: boolean;
|
|
1534
1534
|
components?: CommentComponents;
|
|
1535
1535
|
config?: CommentThreadConfig;
|
|
1536
|
-
onEdit?: (comment: CommentEntity) => void
|
|
1536
|
+
onEdit?: (comment: CommentEntity) => CommentEntity | void | Promise<CommentEntity | void>;
|
|
1537
1537
|
onDelete?: (comment: CommentEntity) => void;
|
|
1538
1538
|
onReport?: (comment: CommentEntity) => void;
|
|
1539
1539
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1508,7 +1508,7 @@ interface CommentItemProps {
|
|
|
1508
1508
|
onDislike?: (comment: CommentEntity) => void;
|
|
1509
1509
|
onReply?: (comment: CommentEntity, content: string) => Promise<void> | void;
|
|
1510
1510
|
onLoadReplies?: (comment: CommentEntity) => Promise<void> | void;
|
|
1511
|
-
onEdit?: (comment: CommentEntity) => void
|
|
1511
|
+
onEdit?: (comment: CommentEntity) => CommentEntity | void | Promise<CommentEntity | void>;
|
|
1512
1512
|
onDelete?: (comment: CommentEntity) => void;
|
|
1513
1513
|
onReport?: (comment: CommentEntity) => void;
|
|
1514
1514
|
}
|
|
@@ -1522,7 +1522,7 @@ interface CommentListProps {
|
|
|
1522
1522
|
onDislike?: (comment: CommentEntity) => void;
|
|
1523
1523
|
onReply?: (comment: CommentEntity, content: string) => Promise<void> | void;
|
|
1524
1524
|
onLoadReplies?: (comment: CommentEntity) => Promise<void> | void;
|
|
1525
|
-
onEdit?: (comment: CommentEntity) => void
|
|
1525
|
+
onEdit?: (comment: CommentEntity) => CommentEntity | void | Promise<CommentEntity | void>;
|
|
1526
1526
|
onDelete?: (comment: CommentEntity) => void;
|
|
1527
1527
|
onReport?: (comment: CommentEntity) => void;
|
|
1528
1528
|
}
|
|
@@ -1533,7 +1533,7 @@ interface CommentThreadProps {
|
|
|
1533
1533
|
loading?: boolean;
|
|
1534
1534
|
components?: CommentComponents;
|
|
1535
1535
|
config?: CommentThreadConfig;
|
|
1536
|
-
onEdit?: (comment: CommentEntity) => void
|
|
1536
|
+
onEdit?: (comment: CommentEntity) => CommentEntity | void | Promise<CommentEntity | void>;
|
|
1537
1537
|
onDelete?: (comment: CommentEntity) => void;
|
|
1538
1538
|
onReport?: (comment: CommentEntity) => void;
|
|
1539
1539
|
}
|
package/dist/index.js
CHANGED
|
@@ -17994,6 +17994,7 @@ function CommentThread({
|
|
|
17994
17994
|
const [replyCache, setReplyCache] = React4.useState(
|
|
17995
17995
|
{}
|
|
17996
17996
|
);
|
|
17997
|
+
const replyCacheRef = React4.useRef(replyCache);
|
|
17997
17998
|
const ComposerComponent = components?.Composer ?? CommentComposer_default;
|
|
17998
17999
|
const resolvedConfig = {
|
|
17999
18000
|
...DEFAULT_COMMENT_THREAD_CONFIG,
|
|
@@ -18013,6 +18014,45 @@ function CommentThread({
|
|
|
18013
18014
|
}
|
|
18014
18015
|
loadComments();
|
|
18015
18016
|
}, [dataSource, resolvedConfig.commentsPerPage]);
|
|
18017
|
+
React4.useEffect(() => {
|
|
18018
|
+
replyCacheRef.current = replyCache;
|
|
18019
|
+
}, [replyCache]);
|
|
18020
|
+
React4.useEffect(() => {
|
|
18021
|
+
let cancelled = false;
|
|
18022
|
+
async function refreshLoadedReplies() {
|
|
18023
|
+
const parentIds = Object.keys(replyCacheRef.current);
|
|
18024
|
+
if (!parentIds.length) {
|
|
18025
|
+
return;
|
|
18026
|
+
}
|
|
18027
|
+
try {
|
|
18028
|
+
const entries = await Promise.all(
|
|
18029
|
+
parentIds.map(async (parentId) => {
|
|
18030
|
+
const result = await dataSource.getReplies(parentId, {
|
|
18031
|
+
limit: resolvedConfig.repliesPerPage
|
|
18032
|
+
});
|
|
18033
|
+
return [parentId, result.items];
|
|
18034
|
+
})
|
|
18035
|
+
);
|
|
18036
|
+
if (cancelled) {
|
|
18037
|
+
return;
|
|
18038
|
+
}
|
|
18039
|
+
setReplyCache((prev) => {
|
|
18040
|
+
const next = { ...prev };
|
|
18041
|
+
for (const [parentId, replies] of entries) {
|
|
18042
|
+
if (parentId in next) {
|
|
18043
|
+
next[parentId] = replies;
|
|
18044
|
+
}
|
|
18045
|
+
}
|
|
18046
|
+
return next;
|
|
18047
|
+
});
|
|
18048
|
+
} catch {
|
|
18049
|
+
}
|
|
18050
|
+
}
|
|
18051
|
+
void refreshLoadedReplies();
|
|
18052
|
+
return () => {
|
|
18053
|
+
cancelled = true;
|
|
18054
|
+
};
|
|
18055
|
+
}, [dataSource, resolvedConfig.repliesPerPage]);
|
|
18016
18056
|
function updateReplyCacheComment(cache, commentId, updater) {
|
|
18017
18057
|
const next = {};
|
|
18018
18058
|
for (const [parentId, replies] of Object.entries(cache)) {
|
|
@@ -18062,6 +18102,10 @@ function CommentThread({
|
|
|
18062
18102
|
);
|
|
18063
18103
|
}
|
|
18064
18104
|
}
|
|
18105
|
+
function updateCommentEverywhere(commentId, updater) {
|
|
18106
|
+
setComments((prev) => updateComment(prev, commentId, updater));
|
|
18107
|
+
setReplyCache((prev) => updateReplyCacheComment(prev, commentId, updater));
|
|
18108
|
+
}
|
|
18065
18109
|
async function handleReply(parentComment, content) {
|
|
18066
18110
|
const reply = await dataSource.createComment({
|
|
18067
18111
|
content,
|
|
@@ -18147,6 +18191,12 @@ function CommentThread({
|
|
|
18147
18191
|
);
|
|
18148
18192
|
}
|
|
18149
18193
|
}
|
|
18194
|
+
async function handleEditComment(comment) {
|
|
18195
|
+
const updatedComment = await onEdit?.(comment);
|
|
18196
|
+
if (updatedComment) {
|
|
18197
|
+
updateCommentEverywhere(updatedComment.id, () => updatedComment);
|
|
18198
|
+
}
|
|
18199
|
+
}
|
|
18150
18200
|
if (loading || isLoadingComments) {
|
|
18151
18201
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-6", children: "Loading comments..." });
|
|
18152
18202
|
}
|
|
@@ -18171,7 +18221,7 @@ function CommentThread({
|
|
|
18171
18221
|
onDislike: handleDislike,
|
|
18172
18222
|
onReply: handleReply,
|
|
18173
18223
|
onLoadReplies: handleLoadReplies,
|
|
18174
|
-
onEdit,
|
|
18224
|
+
onEdit: handleEditComment,
|
|
18175
18225
|
onDelete: handleDeleteComment,
|
|
18176
18226
|
onReport
|
|
18177
18227
|
}
|