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.js
CHANGED
|
@@ -3132,7 +3132,7 @@ var ShapeSwitch = () => {
|
|
|
3132
3132
|
{
|
|
3133
3133
|
value: currentShape,
|
|
3134
3134
|
onChange: handleChange,
|
|
3135
|
-
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 ",
|
|
3135
|
+
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 ",
|
|
3136
3136
|
children: Object.keys(Shape).map((shape) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: shape, children: shape }, shape))
|
|
3137
3137
|
}
|
|
3138
3138
|
) });
|
|
@@ -16126,7 +16126,7 @@ function MarkdownTOC({ title = "Table of Contents" }) {
|
|
|
16126
16126
|
/* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
16127
16127
|
"h2",
|
|
16128
16128
|
{
|
|
16129
|
-
className: "\n text-sm\n font-semibold\n uppercase\n tracking-wide\n text-gray-900\n dark:text-gray-100\n ",
|
|
16129
|
+
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 ",
|
|
16130
16130
|
children: title
|
|
16131
16131
|
}
|
|
16132
16132
|
) }),
|
|
@@ -17121,6 +17121,7 @@ var Menu = ({
|
|
|
17121
17121
|
badge: item.badge,
|
|
17122
17122
|
to: item.to,
|
|
17123
17123
|
navigate: item.navigate || navigate,
|
|
17124
|
+
onClick: item.onClick,
|
|
17124
17125
|
className: cn(
|
|
17125
17126
|
item.className,
|
|
17126
17127
|
isActive && "bg-gray-200 dark:bg-gray-800/50 text-gray-900 dark:text-gray-300"
|
|
@@ -17455,7 +17456,7 @@ var GlowWrapper = ({
|
|
|
17455
17456
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
17456
17457
|
"span",
|
|
17457
17458
|
{
|
|
17458
|
-
className: "\n pointer-events-none absolute inset-0 opacity-0 \n group-hover:opacity-100 transition-opacity duration-300\n ",
|
|
17459
|
+
className: "\r\n pointer-events-none absolute inset-0 opacity-0 \r\n group-hover:opacity-100 transition-opacity duration-300\r\n ",
|
|
17459
17460
|
style: { background: "var(--glow-bg)" }
|
|
17460
17461
|
}
|
|
17461
17462
|
),
|
|
@@ -17605,6 +17606,33 @@ function CommentContent({ comment }) {
|
|
|
17605
17606
|
}
|
|
17606
17607
|
var CommentContent_default = CommentContent;
|
|
17607
17608
|
|
|
17609
|
+
// src/compositions/comment-thread/utils/commentReaction.ts
|
|
17610
|
+
function getOptimisticLikeState(comment) {
|
|
17611
|
+
return {
|
|
17612
|
+
liked: !comment.liked,
|
|
17613
|
+
disliked: false,
|
|
17614
|
+
likes: comment.liked ? Math.max(comment.likes - 1, 0) : comment.likes + 1,
|
|
17615
|
+
dislikes: comment.disliked ? Math.max(comment.dislikes - 1, 0) : comment.dislikes
|
|
17616
|
+
};
|
|
17617
|
+
}
|
|
17618
|
+
function getOptimisticDislikeState(comment) {
|
|
17619
|
+
return {
|
|
17620
|
+
liked: false,
|
|
17621
|
+
disliked: !comment.disliked,
|
|
17622
|
+
likes: comment.liked ? Math.max(comment.likes - 1, 0) : comment.likes,
|
|
17623
|
+
dislikes: comment.disliked ? Math.max(comment.dislikes - 1, 0) : comment.dislikes + 1
|
|
17624
|
+
};
|
|
17625
|
+
}
|
|
17626
|
+
function applyReactionState(comment, reaction) {
|
|
17627
|
+
return {
|
|
17628
|
+
...comment,
|
|
17629
|
+
likes: reaction.likes,
|
|
17630
|
+
dislikes: reaction.dislikes,
|
|
17631
|
+
liked: reaction.liked,
|
|
17632
|
+
disliked: reaction.disliked
|
|
17633
|
+
};
|
|
17634
|
+
}
|
|
17635
|
+
|
|
17608
17636
|
// src/compositions/comment-thread/utils/formatCommentDate.ts
|
|
17609
17637
|
function formatCommentDate(date, format = "relative") {
|
|
17610
17638
|
const target = new Date(date);
|
|
@@ -17643,6 +17671,65 @@ function formatCommentDate(date, format = "relative") {
|
|
|
17643
17671
|
}
|
|
17644
17672
|
return "Just now";
|
|
17645
17673
|
}
|
|
17674
|
+
|
|
17675
|
+
// src/compositions/comment-thread/utils/removeComment.ts
|
|
17676
|
+
function removeComment(comments, commentId) {
|
|
17677
|
+
return comments.filter((comment) => comment.id !== commentId);
|
|
17678
|
+
}
|
|
17679
|
+
function incrementReplyCount(comments, commentId) {
|
|
17680
|
+
return comments.map(
|
|
17681
|
+
(comment) => comment.id === commentId ? {
|
|
17682
|
+
...comment,
|
|
17683
|
+
replyCount: comment.replyCount + 1
|
|
17684
|
+
} : comment
|
|
17685
|
+
);
|
|
17686
|
+
}
|
|
17687
|
+
function decrementReplyCount(comments, commentId) {
|
|
17688
|
+
return comments.map(
|
|
17689
|
+
(comment) => comment.id === commentId ? {
|
|
17690
|
+
...comment,
|
|
17691
|
+
replyCount: Math.max(comment.replyCount - 1, 0)
|
|
17692
|
+
} : comment
|
|
17693
|
+
);
|
|
17694
|
+
}
|
|
17695
|
+
|
|
17696
|
+
// src/compositions/comment-thread/utils/replyCache.ts
|
|
17697
|
+
function addReplyToCache(cache, parentCommentId, reply) {
|
|
17698
|
+
return {
|
|
17699
|
+
...cache,
|
|
17700
|
+
[parentCommentId]: [...cache[parentCommentId] ?? [], reply]
|
|
17701
|
+
};
|
|
17702
|
+
}
|
|
17703
|
+
function updateReplyCacheComment(cache, commentId, updater) {
|
|
17704
|
+
const next = {};
|
|
17705
|
+
for (const [parentId, replies] of Object.entries(cache)) {
|
|
17706
|
+
next[parentId] = replies.map(
|
|
17707
|
+
(reply) => reply.id === commentId ? updater(reply) : reply
|
|
17708
|
+
);
|
|
17709
|
+
}
|
|
17710
|
+
return next;
|
|
17711
|
+
}
|
|
17712
|
+
function removeCommentTreeFromCache(cache, commentId) {
|
|
17713
|
+
const childIds = cache[commentId]?.map((reply) => reply.id) ?? [];
|
|
17714
|
+
let next = Object.fromEntries(
|
|
17715
|
+
Object.entries(cache).map(([parentId, replies]) => [
|
|
17716
|
+
parentId,
|
|
17717
|
+
replies.filter((reply) => reply.id !== commentId)
|
|
17718
|
+
])
|
|
17719
|
+
);
|
|
17720
|
+
delete next[commentId];
|
|
17721
|
+
for (const childId of childIds) {
|
|
17722
|
+
next = removeCommentTreeFromCache(next, childId);
|
|
17723
|
+
}
|
|
17724
|
+
return next;
|
|
17725
|
+
}
|
|
17726
|
+
|
|
17727
|
+
// src/compositions/comment-thread/utils/updateComment.ts
|
|
17728
|
+
function updateComment(comments, commentId, updater) {
|
|
17729
|
+
return comments.map(
|
|
17730
|
+
(comment) => comment.id === commentId ? updater(comment) : comment
|
|
17731
|
+
);
|
|
17732
|
+
}
|
|
17646
17733
|
function CommentHeader({ comment, config }) {
|
|
17647
17734
|
const author = comment.author;
|
|
17648
17735
|
const displayName = author?.firstName || author?.lastName ? `${author?.firstName ?? ""} ${author?.lastName ?? ""}`.trim() : author?.username ?? "Unknown";
|
|
@@ -17663,6 +17750,60 @@ function CommentHeader({ comment, config }) {
|
|
|
17663
17750
|
] });
|
|
17664
17751
|
}
|
|
17665
17752
|
var CommentHeader_default = CommentHeader;
|
|
17753
|
+
var useDrawer = (defaultVisibility = true) => {
|
|
17754
|
+
const [show, setShow] = React4.useState(defaultVisibility);
|
|
17755
|
+
const openDrawer = () => {
|
|
17756
|
+
setShow((prev) => !prev);
|
|
17757
|
+
};
|
|
17758
|
+
const closeDrawer = () => {
|
|
17759
|
+
setShow(false);
|
|
17760
|
+
};
|
|
17761
|
+
return {
|
|
17762
|
+
show,
|
|
17763
|
+
openDrawer,
|
|
17764
|
+
closeDrawer
|
|
17765
|
+
};
|
|
17766
|
+
};
|
|
17767
|
+
var useDrawer_default = useDrawer;
|
|
17768
|
+
var useModal = () => {
|
|
17769
|
+
const [show, setShow] = React4.useState(false);
|
|
17770
|
+
const handleOpenModal = () => {
|
|
17771
|
+
setShow(true);
|
|
17772
|
+
};
|
|
17773
|
+
const handleCloseModal = () => {
|
|
17774
|
+
setShow(false);
|
|
17775
|
+
};
|
|
17776
|
+
return {
|
|
17777
|
+
show,
|
|
17778
|
+
handleOpenModal,
|
|
17779
|
+
handleCloseModal
|
|
17780
|
+
};
|
|
17781
|
+
};
|
|
17782
|
+
var useModal_default = useModal;
|
|
17783
|
+
function CommentMenuItem({
|
|
17784
|
+
icon,
|
|
17785
|
+
name,
|
|
17786
|
+
badge,
|
|
17787
|
+
to,
|
|
17788
|
+
navigate,
|
|
17789
|
+
className,
|
|
17790
|
+
onClick,
|
|
17791
|
+
style
|
|
17792
|
+
}) {
|
|
17793
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
17794
|
+
MenuItem,
|
|
17795
|
+
{
|
|
17796
|
+
icon,
|
|
17797
|
+
name,
|
|
17798
|
+
badge,
|
|
17799
|
+
to,
|
|
17800
|
+
navigate,
|
|
17801
|
+
onClick,
|
|
17802
|
+
style,
|
|
17803
|
+
className
|
|
17804
|
+
}
|
|
17805
|
+
);
|
|
17806
|
+
}
|
|
17666
17807
|
function CommentMenu({
|
|
17667
17808
|
open,
|
|
17668
17809
|
setOpen,
|
|
@@ -17674,17 +17815,48 @@ function CommentMenu({
|
|
|
17674
17815
|
onReport
|
|
17675
17816
|
}) {
|
|
17676
17817
|
const ref = React4.useRef(null);
|
|
17677
|
-
|
|
17678
|
-
|
|
17679
|
-
|
|
17818
|
+
useClickOutside(ref, () => setOpen(false));
|
|
17819
|
+
const items = [];
|
|
17820
|
+
if (canEdit) {
|
|
17821
|
+
items.push({
|
|
17822
|
+
type: "item",
|
|
17823
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(bi.BiEdit, {}),
|
|
17824
|
+
name: "Edit",
|
|
17825
|
+
component: CommentMenuItem,
|
|
17826
|
+
onClick: () => {
|
|
17680
17827
|
setOpen(false);
|
|
17681
|
-
|
|
17682
|
-
|
|
17683
|
-
|
|
17684
|
-
|
|
17685
|
-
}
|
|
17686
|
-
|
|
17687
|
-
|
|
17828
|
+
onEdit?.();
|
|
17829
|
+
},
|
|
17830
|
+
className: "flex w-full items-center gap-2 px-4 py-3 text-sm hover:bg-gray-100 dark:hover:bg-neutral-800"
|
|
17831
|
+
});
|
|
17832
|
+
}
|
|
17833
|
+
if (canDelete) {
|
|
17834
|
+
items.push({
|
|
17835
|
+
type: "item",
|
|
17836
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(bi.BiTrash, {}),
|
|
17837
|
+
name: "Delete",
|
|
17838
|
+
component: CommentMenuItem,
|
|
17839
|
+
onClick: () => {
|
|
17840
|
+
setOpen(false);
|
|
17841
|
+
onDelete?.();
|
|
17842
|
+
},
|
|
17843
|
+
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"
|
|
17844
|
+
});
|
|
17845
|
+
}
|
|
17846
|
+
if (canReport) {
|
|
17847
|
+
items.push({
|
|
17848
|
+
type: "item",
|
|
17849
|
+
icon: /* @__PURE__ */ jsxRuntime.jsx(bi.BiFlag, {}),
|
|
17850
|
+
name: "Report",
|
|
17851
|
+
component: CommentMenuItem,
|
|
17852
|
+
onClick: () => {
|
|
17853
|
+
setOpen(false);
|
|
17854
|
+
onReport?.();
|
|
17855
|
+
},
|
|
17856
|
+
className: "flex w-full items-center gap-2 px-4 py-3 text-sm hover:bg-gray-100 dark:hover:bg-neutral-800"
|
|
17857
|
+
});
|
|
17858
|
+
}
|
|
17859
|
+
if (!items.length) {
|
|
17688
17860
|
return null;
|
|
17689
17861
|
}
|
|
17690
17862
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, className: "relative", children: [
|
|
@@ -17697,53 +17869,7 @@ function CommentMenu({
|
|
|
17697
17869
|
children: /* @__PURE__ */ jsxRuntime.jsx(bi.BiDotsVerticalRounded, { size: 18 })
|
|
17698
17870
|
}
|
|
17699
17871
|
),
|
|
17700
|
-
open
|
|
17701
|
-
canEdit && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
17702
|
-
"button",
|
|
17703
|
-
{
|
|
17704
|
-
type: "button",
|
|
17705
|
-
onClick: () => {
|
|
17706
|
-
setOpen(false);
|
|
17707
|
-
onEdit?.();
|
|
17708
|
-
},
|
|
17709
|
-
className: "flex w-full items-center gap-2 px-4 py-3 text-sm hover:bg-gray-100 dark:hover:bg-neutral-800",
|
|
17710
|
-
children: [
|
|
17711
|
-
/* @__PURE__ */ jsxRuntime.jsx(bi.BiEdit, {}),
|
|
17712
|
-
"Edit"
|
|
17713
|
-
]
|
|
17714
|
-
}
|
|
17715
|
-
),
|
|
17716
|
-
canDelete && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
17717
|
-
"button",
|
|
17718
|
-
{
|
|
17719
|
-
type: "button",
|
|
17720
|
-
onClick: () => {
|
|
17721
|
-
setOpen(false);
|
|
17722
|
-
onDelete?.();
|
|
17723
|
-
},
|
|
17724
|
-
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",
|
|
17725
|
-
children: [
|
|
17726
|
-
/* @__PURE__ */ jsxRuntime.jsx(bi.BiTrash, {}),
|
|
17727
|
-
"Delete"
|
|
17728
|
-
]
|
|
17729
|
-
}
|
|
17730
|
-
),
|
|
17731
|
-
canReport && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
17732
|
-
"button",
|
|
17733
|
-
{
|
|
17734
|
-
type: "button",
|
|
17735
|
-
onClick: () => {
|
|
17736
|
-
setOpen(false);
|
|
17737
|
-
onReport?.();
|
|
17738
|
-
},
|
|
17739
|
-
className: "flex w-full items-center gap-2 px-4 py-3 text-sm hover:bg-gray-100 dark:hover:bg-neutral-800",
|
|
17740
|
-
children: [
|
|
17741
|
-
/* @__PURE__ */ jsxRuntime.jsx(bi.BiFlag, {}),
|
|
17742
|
-
"Report"
|
|
17743
|
-
]
|
|
17744
|
-
}
|
|
17745
|
-
)
|
|
17746
|
-
] })
|
|
17872
|
+
/* @__PURE__ */ jsxRuntime.jsx(Transition4.TransitionDropdown, { visibility: open, children: /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsx(Menu, { items }) }) })
|
|
17747
17873
|
] });
|
|
17748
17874
|
}
|
|
17749
17875
|
var CommentMenu_default = CommentMenu;
|
|
@@ -17964,13 +18090,6 @@ function CommentList({
|
|
|
17964
18090
|
}
|
|
17965
18091
|
var CommentList_default = CommentList;
|
|
17966
18092
|
|
|
17967
|
-
// src/compositions/comment-thread/utils/updateComment.ts
|
|
17968
|
-
function updateComment(comments, commentId, updater) {
|
|
17969
|
-
return comments.map(
|
|
17970
|
-
(comment) => comment.id === commentId ? updater(comment) : comment
|
|
17971
|
-
);
|
|
17972
|
-
}
|
|
17973
|
-
|
|
17974
18093
|
// src/compositions/comment-thread/constants/comment.constants.ts
|
|
17975
18094
|
var DEFAULT_COMMENT_THREAD_CONFIG = {
|
|
17976
18095
|
maxDepth: 5,
|
|
@@ -17986,6 +18105,7 @@ function CommentThread({
|
|
|
17986
18105
|
components,
|
|
17987
18106
|
config,
|
|
17988
18107
|
updatedComment,
|
|
18108
|
+
deletedComment,
|
|
17989
18109
|
onEdit,
|
|
17990
18110
|
onDelete,
|
|
17991
18111
|
onReport
|
|
@@ -18013,7 +18133,7 @@ function CommentThread({
|
|
|
18013
18133
|
setIsLoadingComments(false);
|
|
18014
18134
|
}
|
|
18015
18135
|
}
|
|
18016
|
-
loadComments();
|
|
18136
|
+
void loadComments();
|
|
18017
18137
|
}, [dataSource, resolvedConfig.commentsPerPage]);
|
|
18018
18138
|
React4.useEffect(() => {
|
|
18019
18139
|
replyCacheRef.current = replyCache;
|
|
@@ -18054,29 +18174,18 @@ function CommentThread({
|
|
|
18054
18174
|
cancelled = true;
|
|
18055
18175
|
};
|
|
18056
18176
|
}, [dataSource, resolvedConfig.repliesPerPage]);
|
|
18057
|
-
|
|
18058
|
-
|
|
18059
|
-
|
|
18060
|
-
next[parentId] = replies.map(
|
|
18061
|
-
(reply) => reply.id === commentId ? updater(reply) : reply
|
|
18062
|
-
);
|
|
18177
|
+
React4.useEffect(() => {
|
|
18178
|
+
if (!updatedComment) {
|
|
18179
|
+
return;
|
|
18063
18180
|
}
|
|
18064
|
-
|
|
18065
|
-
}
|
|
18066
|
-
|
|
18067
|
-
|
|
18068
|
-
|
|
18069
|
-
Object.entries(cache).map(([parentId, replies]) => [
|
|
18070
|
-
parentId,
|
|
18071
|
-
replies.filter((reply) => reply.id !== commentId)
|
|
18072
|
-
])
|
|
18073
|
-
);
|
|
18074
|
-
delete next[commentId];
|
|
18075
|
-
for (const childId of childIds) {
|
|
18076
|
-
next = removeCommentTreeFromCache(next, childId);
|
|
18181
|
+
updateCommentEverywhere(updatedComment.id, () => updatedComment);
|
|
18182
|
+
}, [updatedComment]);
|
|
18183
|
+
React4.useEffect(() => {
|
|
18184
|
+
if (!deletedComment) {
|
|
18185
|
+
return;
|
|
18077
18186
|
}
|
|
18078
|
-
|
|
18079
|
-
}
|
|
18187
|
+
removeCommentEverywhere(deletedComment);
|
|
18188
|
+
}, [deletedComment]);
|
|
18080
18189
|
async function handleCreateComment(content) {
|
|
18081
18190
|
const comment = await dataSource.createComment({
|
|
18082
18191
|
content,
|
|
@@ -18084,51 +18193,13 @@ function CommentThread({
|
|
|
18084
18193
|
});
|
|
18085
18194
|
setComments((prev) => [comment, ...prev]);
|
|
18086
18195
|
}
|
|
18087
|
-
async function handleDeleteComment(comment) {
|
|
18088
|
-
await dataSource.deleteComment(comment.id);
|
|
18089
|
-
setComments((prev) => prev.filter((item) => item.id !== comment.id));
|
|
18090
|
-
setReplyCache((prev) => removeCommentTreeFromCache(prev, comment.id));
|
|
18091
|
-
if (comment.parentCommentId) {
|
|
18092
|
-
setComments(
|
|
18093
|
-
(prev) => updateComment(prev, comment.parentCommentId, (item) => ({
|
|
18094
|
-
...item,
|
|
18095
|
-
replyCount: Math.max(item.replyCount - 1, 0)
|
|
18096
|
-
}))
|
|
18097
|
-
);
|
|
18098
|
-
setReplyCache(
|
|
18099
|
-
(prev) => updateReplyCacheComment(prev, comment.parentCommentId, (item) => ({
|
|
18100
|
-
...item,
|
|
18101
|
-
replyCount: Math.max(item.replyCount - 1, 0)
|
|
18102
|
-
}))
|
|
18103
|
-
);
|
|
18104
|
-
}
|
|
18105
|
-
}
|
|
18106
|
-
function updateCommentEverywhere(commentId, updater) {
|
|
18107
|
-
setComments((prev) => updateComment(prev, commentId, updater));
|
|
18108
|
-
setReplyCache((prev) => updateReplyCacheComment(prev, commentId, updater));
|
|
18109
|
-
}
|
|
18110
|
-
React4.useEffect(() => {
|
|
18111
|
-
if (!updatedComment) {
|
|
18112
|
-
return;
|
|
18113
|
-
}
|
|
18114
|
-
updateCommentEverywhere(updatedComment.id, () => updatedComment);
|
|
18115
|
-
}, [updatedComment]);
|
|
18116
18196
|
async function handleReply(parentComment, content) {
|
|
18117
18197
|
const reply = await dataSource.createComment({
|
|
18118
18198
|
content,
|
|
18119
18199
|
parentCommentId: parentComment.id
|
|
18120
18200
|
});
|
|
18121
|
-
setReplyCache((prev) => (
|
|
18122
|
-
|
|
18123
|
-
[parentComment.id]: [...prev[parentComment.id] ?? [], reply]
|
|
18124
|
-
}));
|
|
18125
|
-
const incrementReplyCount = (items) => items.map(
|
|
18126
|
-
(item) => item.id === parentComment.id ? {
|
|
18127
|
-
...item,
|
|
18128
|
-
replyCount: item.replyCount + 1
|
|
18129
|
-
} : item
|
|
18130
|
-
);
|
|
18131
|
-
setComments((prev) => incrementReplyCount(prev));
|
|
18201
|
+
setReplyCache((prev) => addReplyToCache(prev, parentComment.id, reply));
|
|
18202
|
+
setComments((prev) => incrementReplyCount(prev, parentComment.id));
|
|
18132
18203
|
setReplyCache(
|
|
18133
18204
|
(prev) => updateReplyCacheComment(prev, parentComment.id, (item) => ({
|
|
18134
18205
|
...item,
|
|
@@ -18149,61 +18220,66 @@ function CommentThread({
|
|
|
18149
18220
|
}));
|
|
18150
18221
|
}
|
|
18151
18222
|
async function handleLike(comment) {
|
|
18152
|
-
const optimistic =
|
|
18153
|
-
|
|
18154
|
-
disliked: false,
|
|
18155
|
-
likes: comment.liked ? Math.max(comment.likes - 1, 0) : comment.likes + 1,
|
|
18156
|
-
dislikes: comment.disliked ? Math.max(comment.dislikes - 1, 0) : comment.dislikes
|
|
18157
|
-
};
|
|
18158
|
-
const updater = (item) => ({
|
|
18159
|
-
...item,
|
|
18160
|
-
likes: optimistic.likes,
|
|
18161
|
-
dislikes: optimistic.dislikes,
|
|
18162
|
-
liked: optimistic.liked,
|
|
18163
|
-
disliked: optimistic.disliked
|
|
18164
|
-
});
|
|
18223
|
+
const optimistic = getOptimisticLikeState(comment);
|
|
18224
|
+
const updater = (item) => applyReactionState(item, optimistic);
|
|
18165
18225
|
setComments((prev) => updateComment(prev, comment.id, updater));
|
|
18166
18226
|
setReplyCache((prev) => updateReplyCacheComment(prev, comment.id, updater));
|
|
18167
18227
|
try {
|
|
18168
18228
|
await dataSource.toggleLike(comment.id);
|
|
18169
18229
|
} catch {
|
|
18170
|
-
|
|
18171
|
-
setReplyCache(
|
|
18172
|
-
(prev) => updateReplyCacheComment(prev, comment.id, () => comment)
|
|
18173
|
-
);
|
|
18230
|
+
rollbackComment(comment);
|
|
18174
18231
|
}
|
|
18175
18232
|
}
|
|
18176
18233
|
async function handleDislike(comment) {
|
|
18177
|
-
const optimistic =
|
|
18178
|
-
|
|
18179
|
-
disliked: !comment.disliked,
|
|
18180
|
-
likes: comment.liked ? Math.max(comment.likes - 1, 0) : comment.likes,
|
|
18181
|
-
dislikes: comment.disliked ? Math.max(comment.dislikes - 1, 0) : comment.dislikes + 1
|
|
18182
|
-
};
|
|
18183
|
-
const updater = (item) => ({
|
|
18184
|
-
...item,
|
|
18185
|
-
likes: optimistic.likes,
|
|
18186
|
-
dislikes: optimistic.dislikes,
|
|
18187
|
-
liked: optimistic.liked,
|
|
18188
|
-
disliked: optimistic.disliked
|
|
18189
|
-
});
|
|
18234
|
+
const optimistic = getOptimisticDislikeState(comment);
|
|
18235
|
+
const updater = (item) => applyReactionState(item, optimistic);
|
|
18190
18236
|
setComments((prev) => updateComment(prev, comment.id, updater));
|
|
18191
18237
|
setReplyCache((prev) => updateReplyCacheComment(prev, comment.id, updater));
|
|
18192
18238
|
try {
|
|
18193
18239
|
await dataSource.toggleDislike(comment.id);
|
|
18194
18240
|
} catch {
|
|
18195
|
-
|
|
18196
|
-
setReplyCache(
|
|
18197
|
-
(prev) => updateReplyCacheComment(prev, comment.id, () => comment)
|
|
18198
|
-
);
|
|
18241
|
+
rollbackComment(comment);
|
|
18199
18242
|
}
|
|
18200
18243
|
}
|
|
18244
|
+
function rollbackComment(comment) {
|
|
18245
|
+
setComments((prev) => updateComment(prev, comment.id, () => comment));
|
|
18246
|
+
setReplyCache(
|
|
18247
|
+
(prev) => updateReplyCacheComment(prev, comment.id, () => comment)
|
|
18248
|
+
);
|
|
18249
|
+
}
|
|
18201
18250
|
async function handleEditComment(comment) {
|
|
18202
18251
|
const updatedComment2 = await onEdit?.(comment);
|
|
18203
18252
|
if (updatedComment2) {
|
|
18204
18253
|
updateCommentEverywhere(updatedComment2.id, () => updatedComment2);
|
|
18205
18254
|
}
|
|
18206
18255
|
}
|
|
18256
|
+
function updateCommentEverywhere(commentId, updater) {
|
|
18257
|
+
setComments((prev) => updateComment(prev, commentId, updater));
|
|
18258
|
+
setReplyCache((prev) => updateReplyCacheComment(prev, commentId, updater));
|
|
18259
|
+
}
|
|
18260
|
+
async function handleDeleteComment(comment) {
|
|
18261
|
+
if (onDelete) {
|
|
18262
|
+
onDelete(comment);
|
|
18263
|
+
return;
|
|
18264
|
+
}
|
|
18265
|
+
await dataSource.deleteComment(comment.id);
|
|
18266
|
+
removeCommentEverywhere(comment);
|
|
18267
|
+
}
|
|
18268
|
+
function removeCommentEverywhere(comment) {
|
|
18269
|
+
setComments((prev) => removeComment(prev, comment.id));
|
|
18270
|
+
setReplyCache((prev) => removeCommentTreeFromCache(prev, comment.id));
|
|
18271
|
+
if (comment.parentCommentId) {
|
|
18272
|
+
setComments(
|
|
18273
|
+
(prev) => decrementReplyCount(prev, comment.parentCommentId)
|
|
18274
|
+
);
|
|
18275
|
+
setReplyCache(
|
|
18276
|
+
(prev) => updateReplyCacheComment(prev, comment.parentCommentId, (item) => ({
|
|
18277
|
+
...item,
|
|
18278
|
+
replyCount: Math.max(item.replyCount - 1, 0)
|
|
18279
|
+
}))
|
|
18280
|
+
);
|
|
18281
|
+
}
|
|
18282
|
+
}
|
|
18207
18283
|
if (loading || isLoadingComments) {
|
|
18208
18284
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-6", children: "Loading comments..." });
|
|
18209
18285
|
}
|
|
@@ -18901,36 +18977,6 @@ var TopNav = ({
|
|
|
18901
18977
|
};
|
|
18902
18978
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center", children: items.map(renderNode) });
|
|
18903
18979
|
};
|
|
18904
|
-
var useDrawer = (defaultVisibility = true) => {
|
|
18905
|
-
const [show, setShow] = React4.useState(defaultVisibility);
|
|
18906
|
-
const openDrawer = () => {
|
|
18907
|
-
setShow((prev) => !prev);
|
|
18908
|
-
};
|
|
18909
|
-
const closeDrawer = () => {
|
|
18910
|
-
setShow(false);
|
|
18911
|
-
};
|
|
18912
|
-
return {
|
|
18913
|
-
show,
|
|
18914
|
-
openDrawer,
|
|
18915
|
-
closeDrawer
|
|
18916
|
-
};
|
|
18917
|
-
};
|
|
18918
|
-
var useDrawer_default = useDrawer;
|
|
18919
|
-
var useModal = () => {
|
|
18920
|
-
const [show, setShow] = React4.useState(false);
|
|
18921
|
-
const handleOpenModal = () => {
|
|
18922
|
-
setShow(true);
|
|
18923
|
-
};
|
|
18924
|
-
const handleCloseModal = () => {
|
|
18925
|
-
setShow(false);
|
|
18926
|
-
};
|
|
18927
|
-
return {
|
|
18928
|
-
show,
|
|
18929
|
-
handleOpenModal,
|
|
18930
|
-
handleCloseModal
|
|
18931
|
-
};
|
|
18932
|
-
};
|
|
18933
|
-
var useModal_default = useModal;
|
|
18934
18980
|
function GenericLayout({
|
|
18935
18981
|
children,
|
|
18936
18982
|
styles,
|
|
@@ -19188,21 +19234,31 @@ exports.ValueBadge = ValueBadge_default;
|
|
|
19188
19234
|
exports.WorldMap = WorldMap;
|
|
19189
19235
|
exports.WorldMapCountryTable = WorldMapCountryTable;
|
|
19190
19236
|
exports.YoutubeVideoPlayer = YoutubeVideo_default;
|
|
19237
|
+
exports.addReplyToCache = addReplyToCache;
|
|
19238
|
+
exports.applyReactionState = applyReactionState;
|
|
19191
19239
|
exports.cn = cn;
|
|
19192
19240
|
exports.createForceLayout = createForceLayout;
|
|
19193
19241
|
exports.createGridLayout = createGridLayout;
|
|
19194
19242
|
exports.createTreeLayout = createTreeLayout;
|
|
19243
|
+
exports.decrementReplyCount = decrementReplyCount;
|
|
19195
19244
|
exports.enumValues = enumValues;
|
|
19196
19245
|
exports.formatCommentDate = formatCommentDate;
|
|
19197
19246
|
exports.getCurrencySymbol = getCurrencySymbol;
|
|
19198
19247
|
exports.getLayout = getLayout;
|
|
19248
|
+
exports.getOptimisticDislikeState = getOptimisticDislikeState;
|
|
19249
|
+
exports.getOptimisticLikeState = getOptimisticLikeState;
|
|
19250
|
+
exports.incrementReplyCount = incrementReplyCount;
|
|
19199
19251
|
exports.isMatch = isMatch;
|
|
19200
19252
|
exports.isRenderFn = isRenderFn;
|
|
19201
19253
|
exports.normalize = normalize;
|
|
19202
19254
|
exports.registerLayout = registerLayout;
|
|
19255
|
+
exports.removeComment = removeComment;
|
|
19256
|
+
exports.removeCommentTreeFromCache = removeCommentTreeFromCache;
|
|
19203
19257
|
exports.resolveAppearanceStyles = resolveAppearanceStyles;
|
|
19204
19258
|
exports.resolveWithGlobal = resolveWithGlobal;
|
|
19205
19259
|
exports.sendToast = sendToast;
|
|
19260
|
+
exports.updateComment = updateComment;
|
|
19261
|
+
exports.updateReplyCacheComment = updateReplyCacheComment;
|
|
19206
19262
|
exports.useClickOutside = useClickOutside;
|
|
19207
19263
|
exports.useCloudinaryConfig = useCloudinaryConfig;
|
|
19208
19264
|
exports.useCurrentTheme = useCurrentTheme_default;
|