elseware-ui 2.31.16 → 2.31.17
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/LICENSE +20 -20
- package/README.md +98 -98
- package/dist/index.d.mts +1496 -1480
- package/dist/index.d.ts +1496 -1480
- package/dist/index.js +249 -193
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +240 -194
- package/dist/index.mjs.map +1 -1
- package/package.json +110 -110
package/dist/index.mjs
CHANGED
|
@@ -3104,7 +3104,7 @@ var ShapeSwitch = () => {
|
|
|
3104
3104
|
{
|
|
3105
3105
|
value: currentShape,
|
|
3106
3106
|
onChange: handleChange,
|
|
3107
|
-
className: "\n px-3 py-2 rounded-md border border-gray-300\n bg-white dark:bg-gray-800\n text-sm shadow-sm\n focus:outline-none\n ",
|
|
3107
|
+
className: "\r\n px-3 py-2 rounded-md border border-gray-300\r\n bg-white dark:bg-gray-800\r\n text-sm shadow-sm\r\n focus:outline-none\r\n ",
|
|
3108
3108
|
children: Object.keys(Shape).map((shape) => /* @__PURE__ */ jsx("option", { value: shape, children: shape }, shape))
|
|
3109
3109
|
}
|
|
3110
3110
|
) });
|
|
@@ -16098,7 +16098,7 @@ function MarkdownTOC({ title = "Table of Contents" }) {
|
|
|
16098
16098
|
/* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
|
|
16099
16099
|
"h2",
|
|
16100
16100
|
{
|
|
16101
|
-
className: "\n text-sm\n font-semibold\n uppercase\n tracking-wide\n text-gray-900\n dark:text-gray-100\n ",
|
|
16101
|
+
className: "\r\n text-sm\r\n font-semibold\r\n uppercase\r\n tracking-wide\r\n text-gray-900\r\n dark:text-gray-100\r\n ",
|
|
16102
16102
|
children: title
|
|
16103
16103
|
}
|
|
16104
16104
|
) }),
|
|
@@ -17093,6 +17093,7 @@ var Menu = ({
|
|
|
17093
17093
|
badge: item.badge,
|
|
17094
17094
|
to: item.to,
|
|
17095
17095
|
navigate: item.navigate || navigate,
|
|
17096
|
+
onClick: item.onClick,
|
|
17096
17097
|
className: cn(
|
|
17097
17098
|
item.className,
|
|
17098
17099
|
isActive && "bg-gray-200 dark:bg-gray-800/50 text-gray-900 dark:text-gray-300"
|
|
@@ -17427,7 +17428,7 @@ var GlowWrapper = ({
|
|
|
17427
17428
|
/* @__PURE__ */ jsx(
|
|
17428
17429
|
"span",
|
|
17429
17430
|
{
|
|
17430
|
-
className: "\n pointer-events-none absolute inset-0 opacity-0 \n group-hover:opacity-100 transition-opacity duration-300\n ",
|
|
17431
|
+
className: "\r\n pointer-events-none absolute inset-0 opacity-0 \r\n group-hover:opacity-100 transition-opacity duration-300\r\n ",
|
|
17431
17432
|
style: { background: "var(--glow-bg)" }
|
|
17432
17433
|
}
|
|
17433
17434
|
),
|
|
@@ -17577,6 +17578,33 @@ function CommentContent({ comment }) {
|
|
|
17577
17578
|
}
|
|
17578
17579
|
var CommentContent_default = CommentContent;
|
|
17579
17580
|
|
|
17581
|
+
// src/compositions/comment-thread/utils/commentReaction.ts
|
|
17582
|
+
function getOptimisticLikeState(comment) {
|
|
17583
|
+
return {
|
|
17584
|
+
liked: !comment.liked,
|
|
17585
|
+
disliked: false,
|
|
17586
|
+
likes: comment.liked ? Math.max(comment.likes - 1, 0) : comment.likes + 1,
|
|
17587
|
+
dislikes: comment.disliked ? Math.max(comment.dislikes - 1, 0) : comment.dislikes
|
|
17588
|
+
};
|
|
17589
|
+
}
|
|
17590
|
+
function getOptimisticDislikeState(comment) {
|
|
17591
|
+
return {
|
|
17592
|
+
liked: false,
|
|
17593
|
+
disliked: !comment.disliked,
|
|
17594
|
+
likes: comment.liked ? Math.max(comment.likes - 1, 0) : comment.likes,
|
|
17595
|
+
dislikes: comment.disliked ? Math.max(comment.dislikes - 1, 0) : comment.dislikes + 1
|
|
17596
|
+
};
|
|
17597
|
+
}
|
|
17598
|
+
function applyReactionState(comment, reaction) {
|
|
17599
|
+
return {
|
|
17600
|
+
...comment,
|
|
17601
|
+
likes: reaction.likes,
|
|
17602
|
+
dislikes: reaction.dislikes,
|
|
17603
|
+
liked: reaction.liked,
|
|
17604
|
+
disliked: reaction.disliked
|
|
17605
|
+
};
|
|
17606
|
+
}
|
|
17607
|
+
|
|
17580
17608
|
// src/compositions/comment-thread/utils/formatCommentDate.ts
|
|
17581
17609
|
function formatCommentDate(date, format = "relative") {
|
|
17582
17610
|
const target = new Date(date);
|
|
@@ -17615,6 +17643,65 @@ function formatCommentDate(date, format = "relative") {
|
|
|
17615
17643
|
}
|
|
17616
17644
|
return "Just now";
|
|
17617
17645
|
}
|
|
17646
|
+
|
|
17647
|
+
// src/compositions/comment-thread/utils/removeComment.ts
|
|
17648
|
+
function removeComment(comments, commentId) {
|
|
17649
|
+
return comments.filter((comment) => comment.id !== commentId);
|
|
17650
|
+
}
|
|
17651
|
+
function incrementReplyCount(comments, commentId) {
|
|
17652
|
+
return comments.map(
|
|
17653
|
+
(comment) => comment.id === commentId ? {
|
|
17654
|
+
...comment,
|
|
17655
|
+
replyCount: comment.replyCount + 1
|
|
17656
|
+
} : comment
|
|
17657
|
+
);
|
|
17658
|
+
}
|
|
17659
|
+
function decrementReplyCount(comments, commentId) {
|
|
17660
|
+
return comments.map(
|
|
17661
|
+
(comment) => comment.id === commentId ? {
|
|
17662
|
+
...comment,
|
|
17663
|
+
replyCount: Math.max(comment.replyCount - 1, 0)
|
|
17664
|
+
} : comment
|
|
17665
|
+
);
|
|
17666
|
+
}
|
|
17667
|
+
|
|
17668
|
+
// src/compositions/comment-thread/utils/replyCache.ts
|
|
17669
|
+
function addReplyToCache(cache, parentCommentId, reply) {
|
|
17670
|
+
return {
|
|
17671
|
+
...cache,
|
|
17672
|
+
[parentCommentId]: [...cache[parentCommentId] ?? [], reply]
|
|
17673
|
+
};
|
|
17674
|
+
}
|
|
17675
|
+
function updateReplyCacheComment(cache, commentId, updater) {
|
|
17676
|
+
const next = {};
|
|
17677
|
+
for (const [parentId, replies] of Object.entries(cache)) {
|
|
17678
|
+
next[parentId] = replies.map(
|
|
17679
|
+
(reply) => reply.id === commentId ? updater(reply) : reply
|
|
17680
|
+
);
|
|
17681
|
+
}
|
|
17682
|
+
return next;
|
|
17683
|
+
}
|
|
17684
|
+
function removeCommentTreeFromCache(cache, commentId) {
|
|
17685
|
+
const childIds = cache[commentId]?.map((reply) => reply.id) ?? [];
|
|
17686
|
+
let next = Object.fromEntries(
|
|
17687
|
+
Object.entries(cache).map(([parentId, replies]) => [
|
|
17688
|
+
parentId,
|
|
17689
|
+
replies.filter((reply) => reply.id !== commentId)
|
|
17690
|
+
])
|
|
17691
|
+
);
|
|
17692
|
+
delete next[commentId];
|
|
17693
|
+
for (const childId of childIds) {
|
|
17694
|
+
next = removeCommentTreeFromCache(next, childId);
|
|
17695
|
+
}
|
|
17696
|
+
return next;
|
|
17697
|
+
}
|
|
17698
|
+
|
|
17699
|
+
// src/compositions/comment-thread/utils/updateComment.ts
|
|
17700
|
+
function updateComment(comments, commentId, updater) {
|
|
17701
|
+
return comments.map(
|
|
17702
|
+
(comment) => comment.id === commentId ? updater(comment) : comment
|
|
17703
|
+
);
|
|
17704
|
+
}
|
|
17618
17705
|
function CommentHeader({ comment, config }) {
|
|
17619
17706
|
const author = comment.author;
|
|
17620
17707
|
const displayName = author?.firstName || author?.lastName ? `${author?.firstName ?? ""} ${author?.lastName ?? ""}`.trim() : author?.username ?? "Unknown";
|
|
@@ -17635,6 +17722,60 @@ function CommentHeader({ comment, config }) {
|
|
|
17635
17722
|
] });
|
|
17636
17723
|
}
|
|
17637
17724
|
var CommentHeader_default = CommentHeader;
|
|
17725
|
+
var useDrawer = (defaultVisibility = true) => {
|
|
17726
|
+
const [show, setShow] = useState(defaultVisibility);
|
|
17727
|
+
const openDrawer = () => {
|
|
17728
|
+
setShow((prev) => !prev);
|
|
17729
|
+
};
|
|
17730
|
+
const closeDrawer = () => {
|
|
17731
|
+
setShow(false);
|
|
17732
|
+
};
|
|
17733
|
+
return {
|
|
17734
|
+
show,
|
|
17735
|
+
openDrawer,
|
|
17736
|
+
closeDrawer
|
|
17737
|
+
};
|
|
17738
|
+
};
|
|
17739
|
+
var useDrawer_default = useDrawer;
|
|
17740
|
+
var useModal = () => {
|
|
17741
|
+
const [show, setShow] = useState(false);
|
|
17742
|
+
const handleOpenModal = () => {
|
|
17743
|
+
setShow(true);
|
|
17744
|
+
};
|
|
17745
|
+
const handleCloseModal = () => {
|
|
17746
|
+
setShow(false);
|
|
17747
|
+
};
|
|
17748
|
+
return {
|
|
17749
|
+
show,
|
|
17750
|
+
handleOpenModal,
|
|
17751
|
+
handleCloseModal
|
|
17752
|
+
};
|
|
17753
|
+
};
|
|
17754
|
+
var useModal_default = useModal;
|
|
17755
|
+
function CommentMenuItem({
|
|
17756
|
+
icon,
|
|
17757
|
+
name,
|
|
17758
|
+
badge,
|
|
17759
|
+
to,
|
|
17760
|
+
navigate,
|
|
17761
|
+
className,
|
|
17762
|
+
onClick,
|
|
17763
|
+
style
|
|
17764
|
+
}) {
|
|
17765
|
+
return /* @__PURE__ */ jsx(
|
|
17766
|
+
MenuItem,
|
|
17767
|
+
{
|
|
17768
|
+
icon,
|
|
17769
|
+
name,
|
|
17770
|
+
badge,
|
|
17771
|
+
to,
|
|
17772
|
+
navigate,
|
|
17773
|
+
onClick,
|
|
17774
|
+
style,
|
|
17775
|
+
className
|
|
17776
|
+
}
|
|
17777
|
+
);
|
|
17778
|
+
}
|
|
17638
17779
|
function CommentMenu({
|
|
17639
17780
|
open,
|
|
17640
17781
|
setOpen,
|
|
@@ -17646,17 +17787,48 @@ function CommentMenu({
|
|
|
17646
17787
|
onReport
|
|
17647
17788
|
}) {
|
|
17648
17789
|
const ref = useRef(null);
|
|
17649
|
-
|
|
17650
|
-
|
|
17651
|
-
|
|
17790
|
+
useClickOutside(ref, () => setOpen(false));
|
|
17791
|
+
const items = [];
|
|
17792
|
+
if (canEdit) {
|
|
17793
|
+
items.push({
|
|
17794
|
+
type: "item",
|
|
17795
|
+
icon: /* @__PURE__ */ jsx(BiEdit, {}),
|
|
17796
|
+
name: "Edit",
|
|
17797
|
+
component: CommentMenuItem,
|
|
17798
|
+
onClick: () => {
|
|
17652
17799
|
setOpen(false);
|
|
17653
|
-
|
|
17654
|
-
|
|
17655
|
-
|
|
17656
|
-
|
|
17657
|
-
}
|
|
17658
|
-
|
|
17659
|
-
|
|
17800
|
+
onEdit?.();
|
|
17801
|
+
},
|
|
17802
|
+
className: "flex w-full items-center gap-2 px-4 py-3 text-sm hover:bg-gray-100 dark:hover:bg-neutral-800"
|
|
17803
|
+
});
|
|
17804
|
+
}
|
|
17805
|
+
if (canDelete) {
|
|
17806
|
+
items.push({
|
|
17807
|
+
type: "item",
|
|
17808
|
+
icon: /* @__PURE__ */ jsx(BiTrash, {}),
|
|
17809
|
+
name: "Delete",
|
|
17810
|
+
component: CommentMenuItem,
|
|
17811
|
+
onClick: () => {
|
|
17812
|
+
setOpen(false);
|
|
17813
|
+
onDelete?.();
|
|
17814
|
+
},
|
|
17815
|
+
className: "flex w-full items-center gap-2 px-4 py-3 text-sm text-red-500 hover:bg-gray-100 dark:hover:bg-neutral-800"
|
|
17816
|
+
});
|
|
17817
|
+
}
|
|
17818
|
+
if (canReport) {
|
|
17819
|
+
items.push({
|
|
17820
|
+
type: "item",
|
|
17821
|
+
icon: /* @__PURE__ */ jsx(BiFlag, {}),
|
|
17822
|
+
name: "Report",
|
|
17823
|
+
component: CommentMenuItem,
|
|
17824
|
+
onClick: () => {
|
|
17825
|
+
setOpen(false);
|
|
17826
|
+
onReport?.();
|
|
17827
|
+
},
|
|
17828
|
+
className: "flex w-full items-center gap-2 px-4 py-3 text-sm hover:bg-gray-100 dark:hover:bg-neutral-800"
|
|
17829
|
+
});
|
|
17830
|
+
}
|
|
17831
|
+
if (!items.length) {
|
|
17660
17832
|
return null;
|
|
17661
17833
|
}
|
|
17662
17834
|
return /* @__PURE__ */ jsxs("div", { ref, className: "relative", children: [
|
|
@@ -17669,53 +17841,7 @@ function CommentMenu({
|
|
|
17669
17841
|
children: /* @__PURE__ */ jsx(BiDotsVerticalRounded, { size: 18 })
|
|
17670
17842
|
}
|
|
17671
17843
|
),
|
|
17672
|
-
open
|
|
17673
|
-
canEdit && /* @__PURE__ */ jsxs(
|
|
17674
|
-
"button",
|
|
17675
|
-
{
|
|
17676
|
-
type: "button",
|
|
17677
|
-
onClick: () => {
|
|
17678
|
-
setOpen(false);
|
|
17679
|
-
onEdit?.();
|
|
17680
|
-
},
|
|
17681
|
-
className: "flex w-full items-center gap-2 px-4 py-3 text-sm hover:bg-gray-100 dark:hover:bg-neutral-800",
|
|
17682
|
-
children: [
|
|
17683
|
-
/* @__PURE__ */ jsx(BiEdit, {}),
|
|
17684
|
-
"Edit"
|
|
17685
|
-
]
|
|
17686
|
-
}
|
|
17687
|
-
),
|
|
17688
|
-
canDelete && /* @__PURE__ */ jsxs(
|
|
17689
|
-
"button",
|
|
17690
|
-
{
|
|
17691
|
-
type: "button",
|
|
17692
|
-
onClick: () => {
|
|
17693
|
-
setOpen(false);
|
|
17694
|
-
onDelete?.();
|
|
17695
|
-
},
|
|
17696
|
-
className: "flex w-full items-center gap-2 px-4 py-3 text-sm text-red-500 hover:bg-gray-100 dark:hover:bg-neutral-800",
|
|
17697
|
-
children: [
|
|
17698
|
-
/* @__PURE__ */ jsx(BiTrash, {}),
|
|
17699
|
-
"Delete"
|
|
17700
|
-
]
|
|
17701
|
-
}
|
|
17702
|
-
),
|
|
17703
|
-
canReport && /* @__PURE__ */ jsxs(
|
|
17704
|
-
"button",
|
|
17705
|
-
{
|
|
17706
|
-
type: "button",
|
|
17707
|
-
onClick: () => {
|
|
17708
|
-
setOpen(false);
|
|
17709
|
-
onReport?.();
|
|
17710
|
-
},
|
|
17711
|
-
className: "flex w-full items-center gap-2 px-4 py-3 text-sm hover:bg-gray-100 dark:hover:bg-neutral-800",
|
|
17712
|
-
children: [
|
|
17713
|
-
/* @__PURE__ */ jsx(BiFlag, {}),
|
|
17714
|
-
"Report"
|
|
17715
|
-
]
|
|
17716
|
-
}
|
|
17717
|
-
)
|
|
17718
|
-
] })
|
|
17844
|
+
/* @__PURE__ */ jsx(Transition4.TransitionDropdown, { visibility: open, children: /* @__PURE__ */ jsx("div", { className: "absolute right-0 top-full z-50 mt-2 min-w-[180px] overflow-hidden rounded-xl border border-gray-200 bg-white shadow-xl dark:border-neutral-800 dark:bg-neutral-900", children: /* @__PURE__ */ jsx(Menu, { items }) }) })
|
|
17719
17845
|
] });
|
|
17720
17846
|
}
|
|
17721
17847
|
var CommentMenu_default = CommentMenu;
|
|
@@ -17936,13 +18062,6 @@ function CommentList({
|
|
|
17936
18062
|
}
|
|
17937
18063
|
var CommentList_default = CommentList;
|
|
17938
18064
|
|
|
17939
|
-
// src/compositions/comment-thread/utils/updateComment.ts
|
|
17940
|
-
function updateComment(comments, commentId, updater) {
|
|
17941
|
-
return comments.map(
|
|
17942
|
-
(comment) => comment.id === commentId ? updater(comment) : comment
|
|
17943
|
-
);
|
|
17944
|
-
}
|
|
17945
|
-
|
|
17946
18065
|
// src/compositions/comment-thread/constants/comment.constants.ts
|
|
17947
18066
|
var DEFAULT_COMMENT_THREAD_CONFIG = {
|
|
17948
18067
|
maxDepth: 5,
|
|
@@ -17958,6 +18077,7 @@ function CommentThread({
|
|
|
17958
18077
|
components,
|
|
17959
18078
|
config,
|
|
17960
18079
|
updatedComment,
|
|
18080
|
+
deletedComment,
|
|
17961
18081
|
onEdit,
|
|
17962
18082
|
onDelete,
|
|
17963
18083
|
onReport
|
|
@@ -17985,7 +18105,7 @@ function CommentThread({
|
|
|
17985
18105
|
setIsLoadingComments(false);
|
|
17986
18106
|
}
|
|
17987
18107
|
}
|
|
17988
|
-
loadComments();
|
|
18108
|
+
void loadComments();
|
|
17989
18109
|
}, [dataSource, resolvedConfig.commentsPerPage]);
|
|
17990
18110
|
useEffect(() => {
|
|
17991
18111
|
replyCacheRef.current = replyCache;
|
|
@@ -18026,29 +18146,18 @@ function CommentThread({
|
|
|
18026
18146
|
cancelled = true;
|
|
18027
18147
|
};
|
|
18028
18148
|
}, [dataSource, resolvedConfig.repliesPerPage]);
|
|
18029
|
-
|
|
18030
|
-
|
|
18031
|
-
|
|
18032
|
-
next[parentId] = replies.map(
|
|
18033
|
-
(reply) => reply.id === commentId ? updater(reply) : reply
|
|
18034
|
-
);
|
|
18149
|
+
useEffect(() => {
|
|
18150
|
+
if (!updatedComment) {
|
|
18151
|
+
return;
|
|
18035
18152
|
}
|
|
18036
|
-
|
|
18037
|
-
}
|
|
18038
|
-
|
|
18039
|
-
|
|
18040
|
-
|
|
18041
|
-
Object.entries(cache).map(([parentId, replies]) => [
|
|
18042
|
-
parentId,
|
|
18043
|
-
replies.filter((reply) => reply.id !== commentId)
|
|
18044
|
-
])
|
|
18045
|
-
);
|
|
18046
|
-
delete next[commentId];
|
|
18047
|
-
for (const childId of childIds) {
|
|
18048
|
-
next = removeCommentTreeFromCache(next, childId);
|
|
18153
|
+
updateCommentEverywhere(updatedComment.id, () => updatedComment);
|
|
18154
|
+
}, [updatedComment]);
|
|
18155
|
+
useEffect(() => {
|
|
18156
|
+
if (!deletedComment) {
|
|
18157
|
+
return;
|
|
18049
18158
|
}
|
|
18050
|
-
|
|
18051
|
-
}
|
|
18159
|
+
removeCommentEverywhere(deletedComment);
|
|
18160
|
+
}, [deletedComment]);
|
|
18052
18161
|
async function handleCreateComment(content) {
|
|
18053
18162
|
const comment = await dataSource.createComment({
|
|
18054
18163
|
content,
|
|
@@ -18056,51 +18165,13 @@ function CommentThread({
|
|
|
18056
18165
|
});
|
|
18057
18166
|
setComments((prev) => [comment, ...prev]);
|
|
18058
18167
|
}
|
|
18059
|
-
async function handleDeleteComment(comment) {
|
|
18060
|
-
await dataSource.deleteComment(comment.id);
|
|
18061
|
-
setComments((prev) => prev.filter((item) => item.id !== comment.id));
|
|
18062
|
-
setReplyCache((prev) => removeCommentTreeFromCache(prev, comment.id));
|
|
18063
|
-
if (comment.parentCommentId) {
|
|
18064
|
-
setComments(
|
|
18065
|
-
(prev) => updateComment(prev, comment.parentCommentId, (item) => ({
|
|
18066
|
-
...item,
|
|
18067
|
-
replyCount: Math.max(item.replyCount - 1, 0)
|
|
18068
|
-
}))
|
|
18069
|
-
);
|
|
18070
|
-
setReplyCache(
|
|
18071
|
-
(prev) => updateReplyCacheComment(prev, comment.parentCommentId, (item) => ({
|
|
18072
|
-
...item,
|
|
18073
|
-
replyCount: Math.max(item.replyCount - 1, 0)
|
|
18074
|
-
}))
|
|
18075
|
-
);
|
|
18076
|
-
}
|
|
18077
|
-
}
|
|
18078
|
-
function updateCommentEverywhere(commentId, updater) {
|
|
18079
|
-
setComments((prev) => updateComment(prev, commentId, updater));
|
|
18080
|
-
setReplyCache((prev) => updateReplyCacheComment(prev, commentId, updater));
|
|
18081
|
-
}
|
|
18082
|
-
useEffect(() => {
|
|
18083
|
-
if (!updatedComment) {
|
|
18084
|
-
return;
|
|
18085
|
-
}
|
|
18086
|
-
updateCommentEverywhere(updatedComment.id, () => updatedComment);
|
|
18087
|
-
}, [updatedComment]);
|
|
18088
18168
|
async function handleReply(parentComment, content) {
|
|
18089
18169
|
const reply = await dataSource.createComment({
|
|
18090
18170
|
content,
|
|
18091
18171
|
parentCommentId: parentComment.id
|
|
18092
18172
|
});
|
|
18093
|
-
setReplyCache((prev) => (
|
|
18094
|
-
|
|
18095
|
-
[parentComment.id]: [...prev[parentComment.id] ?? [], reply]
|
|
18096
|
-
}));
|
|
18097
|
-
const incrementReplyCount = (items) => items.map(
|
|
18098
|
-
(item) => item.id === parentComment.id ? {
|
|
18099
|
-
...item,
|
|
18100
|
-
replyCount: item.replyCount + 1
|
|
18101
|
-
} : item
|
|
18102
|
-
);
|
|
18103
|
-
setComments((prev) => incrementReplyCount(prev));
|
|
18173
|
+
setReplyCache((prev) => addReplyToCache(prev, parentComment.id, reply));
|
|
18174
|
+
setComments((prev) => incrementReplyCount(prev, parentComment.id));
|
|
18104
18175
|
setReplyCache(
|
|
18105
18176
|
(prev) => updateReplyCacheComment(prev, parentComment.id, (item) => ({
|
|
18106
18177
|
...item,
|
|
@@ -18121,61 +18192,66 @@ function CommentThread({
|
|
|
18121
18192
|
}));
|
|
18122
18193
|
}
|
|
18123
18194
|
async function handleLike(comment) {
|
|
18124
|
-
const optimistic =
|
|
18125
|
-
|
|
18126
|
-
disliked: false,
|
|
18127
|
-
likes: comment.liked ? Math.max(comment.likes - 1, 0) : comment.likes + 1,
|
|
18128
|
-
dislikes: comment.disliked ? Math.max(comment.dislikes - 1, 0) : comment.dislikes
|
|
18129
|
-
};
|
|
18130
|
-
const updater = (item) => ({
|
|
18131
|
-
...item,
|
|
18132
|
-
likes: optimistic.likes,
|
|
18133
|
-
dislikes: optimistic.dislikes,
|
|
18134
|
-
liked: optimistic.liked,
|
|
18135
|
-
disliked: optimistic.disliked
|
|
18136
|
-
});
|
|
18195
|
+
const optimistic = getOptimisticLikeState(comment);
|
|
18196
|
+
const updater = (item) => applyReactionState(item, optimistic);
|
|
18137
18197
|
setComments((prev) => updateComment(prev, comment.id, updater));
|
|
18138
18198
|
setReplyCache((prev) => updateReplyCacheComment(prev, comment.id, updater));
|
|
18139
18199
|
try {
|
|
18140
18200
|
await dataSource.toggleLike(comment.id);
|
|
18141
18201
|
} catch {
|
|
18142
|
-
|
|
18143
|
-
setReplyCache(
|
|
18144
|
-
(prev) => updateReplyCacheComment(prev, comment.id, () => comment)
|
|
18145
|
-
);
|
|
18202
|
+
rollbackComment(comment);
|
|
18146
18203
|
}
|
|
18147
18204
|
}
|
|
18148
18205
|
async function handleDislike(comment) {
|
|
18149
|
-
const optimistic =
|
|
18150
|
-
|
|
18151
|
-
disliked: !comment.disliked,
|
|
18152
|
-
likes: comment.liked ? Math.max(comment.likes - 1, 0) : comment.likes,
|
|
18153
|
-
dislikes: comment.disliked ? Math.max(comment.dislikes - 1, 0) : comment.dislikes + 1
|
|
18154
|
-
};
|
|
18155
|
-
const updater = (item) => ({
|
|
18156
|
-
...item,
|
|
18157
|
-
likes: optimistic.likes,
|
|
18158
|
-
dislikes: optimistic.dislikes,
|
|
18159
|
-
liked: optimistic.liked,
|
|
18160
|
-
disliked: optimistic.disliked
|
|
18161
|
-
});
|
|
18206
|
+
const optimistic = getOptimisticDislikeState(comment);
|
|
18207
|
+
const updater = (item) => applyReactionState(item, optimistic);
|
|
18162
18208
|
setComments((prev) => updateComment(prev, comment.id, updater));
|
|
18163
18209
|
setReplyCache((prev) => updateReplyCacheComment(prev, comment.id, updater));
|
|
18164
18210
|
try {
|
|
18165
18211
|
await dataSource.toggleDislike(comment.id);
|
|
18166
18212
|
} catch {
|
|
18167
|
-
|
|
18168
|
-
setReplyCache(
|
|
18169
|
-
(prev) => updateReplyCacheComment(prev, comment.id, () => comment)
|
|
18170
|
-
);
|
|
18213
|
+
rollbackComment(comment);
|
|
18171
18214
|
}
|
|
18172
18215
|
}
|
|
18216
|
+
function rollbackComment(comment) {
|
|
18217
|
+
setComments((prev) => updateComment(prev, comment.id, () => comment));
|
|
18218
|
+
setReplyCache(
|
|
18219
|
+
(prev) => updateReplyCacheComment(prev, comment.id, () => comment)
|
|
18220
|
+
);
|
|
18221
|
+
}
|
|
18173
18222
|
async function handleEditComment(comment) {
|
|
18174
18223
|
const updatedComment2 = await onEdit?.(comment);
|
|
18175
18224
|
if (updatedComment2) {
|
|
18176
18225
|
updateCommentEverywhere(updatedComment2.id, () => updatedComment2);
|
|
18177
18226
|
}
|
|
18178
18227
|
}
|
|
18228
|
+
function updateCommentEverywhere(commentId, updater) {
|
|
18229
|
+
setComments((prev) => updateComment(prev, commentId, updater));
|
|
18230
|
+
setReplyCache((prev) => updateReplyCacheComment(prev, commentId, updater));
|
|
18231
|
+
}
|
|
18232
|
+
async function handleDeleteComment(comment) {
|
|
18233
|
+
if (onDelete) {
|
|
18234
|
+
onDelete(comment);
|
|
18235
|
+
return;
|
|
18236
|
+
}
|
|
18237
|
+
await dataSource.deleteComment(comment.id);
|
|
18238
|
+
removeCommentEverywhere(comment);
|
|
18239
|
+
}
|
|
18240
|
+
function removeCommentEverywhere(comment) {
|
|
18241
|
+
setComments((prev) => removeComment(prev, comment.id));
|
|
18242
|
+
setReplyCache((prev) => removeCommentTreeFromCache(prev, comment.id));
|
|
18243
|
+
if (comment.parentCommentId) {
|
|
18244
|
+
setComments(
|
|
18245
|
+
(prev) => decrementReplyCount(prev, comment.parentCommentId)
|
|
18246
|
+
);
|
|
18247
|
+
setReplyCache(
|
|
18248
|
+
(prev) => updateReplyCacheComment(prev, comment.parentCommentId, (item) => ({
|
|
18249
|
+
...item,
|
|
18250
|
+
replyCount: Math.max(item.replyCount - 1, 0)
|
|
18251
|
+
}))
|
|
18252
|
+
);
|
|
18253
|
+
}
|
|
18254
|
+
}
|
|
18179
18255
|
if (loading || isLoadingComments) {
|
|
18180
18256
|
return /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-6", children: "Loading comments..." });
|
|
18181
18257
|
}
|
|
@@ -18873,36 +18949,6 @@ var TopNav = ({
|
|
|
18873
18949
|
};
|
|
18874
18950
|
return /* @__PURE__ */ jsx("div", { className: "flex items-center", children: items.map(renderNode) });
|
|
18875
18951
|
};
|
|
18876
|
-
var useDrawer = (defaultVisibility = true) => {
|
|
18877
|
-
const [show, setShow] = useState(defaultVisibility);
|
|
18878
|
-
const openDrawer = () => {
|
|
18879
|
-
setShow((prev) => !prev);
|
|
18880
|
-
};
|
|
18881
|
-
const closeDrawer = () => {
|
|
18882
|
-
setShow(false);
|
|
18883
|
-
};
|
|
18884
|
-
return {
|
|
18885
|
-
show,
|
|
18886
|
-
openDrawer,
|
|
18887
|
-
closeDrawer
|
|
18888
|
-
};
|
|
18889
|
-
};
|
|
18890
|
-
var useDrawer_default = useDrawer;
|
|
18891
|
-
var useModal = () => {
|
|
18892
|
-
const [show, setShow] = useState(false);
|
|
18893
|
-
const handleOpenModal = () => {
|
|
18894
|
-
setShow(true);
|
|
18895
|
-
};
|
|
18896
|
-
const handleCloseModal = () => {
|
|
18897
|
-
setShow(false);
|
|
18898
|
-
};
|
|
18899
|
-
return {
|
|
18900
|
-
show,
|
|
18901
|
-
handleOpenModal,
|
|
18902
|
-
handleCloseModal
|
|
18903
|
-
};
|
|
18904
|
-
};
|
|
18905
|
-
var useModal_default = useModal;
|
|
18906
18952
|
function GenericLayout({
|
|
18907
18953
|
children,
|
|
18908
18954
|
styles,
|
|
@@ -19019,6 +19065,6 @@ function ScrollToTop({
|
|
|
19019
19065
|
}
|
|
19020
19066
|
var ScrollToTop_default = ScrollToTop;
|
|
19021
19067
|
|
|
19022
|
-
export { Accordion_default as Accordion, AsyncComponentWrapper_default as AsyncComponentWrapper, Avatar, Backdrop_default as Backdrop, Badge, BarChart_default as BarChart, Block_default as Block, BlockGroup_default as BlockGroup, BoxNav_default as BoxNav, BoxNavItem_default as BoxNavItem, Brand_default as Brand, Breadcrumb, BreadcrumbItem_default as BreadcrumbItem, Button_default as Button, Caption, Card_default as Card, CardContent_default as CardContent, CardFooter_default as CardFooter, CardHeader_default as CardHeader, Chapter, Checkbox_default as Checkbox, Chip, CloudinaryImage_default as CloudinaryImage, CloudinaryProvider, CloudinaryVideo_default as CloudinaryVideo, Code, CommentThread_default as CommentThread, Content, ContentArea_default as ContentArea, DataView, DataViewTable_default as DataViewTable, DateSelector_default as DateSelector, DefaultLayout_default as DefaultLayout, Display, DocumentationPanel_default as DocumentationPanel, Drawer, DrawerToggler_default as DrawerToggler, EUIDevLayout_default as EUIDevLayout, EUIProvider, Flag, Flex, FlexCol_default as FlexCol, FlexRow_default as FlexRow, Footer, FooterNav_default as FooterNav, FooterNavGroup_default as FooterNavGroup, FooterNavItem, FooterNavItemContext, FooterNavItemTitle, Form, FormResponse_default as FormResponse, GenericLayout_default as GenericLayout, GlowWrapper_default as GlowWrapper, Graph, GraphEdge, GraphNode, GraphRenderer, Grid_default as Grid, Header, HeaderNav_default as HeaderNav, HeaderNavGroup_default as HeaderNavGroup, HeaderNavItem, HeaderNavItemContext, HeaderNavItemTitle, HomeLayout_default as HomeLayout, Image2 as Image, ImageInput_default as ImageInput, Info_default as Info, Input, InputFile, InputLabel_default as InputLabel, InputList, InputListGroup, InputResponse_default as InputResponse, Label, Layout, Lead, LineChart_default as LineChart, Link, List_default as List, ListItem_default as ListItem, MarkdownEditor_default as MarkdownEditor, MarkdownProvider_default as MarkdownProvider, MarkdownTOC_default as MarkdownTOC, MarkdownViewer_default as MarkdownViewer, Menu, MenuGroup, MenuItem, MenuItemTitle, Modal_default as Modal, MotionSurface_default as MotionSurface, MultiImageInput_default as MultiImageInput, NumericRating_default as NumericRating, Overline, Paragraph, PieChart_default as PieChart, PriceTag, ProgressBar, ProgressBarRating_default as ProgressBarRating, Quote, Radio_default as Radio, RouteTab_default as RouteTab, RouteTabs_default as RouteTabs, ScrollToTop_default as ScrollToTop, Section, Select_default as Select, ShapeSwitch, ShowMore_default as ShowMore, Sidebar_default as Sidebar, SidebarLayout_default as SidebarLayout, SidemenuLayout_default as SidemenuLayout, Skeleton, Slider_default as Slider, StarRating_default as StarRating, StarRatingDistribution_default as StarRatingDistribution, StarRatingInput_default as StarRatingInput, Switch_default as Switch, TNDropdown, TNDropdownItem, TNDropdownTitle, TNGroup, Table_default as Table, Tag_default as Tag, Tags_default as Tags, TextArea_default as TextArea, ThemeContext, ThemeProvider, ThemeSwitch, TitleBanner, Toast, Tooltip4 as Tooltip, TopNav, Transition4 as Transition, TransitionDropdown_default as TransitionDropdown, TransitionFadeIn_default as TransitionFadeIn, Typography, UnderConstructionBanner, ValueBadge_default as ValueBadge, WorldMap, WorldMapCountryTable, YoutubeVideo_default as YoutubeVideoPlayer, cn, createForceLayout, createGridLayout, createTreeLayout, enumValues, formatCommentDate, getCurrencySymbol, getLayout, isMatch, isRenderFn, normalize, registerLayout, resolveAppearanceStyles, resolveWithGlobal, sendToast, useClickOutside, useCloudinaryConfig, useCurrentTheme_default as useCurrentTheme, useDrawer_default as useDrawer, useEUIConfig, useIsMobile_default as useIsMobile, useModal_default as useModal, useTheme_default as useTheme };
|
|
19068
|
+
export { Accordion_default as Accordion, AsyncComponentWrapper_default as AsyncComponentWrapper, Avatar, Backdrop_default as Backdrop, Badge, BarChart_default as BarChart, Block_default as Block, BlockGroup_default as BlockGroup, BoxNav_default as BoxNav, BoxNavItem_default as BoxNavItem, Brand_default as Brand, Breadcrumb, BreadcrumbItem_default as BreadcrumbItem, Button_default as Button, Caption, Card_default as Card, CardContent_default as CardContent, CardFooter_default as CardFooter, CardHeader_default as CardHeader, Chapter, Checkbox_default as Checkbox, Chip, CloudinaryImage_default as CloudinaryImage, CloudinaryProvider, CloudinaryVideo_default as CloudinaryVideo, Code, CommentThread_default as CommentThread, Content, ContentArea_default as ContentArea, DataView, DataViewTable_default as DataViewTable, DateSelector_default as DateSelector, DefaultLayout_default as DefaultLayout, Display, DocumentationPanel_default as DocumentationPanel, Drawer, DrawerToggler_default as DrawerToggler, EUIDevLayout_default as EUIDevLayout, EUIProvider, Flag, Flex, FlexCol_default as FlexCol, FlexRow_default as FlexRow, Footer, FooterNav_default as FooterNav, FooterNavGroup_default as FooterNavGroup, FooterNavItem, FooterNavItemContext, FooterNavItemTitle, Form, FormResponse_default as FormResponse, GenericLayout_default as GenericLayout, GlowWrapper_default as GlowWrapper, Graph, GraphEdge, GraphNode, GraphRenderer, Grid_default as Grid, Header, HeaderNav_default as HeaderNav, HeaderNavGroup_default as HeaderNavGroup, HeaderNavItem, HeaderNavItemContext, HeaderNavItemTitle, HomeLayout_default as HomeLayout, Image2 as Image, ImageInput_default as ImageInput, Info_default as Info, Input, InputFile, InputLabel_default as InputLabel, InputList, InputListGroup, InputResponse_default as InputResponse, Label, Layout, Lead, LineChart_default as LineChart, Link, List_default as List, ListItem_default as ListItem, MarkdownEditor_default as MarkdownEditor, MarkdownProvider_default as MarkdownProvider, MarkdownTOC_default as MarkdownTOC, MarkdownViewer_default as MarkdownViewer, Menu, MenuGroup, MenuItem, MenuItemTitle, Modal_default as Modal, MotionSurface_default as MotionSurface, MultiImageInput_default as MultiImageInput, NumericRating_default as NumericRating, Overline, Paragraph, PieChart_default as PieChart, PriceTag, ProgressBar, ProgressBarRating_default as ProgressBarRating, Quote, Radio_default as Radio, RouteTab_default as RouteTab, RouteTabs_default as RouteTabs, ScrollToTop_default as ScrollToTop, Section, Select_default as Select, ShapeSwitch, ShowMore_default as ShowMore, Sidebar_default as Sidebar, SidebarLayout_default as SidebarLayout, SidemenuLayout_default as SidemenuLayout, Skeleton, Slider_default as Slider, StarRating_default as StarRating, StarRatingDistribution_default as StarRatingDistribution, StarRatingInput_default as StarRatingInput, Switch_default as Switch, TNDropdown, TNDropdownItem, TNDropdownTitle, TNGroup, Table_default as Table, Tag_default as Tag, Tags_default as Tags, TextArea_default as TextArea, ThemeContext, ThemeProvider, ThemeSwitch, TitleBanner, Toast, Tooltip4 as Tooltip, TopNav, Transition4 as Transition, TransitionDropdown_default as TransitionDropdown, TransitionFadeIn_default as TransitionFadeIn, Typography, UnderConstructionBanner, ValueBadge_default as ValueBadge, WorldMap, WorldMapCountryTable, YoutubeVideo_default as YoutubeVideoPlayer, addReplyToCache, applyReactionState, cn, createForceLayout, createGridLayout, createTreeLayout, decrementReplyCount, enumValues, formatCommentDate, getCurrencySymbol, getLayout, getOptimisticDislikeState, getOptimisticLikeState, incrementReplyCount, isMatch, isRenderFn, normalize, registerLayout, removeComment, removeCommentTreeFromCache, resolveAppearanceStyles, resolveWithGlobal, sendToast, updateComment, updateReplyCacheComment, useClickOutside, useCloudinaryConfig, useCurrentTheme_default as useCurrentTheme, useDrawer_default as useDrawer, useEUIConfig, useIsMobile_default as useIsMobile, useModal_default as useModal, useTheme_default as useTheme };
|
|
19023
19069
|
//# sourceMappingURL=index.mjs.map
|
|
19024
19070
|
//# sourceMappingURL=index.mjs.map
|