elseware-ui 2.31.15 → 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 -1479
- package/dist/index.d.ts +1496 -1479
- package/dist/index.js +253 -190
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +244 -191
- 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,
|
|
@@ -17957,6 +18076,8 @@ function CommentThread({
|
|
|
17957
18076
|
loading = false,
|
|
17958
18077
|
components,
|
|
17959
18078
|
config,
|
|
18079
|
+
updatedComment,
|
|
18080
|
+
deletedComment,
|
|
17960
18081
|
onEdit,
|
|
17961
18082
|
onDelete,
|
|
17962
18083
|
onReport
|
|
@@ -17984,7 +18105,7 @@ function CommentThread({
|
|
|
17984
18105
|
setIsLoadingComments(false);
|
|
17985
18106
|
}
|
|
17986
18107
|
}
|
|
17987
|
-
loadComments();
|
|
18108
|
+
void loadComments();
|
|
17988
18109
|
}, [dataSource, resolvedConfig.commentsPerPage]);
|
|
17989
18110
|
useEffect(() => {
|
|
17990
18111
|
replyCacheRef.current = replyCache;
|
|
@@ -18025,29 +18146,18 @@ function CommentThread({
|
|
|
18025
18146
|
cancelled = true;
|
|
18026
18147
|
};
|
|
18027
18148
|
}, [dataSource, resolvedConfig.repliesPerPage]);
|
|
18028
|
-
|
|
18029
|
-
|
|
18030
|
-
|
|
18031
|
-
next[parentId] = replies.map(
|
|
18032
|
-
(reply) => reply.id === commentId ? updater(reply) : reply
|
|
18033
|
-
);
|
|
18149
|
+
useEffect(() => {
|
|
18150
|
+
if (!updatedComment) {
|
|
18151
|
+
return;
|
|
18034
18152
|
}
|
|
18035
|
-
|
|
18036
|
-
}
|
|
18037
|
-
|
|
18038
|
-
|
|
18039
|
-
|
|
18040
|
-
Object.entries(cache).map(([parentId, replies]) => [
|
|
18041
|
-
parentId,
|
|
18042
|
-
replies.filter((reply) => reply.id !== commentId)
|
|
18043
|
-
])
|
|
18044
|
-
);
|
|
18045
|
-
delete next[commentId];
|
|
18046
|
-
for (const childId of childIds) {
|
|
18047
|
-
next = removeCommentTreeFromCache(next, childId);
|
|
18153
|
+
updateCommentEverywhere(updatedComment.id, () => updatedComment);
|
|
18154
|
+
}, [updatedComment]);
|
|
18155
|
+
useEffect(() => {
|
|
18156
|
+
if (!deletedComment) {
|
|
18157
|
+
return;
|
|
18048
18158
|
}
|
|
18049
|
-
|
|
18050
|
-
}
|
|
18159
|
+
removeCommentEverywhere(deletedComment);
|
|
18160
|
+
}, [deletedComment]);
|
|
18051
18161
|
async function handleCreateComment(content) {
|
|
18052
18162
|
const comment = await dataSource.createComment({
|
|
18053
18163
|
content,
|
|
@@ -18055,45 +18165,13 @@ function CommentThread({
|
|
|
18055
18165
|
});
|
|
18056
18166
|
setComments((prev) => [comment, ...prev]);
|
|
18057
18167
|
}
|
|
18058
|
-
async function handleDeleteComment(comment) {
|
|
18059
|
-
await dataSource.deleteComment(comment.id);
|
|
18060
|
-
setComments((prev) => prev.filter((item) => item.id !== comment.id));
|
|
18061
|
-
setReplyCache((prev) => removeCommentTreeFromCache(prev, comment.id));
|
|
18062
|
-
if (comment.parentCommentId) {
|
|
18063
|
-
setComments(
|
|
18064
|
-
(prev) => updateComment(prev, comment.parentCommentId, (item) => ({
|
|
18065
|
-
...item,
|
|
18066
|
-
replyCount: Math.max(item.replyCount - 1, 0)
|
|
18067
|
-
}))
|
|
18068
|
-
);
|
|
18069
|
-
setReplyCache(
|
|
18070
|
-
(prev) => updateReplyCacheComment(prev, comment.parentCommentId, (item) => ({
|
|
18071
|
-
...item,
|
|
18072
|
-
replyCount: Math.max(item.replyCount - 1, 0)
|
|
18073
|
-
}))
|
|
18074
|
-
);
|
|
18075
|
-
}
|
|
18076
|
-
}
|
|
18077
|
-
function updateCommentEverywhere(commentId, updater) {
|
|
18078
|
-
setComments((prev) => updateComment(prev, commentId, updater));
|
|
18079
|
-
setReplyCache((prev) => updateReplyCacheComment(prev, commentId, updater));
|
|
18080
|
-
}
|
|
18081
18168
|
async function handleReply(parentComment, content) {
|
|
18082
18169
|
const reply = await dataSource.createComment({
|
|
18083
18170
|
content,
|
|
18084
18171
|
parentCommentId: parentComment.id
|
|
18085
18172
|
});
|
|
18086
|
-
setReplyCache((prev) => (
|
|
18087
|
-
|
|
18088
|
-
[parentComment.id]: [...prev[parentComment.id] ?? [], reply]
|
|
18089
|
-
}));
|
|
18090
|
-
const incrementReplyCount = (items) => items.map(
|
|
18091
|
-
(item) => item.id === parentComment.id ? {
|
|
18092
|
-
...item,
|
|
18093
|
-
replyCount: item.replyCount + 1
|
|
18094
|
-
} : item
|
|
18095
|
-
);
|
|
18096
|
-
setComments((prev) => incrementReplyCount(prev));
|
|
18173
|
+
setReplyCache((prev) => addReplyToCache(prev, parentComment.id, reply));
|
|
18174
|
+
setComments((prev) => incrementReplyCount(prev, parentComment.id));
|
|
18097
18175
|
setReplyCache(
|
|
18098
18176
|
(prev) => updateReplyCacheComment(prev, parentComment.id, (item) => ({
|
|
18099
18177
|
...item,
|
|
@@ -18114,59 +18192,64 @@ function CommentThread({
|
|
|
18114
18192
|
}));
|
|
18115
18193
|
}
|
|
18116
18194
|
async function handleLike(comment) {
|
|
18117
|
-
const optimistic =
|
|
18118
|
-
|
|
18119
|
-
disliked: false,
|
|
18120
|
-
likes: comment.liked ? Math.max(comment.likes - 1, 0) : comment.likes + 1,
|
|
18121
|
-
dislikes: comment.disliked ? Math.max(comment.dislikes - 1, 0) : comment.dislikes
|
|
18122
|
-
};
|
|
18123
|
-
const updater = (item) => ({
|
|
18124
|
-
...item,
|
|
18125
|
-
likes: optimistic.likes,
|
|
18126
|
-
dislikes: optimistic.dislikes,
|
|
18127
|
-
liked: optimistic.liked,
|
|
18128
|
-
disliked: optimistic.disliked
|
|
18129
|
-
});
|
|
18195
|
+
const optimistic = getOptimisticLikeState(comment);
|
|
18196
|
+
const updater = (item) => applyReactionState(item, optimistic);
|
|
18130
18197
|
setComments((prev) => updateComment(prev, comment.id, updater));
|
|
18131
18198
|
setReplyCache((prev) => updateReplyCacheComment(prev, comment.id, updater));
|
|
18132
18199
|
try {
|
|
18133
18200
|
await dataSource.toggleLike(comment.id);
|
|
18134
18201
|
} catch {
|
|
18135
|
-
|
|
18136
|
-
setReplyCache(
|
|
18137
|
-
(prev) => updateReplyCacheComment(prev, comment.id, () => comment)
|
|
18138
|
-
);
|
|
18202
|
+
rollbackComment(comment);
|
|
18139
18203
|
}
|
|
18140
18204
|
}
|
|
18141
18205
|
async function handleDislike(comment) {
|
|
18142
|
-
const optimistic =
|
|
18143
|
-
|
|
18144
|
-
disliked: !comment.disliked,
|
|
18145
|
-
likes: comment.liked ? Math.max(comment.likes - 1, 0) : comment.likes,
|
|
18146
|
-
dislikes: comment.disliked ? Math.max(comment.dislikes - 1, 0) : comment.dislikes + 1
|
|
18147
|
-
};
|
|
18148
|
-
const updater = (item) => ({
|
|
18149
|
-
...item,
|
|
18150
|
-
likes: optimistic.likes,
|
|
18151
|
-
dislikes: optimistic.dislikes,
|
|
18152
|
-
liked: optimistic.liked,
|
|
18153
|
-
disliked: optimistic.disliked
|
|
18154
|
-
});
|
|
18206
|
+
const optimistic = getOptimisticDislikeState(comment);
|
|
18207
|
+
const updater = (item) => applyReactionState(item, optimistic);
|
|
18155
18208
|
setComments((prev) => updateComment(prev, comment.id, updater));
|
|
18156
18209
|
setReplyCache((prev) => updateReplyCacheComment(prev, comment.id, updater));
|
|
18157
18210
|
try {
|
|
18158
18211
|
await dataSource.toggleDislike(comment.id);
|
|
18159
18212
|
} catch {
|
|
18160
|
-
|
|
18161
|
-
setReplyCache(
|
|
18162
|
-
(prev) => updateReplyCacheComment(prev, comment.id, () => comment)
|
|
18163
|
-
);
|
|
18213
|
+
rollbackComment(comment);
|
|
18164
18214
|
}
|
|
18165
18215
|
}
|
|
18216
|
+
function rollbackComment(comment) {
|
|
18217
|
+
setComments((prev) => updateComment(prev, comment.id, () => comment));
|
|
18218
|
+
setReplyCache(
|
|
18219
|
+
(prev) => updateReplyCacheComment(prev, comment.id, () => comment)
|
|
18220
|
+
);
|
|
18221
|
+
}
|
|
18166
18222
|
async function handleEditComment(comment) {
|
|
18167
|
-
const
|
|
18168
|
-
if (
|
|
18169
|
-
updateCommentEverywhere(
|
|
18223
|
+
const updatedComment2 = await onEdit?.(comment);
|
|
18224
|
+
if (updatedComment2) {
|
|
18225
|
+
updateCommentEverywhere(updatedComment2.id, () => updatedComment2);
|
|
18226
|
+
}
|
|
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
|
+
);
|
|
18170
18253
|
}
|
|
18171
18254
|
}
|
|
18172
18255
|
if (loading || isLoadingComments) {
|
|
@@ -18866,36 +18949,6 @@ var TopNav = ({
|
|
|
18866
18949
|
};
|
|
18867
18950
|
return /* @__PURE__ */ jsx("div", { className: "flex items-center", children: items.map(renderNode) });
|
|
18868
18951
|
};
|
|
18869
|
-
var useDrawer = (defaultVisibility = true) => {
|
|
18870
|
-
const [show, setShow] = useState(defaultVisibility);
|
|
18871
|
-
const openDrawer = () => {
|
|
18872
|
-
setShow((prev) => !prev);
|
|
18873
|
-
};
|
|
18874
|
-
const closeDrawer = () => {
|
|
18875
|
-
setShow(false);
|
|
18876
|
-
};
|
|
18877
|
-
return {
|
|
18878
|
-
show,
|
|
18879
|
-
openDrawer,
|
|
18880
|
-
closeDrawer
|
|
18881
|
-
};
|
|
18882
|
-
};
|
|
18883
|
-
var useDrawer_default = useDrawer;
|
|
18884
|
-
var useModal = () => {
|
|
18885
|
-
const [show, setShow] = useState(false);
|
|
18886
|
-
const handleOpenModal = () => {
|
|
18887
|
-
setShow(true);
|
|
18888
|
-
};
|
|
18889
|
-
const handleCloseModal = () => {
|
|
18890
|
-
setShow(false);
|
|
18891
|
-
};
|
|
18892
|
-
return {
|
|
18893
|
-
show,
|
|
18894
|
-
handleOpenModal,
|
|
18895
|
-
handleCloseModal
|
|
18896
|
-
};
|
|
18897
|
-
};
|
|
18898
|
-
var useModal_default = useModal;
|
|
18899
18952
|
function GenericLayout({
|
|
18900
18953
|
children,
|
|
18901
18954
|
styles,
|
|
@@ -19012,6 +19065,6 @@ function ScrollToTop({
|
|
|
19012
19065
|
}
|
|
19013
19066
|
var ScrollToTop_default = ScrollToTop;
|
|
19014
19067
|
|
|
19015
|
-
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 };
|
|
19016
19069
|
//# sourceMappingURL=index.mjs.map
|
|
19017
19070
|
//# sourceMappingURL=index.mjs.map
|