elseware-ui 2.31.14 → 2.31.16
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 +5 -4
- package/dist/index.d.ts +5 -4
- package/dist/index.js +52 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +52 -3
- 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,8 @@ interface CommentThreadProps {
|
|
|
1533
1533
|
loading?: boolean;
|
|
1534
1534
|
components?: CommentComponents;
|
|
1535
1535
|
config?: CommentThreadConfig;
|
|
1536
|
-
|
|
1536
|
+
updatedComment?: CommentEntity | null;
|
|
1537
|
+
onEdit?: (comment: CommentEntity) => CommentEntity | void | Promise<CommentEntity | void>;
|
|
1537
1538
|
onDelete?: (comment: CommentEntity) => void;
|
|
1538
1539
|
onReport?: (comment: CommentEntity) => void;
|
|
1539
1540
|
}
|
|
@@ -1575,7 +1576,7 @@ interface CommentComponents {
|
|
|
1575
1576
|
RepliesToggle?: ComponentType<CommentRepliesToggleProps>;
|
|
1576
1577
|
}
|
|
1577
1578
|
|
|
1578
|
-
declare function CommentThread({ currentUser, dataSource, loading, components, config, onEdit, onDelete, onReport, }: CommentThreadProps): react_jsx_runtime.JSX.Element;
|
|
1579
|
+
declare function CommentThread({ currentUser, dataSource, loading, components, config, updatedComment, onEdit, onDelete, onReport, }: CommentThreadProps): react_jsx_runtime.JSX.Element;
|
|
1579
1580
|
|
|
1580
1581
|
declare function formatCommentDate(date: string, format?: "relative" | "absolute"): string;
|
|
1581
1582
|
|
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,8 @@ interface CommentThreadProps {
|
|
|
1533
1533
|
loading?: boolean;
|
|
1534
1534
|
components?: CommentComponents;
|
|
1535
1535
|
config?: CommentThreadConfig;
|
|
1536
|
-
|
|
1536
|
+
updatedComment?: CommentEntity | null;
|
|
1537
|
+
onEdit?: (comment: CommentEntity) => CommentEntity | void | Promise<CommentEntity | void>;
|
|
1537
1538
|
onDelete?: (comment: CommentEntity) => void;
|
|
1538
1539
|
onReport?: (comment: CommentEntity) => void;
|
|
1539
1540
|
}
|
|
@@ -1575,7 +1576,7 @@ interface CommentComponents {
|
|
|
1575
1576
|
RepliesToggle?: ComponentType<CommentRepliesToggleProps>;
|
|
1576
1577
|
}
|
|
1577
1578
|
|
|
1578
|
-
declare function CommentThread({ currentUser, dataSource, loading, components, config, onEdit, onDelete, onReport, }: CommentThreadProps): react_jsx_runtime.JSX.Element;
|
|
1579
|
+
declare function CommentThread({ currentUser, dataSource, loading, components, config, updatedComment, onEdit, onDelete, onReport, }: CommentThreadProps): react_jsx_runtime.JSX.Element;
|
|
1579
1580
|
|
|
1580
1581
|
declare function formatCommentDate(date: string, format?: "relative" | "absolute"): string;
|
|
1581
1582
|
|
package/dist/index.js
CHANGED
|
@@ -17985,6 +17985,7 @@ function CommentThread({
|
|
|
17985
17985
|
loading = false,
|
|
17986
17986
|
components,
|
|
17987
17987
|
config,
|
|
17988
|
+
updatedComment,
|
|
17988
17989
|
onEdit,
|
|
17989
17990
|
onDelete,
|
|
17990
17991
|
onReport
|
|
@@ -17994,6 +17995,7 @@ function CommentThread({
|
|
|
17994
17995
|
const [replyCache, setReplyCache] = React4.useState(
|
|
17995
17996
|
{}
|
|
17996
17997
|
);
|
|
17998
|
+
const replyCacheRef = React4.useRef(replyCache);
|
|
17997
17999
|
const ComposerComponent = components?.Composer ?? CommentComposer_default;
|
|
17998
18000
|
const resolvedConfig = {
|
|
17999
18001
|
...DEFAULT_COMMENT_THREAD_CONFIG,
|
|
@@ -18013,6 +18015,45 @@ function CommentThread({
|
|
|
18013
18015
|
}
|
|
18014
18016
|
loadComments();
|
|
18015
18017
|
}, [dataSource, resolvedConfig.commentsPerPage]);
|
|
18018
|
+
React4.useEffect(() => {
|
|
18019
|
+
replyCacheRef.current = replyCache;
|
|
18020
|
+
}, [replyCache]);
|
|
18021
|
+
React4.useEffect(() => {
|
|
18022
|
+
let cancelled = false;
|
|
18023
|
+
async function refreshLoadedReplies() {
|
|
18024
|
+
const parentIds = Object.keys(replyCacheRef.current);
|
|
18025
|
+
if (!parentIds.length) {
|
|
18026
|
+
return;
|
|
18027
|
+
}
|
|
18028
|
+
try {
|
|
18029
|
+
const entries = await Promise.all(
|
|
18030
|
+
parentIds.map(async (parentId) => {
|
|
18031
|
+
const result = await dataSource.getReplies(parentId, {
|
|
18032
|
+
limit: resolvedConfig.repliesPerPage
|
|
18033
|
+
});
|
|
18034
|
+
return [parentId, result.items];
|
|
18035
|
+
})
|
|
18036
|
+
);
|
|
18037
|
+
if (cancelled) {
|
|
18038
|
+
return;
|
|
18039
|
+
}
|
|
18040
|
+
setReplyCache((prev) => {
|
|
18041
|
+
const next = { ...prev };
|
|
18042
|
+
for (const [parentId, replies] of entries) {
|
|
18043
|
+
if (parentId in next) {
|
|
18044
|
+
next[parentId] = replies;
|
|
18045
|
+
}
|
|
18046
|
+
}
|
|
18047
|
+
return next;
|
|
18048
|
+
});
|
|
18049
|
+
} catch {
|
|
18050
|
+
}
|
|
18051
|
+
}
|
|
18052
|
+
void refreshLoadedReplies();
|
|
18053
|
+
return () => {
|
|
18054
|
+
cancelled = true;
|
|
18055
|
+
};
|
|
18056
|
+
}, [dataSource, resolvedConfig.repliesPerPage]);
|
|
18016
18057
|
function updateReplyCacheComment(cache, commentId, updater) {
|
|
18017
18058
|
const next = {};
|
|
18018
18059
|
for (const [parentId, replies] of Object.entries(cache)) {
|
|
@@ -18066,6 +18107,12 @@ function CommentThread({
|
|
|
18066
18107
|
setComments((prev) => updateComment(prev, commentId, updater));
|
|
18067
18108
|
setReplyCache((prev) => updateReplyCacheComment(prev, commentId, updater));
|
|
18068
18109
|
}
|
|
18110
|
+
React4.useEffect(() => {
|
|
18111
|
+
if (!updatedComment) {
|
|
18112
|
+
return;
|
|
18113
|
+
}
|
|
18114
|
+
updateCommentEverywhere(updatedComment.id, () => updatedComment);
|
|
18115
|
+
}, [updatedComment]);
|
|
18069
18116
|
async function handleReply(parentComment, content) {
|
|
18070
18117
|
const reply = await dataSource.createComment({
|
|
18071
18118
|
content,
|
|
@@ -18151,9 +18198,11 @@ function CommentThread({
|
|
|
18151
18198
|
);
|
|
18152
18199
|
}
|
|
18153
18200
|
}
|
|
18154
|
-
function handleEditComment(
|
|
18155
|
-
|
|
18156
|
-
|
|
18201
|
+
async function handleEditComment(comment) {
|
|
18202
|
+
const updatedComment2 = await onEdit?.(comment);
|
|
18203
|
+
if (updatedComment2) {
|
|
18204
|
+
updateCommentEverywhere(updatedComment2.id, () => updatedComment2);
|
|
18205
|
+
}
|
|
18157
18206
|
}
|
|
18158
18207
|
if (loading || isLoadingComments) {
|
|
18159
18208
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-6", children: "Loading comments..." });
|