elseware-ui 2.31.16 → 2.32.0

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.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
  ),
@@ -17465,6 +17466,41 @@ var GlowWrapper = ({
17465
17466
  );
17466
17467
  };
17467
17468
  var GlowWrapper_default = GlowWrapper;
17469
+ function InfiniteScrollTrigger({
17470
+ children,
17471
+ className,
17472
+ hasMore = false,
17473
+ isLoading = false,
17474
+ rootMargin = "600px",
17475
+ threshold = 0,
17476
+ onLoadMore
17477
+ }) {
17478
+ const triggerRef = React4.useRef(null);
17479
+ React4.useEffect(() => {
17480
+ const element = triggerRef.current;
17481
+ if (!element || !hasMore || isLoading) {
17482
+ return;
17483
+ }
17484
+ const observer = new IntersectionObserver(
17485
+ ([entry]) => {
17486
+ if (entry?.isIntersecting) {
17487
+ onLoadMore?.();
17488
+ }
17489
+ },
17490
+ {
17491
+ root: null,
17492
+ rootMargin,
17493
+ threshold
17494
+ }
17495
+ );
17496
+ observer.observe(element);
17497
+ return () => {
17498
+ observer.disconnect();
17499
+ };
17500
+ }, [hasMore, isLoading, onLoadMore, rootMargin, threshold]);
17501
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { ref: triggerRef, className: cn("w-full", className), children });
17502
+ }
17503
+ var InfiniteScrollTrigger_default = InfiniteScrollTrigger;
17468
17504
  function ShowMore({ text, limit }) {
17469
17505
  const [showMore, setShowMore] = React4.useState(false);
17470
17506
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
@@ -17605,6 +17641,33 @@ function CommentContent({ comment }) {
17605
17641
  }
17606
17642
  var CommentContent_default = CommentContent;
17607
17643
 
17644
+ // src/compositions/comment-thread/utils/commentReaction.ts
17645
+ function getOptimisticLikeState(comment) {
17646
+ return {
17647
+ liked: !comment.liked,
17648
+ disliked: false,
17649
+ likes: comment.liked ? Math.max(comment.likes - 1, 0) : comment.likes + 1,
17650
+ dislikes: comment.disliked ? Math.max(comment.dislikes - 1, 0) : comment.dislikes
17651
+ };
17652
+ }
17653
+ function getOptimisticDislikeState(comment) {
17654
+ return {
17655
+ liked: false,
17656
+ disliked: !comment.disliked,
17657
+ likes: comment.liked ? Math.max(comment.likes - 1, 0) : comment.likes,
17658
+ dislikes: comment.disliked ? Math.max(comment.dislikes - 1, 0) : comment.dislikes + 1
17659
+ };
17660
+ }
17661
+ function applyReactionState(comment, reaction) {
17662
+ return {
17663
+ ...comment,
17664
+ likes: reaction.likes,
17665
+ dislikes: reaction.dislikes,
17666
+ liked: reaction.liked,
17667
+ disliked: reaction.disliked
17668
+ };
17669
+ }
17670
+
17608
17671
  // src/compositions/comment-thread/utils/formatCommentDate.ts
17609
17672
  function formatCommentDate(date, format = "relative") {
17610
17673
  const target = new Date(date);
@@ -17643,6 +17706,65 @@ function formatCommentDate(date, format = "relative") {
17643
17706
  }
17644
17707
  return "Just now";
17645
17708
  }
17709
+
17710
+ // src/compositions/comment-thread/utils/removeComment.ts
17711
+ function removeComment(comments, commentId) {
17712
+ return comments.filter((comment) => comment.id !== commentId);
17713
+ }
17714
+ function incrementReplyCount(comments, commentId) {
17715
+ return comments.map(
17716
+ (comment) => comment.id === commentId ? {
17717
+ ...comment,
17718
+ replyCount: comment.replyCount + 1
17719
+ } : comment
17720
+ );
17721
+ }
17722
+ function decrementReplyCount(comments, commentId) {
17723
+ return comments.map(
17724
+ (comment) => comment.id === commentId ? {
17725
+ ...comment,
17726
+ replyCount: Math.max(comment.replyCount - 1, 0)
17727
+ } : comment
17728
+ );
17729
+ }
17730
+
17731
+ // src/compositions/comment-thread/utils/replyCache.ts
17732
+ function addReplyToCache(cache, parentCommentId, reply) {
17733
+ return {
17734
+ ...cache,
17735
+ [parentCommentId]: [...cache[parentCommentId] ?? [], reply]
17736
+ };
17737
+ }
17738
+ function updateReplyCacheComment(cache, commentId, updater) {
17739
+ const next = {};
17740
+ for (const [parentId, replies] of Object.entries(cache)) {
17741
+ next[parentId] = replies.map(
17742
+ (reply) => reply.id === commentId ? updater(reply) : reply
17743
+ );
17744
+ }
17745
+ return next;
17746
+ }
17747
+ function removeCommentTreeFromCache(cache, commentId) {
17748
+ const childIds = cache[commentId]?.map((reply) => reply.id) ?? [];
17749
+ let next = Object.fromEntries(
17750
+ Object.entries(cache).map(([parentId, replies]) => [
17751
+ parentId,
17752
+ replies.filter((reply) => reply.id !== commentId)
17753
+ ])
17754
+ );
17755
+ delete next[commentId];
17756
+ for (const childId of childIds) {
17757
+ next = removeCommentTreeFromCache(next, childId);
17758
+ }
17759
+ return next;
17760
+ }
17761
+
17762
+ // src/compositions/comment-thread/utils/updateComment.ts
17763
+ function updateComment(comments, commentId, updater) {
17764
+ return comments.map(
17765
+ (comment) => comment.id === commentId ? updater(comment) : comment
17766
+ );
17767
+ }
17646
17768
  function CommentHeader({ comment, config }) {
17647
17769
  const author = comment.author;
17648
17770
  const displayName = author?.firstName || author?.lastName ? `${author?.firstName ?? ""} ${author?.lastName ?? ""}`.trim() : author?.username ?? "Unknown";
@@ -17663,6 +17785,60 @@ function CommentHeader({ comment, config }) {
17663
17785
  ] });
17664
17786
  }
17665
17787
  var CommentHeader_default = CommentHeader;
17788
+ var useDrawer = (defaultVisibility = true) => {
17789
+ const [show, setShow] = React4.useState(defaultVisibility);
17790
+ const openDrawer = () => {
17791
+ setShow((prev) => !prev);
17792
+ };
17793
+ const closeDrawer = () => {
17794
+ setShow(false);
17795
+ };
17796
+ return {
17797
+ show,
17798
+ openDrawer,
17799
+ closeDrawer
17800
+ };
17801
+ };
17802
+ var useDrawer_default = useDrawer;
17803
+ var useModal = () => {
17804
+ const [show, setShow] = React4.useState(false);
17805
+ const handleOpenModal = () => {
17806
+ setShow(true);
17807
+ };
17808
+ const handleCloseModal = () => {
17809
+ setShow(false);
17810
+ };
17811
+ return {
17812
+ show,
17813
+ handleOpenModal,
17814
+ handleCloseModal
17815
+ };
17816
+ };
17817
+ var useModal_default = useModal;
17818
+ function CommentMenuItem({
17819
+ icon,
17820
+ name,
17821
+ badge,
17822
+ to,
17823
+ navigate,
17824
+ className,
17825
+ onClick,
17826
+ style
17827
+ }) {
17828
+ return /* @__PURE__ */ jsxRuntime.jsx(
17829
+ MenuItem,
17830
+ {
17831
+ icon,
17832
+ name,
17833
+ badge,
17834
+ to,
17835
+ navigate,
17836
+ onClick,
17837
+ style,
17838
+ className
17839
+ }
17840
+ );
17841
+ }
17666
17842
  function CommentMenu({
17667
17843
  open,
17668
17844
  setOpen,
@@ -17674,17 +17850,48 @@ function CommentMenu({
17674
17850
  onReport
17675
17851
  }) {
17676
17852
  const ref = React4.useRef(null);
17677
- React4.useEffect(() => {
17678
- function handleOutsideClick(event) {
17679
- if (ref.current && !ref.current.contains(event.target)) {
17853
+ useClickOutside(ref, () => setOpen(false));
17854
+ const items = [];
17855
+ if (canEdit) {
17856
+ items.push({
17857
+ type: "item",
17858
+ icon: /* @__PURE__ */ jsxRuntime.jsx(bi.BiEdit, {}),
17859
+ name: "Edit",
17860
+ component: CommentMenuItem,
17861
+ onClick: () => {
17680
17862
  setOpen(false);
17681
- }
17682
- }
17683
- document.addEventListener("mousedown", handleOutsideClick);
17684
- return () => document.removeEventListener("mousedown", handleOutsideClick);
17685
- }, [setOpen]);
17686
- const hasActions = canEdit || canDelete || canReport;
17687
- if (!hasActions) {
17863
+ onEdit?.();
17864
+ },
17865
+ className: "flex w-full items-center gap-2 px-4 py-3 text-sm hover:bg-gray-100 dark:hover:bg-neutral-800"
17866
+ });
17867
+ }
17868
+ if (canDelete) {
17869
+ items.push({
17870
+ type: "item",
17871
+ icon: /* @__PURE__ */ jsxRuntime.jsx(bi.BiTrash, {}),
17872
+ name: "Delete",
17873
+ component: CommentMenuItem,
17874
+ onClick: () => {
17875
+ setOpen(false);
17876
+ onDelete?.();
17877
+ },
17878
+ 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"
17879
+ });
17880
+ }
17881
+ if (canReport) {
17882
+ items.push({
17883
+ type: "item",
17884
+ icon: /* @__PURE__ */ jsxRuntime.jsx(bi.BiFlag, {}),
17885
+ name: "Report",
17886
+ component: CommentMenuItem,
17887
+ onClick: () => {
17888
+ setOpen(false);
17889
+ onReport?.();
17890
+ },
17891
+ className: "flex w-full items-center gap-2 px-4 py-3 text-sm hover:bg-gray-100 dark:hover:bg-neutral-800"
17892
+ });
17893
+ }
17894
+ if (!items.length) {
17688
17895
  return null;
17689
17896
  }
17690
17897
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref, className: "relative", children: [
@@ -17697,53 +17904,7 @@ function CommentMenu({
17697
17904
  children: /* @__PURE__ */ jsxRuntime.jsx(bi.BiDotsVerticalRounded, { size: 18 })
17698
17905
  }
17699
17906
  ),
17700
- open && /* @__PURE__ */ jsxRuntime.jsxs("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: [
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
- ] })
17907
+ /* @__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
17908
  ] });
17748
17909
  }
17749
17910
  var CommentMenu_default = CommentMenu;
@@ -17964,13 +18125,6 @@ function CommentList({
17964
18125
  }
17965
18126
  var CommentList_default = CommentList;
17966
18127
 
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
18128
  // src/compositions/comment-thread/constants/comment.constants.ts
17975
18129
  var DEFAULT_COMMENT_THREAD_CONFIG = {
17976
18130
  maxDepth: 5,
@@ -17986,6 +18140,7 @@ function CommentThread({
17986
18140
  components,
17987
18141
  config,
17988
18142
  updatedComment,
18143
+ deletedComment,
17989
18144
  onEdit,
17990
18145
  onDelete,
17991
18146
  onReport
@@ -18013,7 +18168,7 @@ function CommentThread({
18013
18168
  setIsLoadingComments(false);
18014
18169
  }
18015
18170
  }
18016
- loadComments();
18171
+ void loadComments();
18017
18172
  }, [dataSource, resolvedConfig.commentsPerPage]);
18018
18173
  React4.useEffect(() => {
18019
18174
  replyCacheRef.current = replyCache;
@@ -18054,29 +18209,18 @@ function CommentThread({
18054
18209
  cancelled = true;
18055
18210
  };
18056
18211
  }, [dataSource, resolvedConfig.repliesPerPage]);
18057
- function updateReplyCacheComment(cache, commentId, updater) {
18058
- const next = {};
18059
- for (const [parentId, replies] of Object.entries(cache)) {
18060
- next[parentId] = replies.map(
18061
- (reply) => reply.id === commentId ? updater(reply) : reply
18062
- );
18212
+ React4.useEffect(() => {
18213
+ if (!updatedComment) {
18214
+ return;
18063
18215
  }
18064
- return next;
18065
- }
18066
- function removeCommentTreeFromCache(cache, commentId) {
18067
- const childIds = cache[commentId]?.map((reply) => reply.id) ?? [];
18068
- let next = Object.fromEntries(
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);
18216
+ updateCommentEverywhere(updatedComment.id, () => updatedComment);
18217
+ }, [updatedComment]);
18218
+ React4.useEffect(() => {
18219
+ if (!deletedComment) {
18220
+ return;
18077
18221
  }
18078
- return next;
18079
- }
18222
+ removeCommentEverywhere(deletedComment);
18223
+ }, [deletedComment]);
18080
18224
  async function handleCreateComment(content) {
18081
18225
  const comment = await dataSource.createComment({
18082
18226
  content,
@@ -18084,51 +18228,13 @@ function CommentThread({
18084
18228
  });
18085
18229
  setComments((prev) => [comment, ...prev]);
18086
18230
  }
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
18231
  async function handleReply(parentComment, content) {
18117
18232
  const reply = await dataSource.createComment({
18118
18233
  content,
18119
18234
  parentCommentId: parentComment.id
18120
18235
  });
18121
- setReplyCache((prev) => ({
18122
- ...prev,
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));
18236
+ setReplyCache((prev) => addReplyToCache(prev, parentComment.id, reply));
18237
+ setComments((prev) => incrementReplyCount(prev, parentComment.id));
18132
18238
  setReplyCache(
18133
18239
  (prev) => updateReplyCacheComment(prev, parentComment.id, (item) => ({
18134
18240
  ...item,
@@ -18149,61 +18255,66 @@ function CommentThread({
18149
18255
  }));
18150
18256
  }
18151
18257
  async function handleLike(comment) {
18152
- const optimistic = {
18153
- liked: !comment.liked,
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
- });
18258
+ const optimistic = getOptimisticLikeState(comment);
18259
+ const updater = (item) => applyReactionState(item, optimistic);
18165
18260
  setComments((prev) => updateComment(prev, comment.id, updater));
18166
18261
  setReplyCache((prev) => updateReplyCacheComment(prev, comment.id, updater));
18167
18262
  try {
18168
18263
  await dataSource.toggleLike(comment.id);
18169
18264
  } catch {
18170
- setComments((prev) => updateComment(prev, comment.id, () => comment));
18171
- setReplyCache(
18172
- (prev) => updateReplyCacheComment(prev, comment.id, () => comment)
18173
- );
18265
+ rollbackComment(comment);
18174
18266
  }
18175
18267
  }
18176
18268
  async function handleDislike(comment) {
18177
- const optimistic = {
18178
- liked: false,
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
- });
18269
+ const optimistic = getOptimisticDislikeState(comment);
18270
+ const updater = (item) => applyReactionState(item, optimistic);
18190
18271
  setComments((prev) => updateComment(prev, comment.id, updater));
18191
18272
  setReplyCache((prev) => updateReplyCacheComment(prev, comment.id, updater));
18192
18273
  try {
18193
18274
  await dataSource.toggleDislike(comment.id);
18194
18275
  } catch {
18195
- setComments((prev) => updateComment(prev, comment.id, () => comment));
18196
- setReplyCache(
18197
- (prev) => updateReplyCacheComment(prev, comment.id, () => comment)
18198
- );
18276
+ rollbackComment(comment);
18199
18277
  }
18200
18278
  }
18279
+ function rollbackComment(comment) {
18280
+ setComments((prev) => updateComment(prev, comment.id, () => comment));
18281
+ setReplyCache(
18282
+ (prev) => updateReplyCacheComment(prev, comment.id, () => comment)
18283
+ );
18284
+ }
18201
18285
  async function handleEditComment(comment) {
18202
18286
  const updatedComment2 = await onEdit?.(comment);
18203
18287
  if (updatedComment2) {
18204
18288
  updateCommentEverywhere(updatedComment2.id, () => updatedComment2);
18205
18289
  }
18206
18290
  }
18291
+ function updateCommentEverywhere(commentId, updater) {
18292
+ setComments((prev) => updateComment(prev, commentId, updater));
18293
+ setReplyCache((prev) => updateReplyCacheComment(prev, commentId, updater));
18294
+ }
18295
+ async function handleDeleteComment(comment) {
18296
+ if (onDelete) {
18297
+ onDelete(comment);
18298
+ return;
18299
+ }
18300
+ await dataSource.deleteComment(comment.id);
18301
+ removeCommentEverywhere(comment);
18302
+ }
18303
+ function removeCommentEverywhere(comment) {
18304
+ setComments((prev) => removeComment(prev, comment.id));
18305
+ setReplyCache((prev) => removeCommentTreeFromCache(prev, comment.id));
18306
+ if (comment.parentCommentId) {
18307
+ setComments(
18308
+ (prev) => decrementReplyCount(prev, comment.parentCommentId)
18309
+ );
18310
+ setReplyCache(
18311
+ (prev) => updateReplyCacheComment(prev, comment.parentCommentId, (item) => ({
18312
+ ...item,
18313
+ replyCount: Math.max(item.replyCount - 1, 0)
18314
+ }))
18315
+ );
18316
+ }
18317
+ }
18207
18318
  if (loading || isLoadingComments) {
18208
18319
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-6", children: "Loading comments..." });
18209
18320
  }
@@ -18901,36 +19012,6 @@ var TopNav = ({
18901
19012
  };
18902
19013
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center", children: items.map(renderNode) });
18903
19014
  };
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
19015
  function GenericLayout({
18935
19016
  children,
18936
19017
  styles,
@@ -19114,6 +19195,7 @@ exports.HeaderNavItemTitle = HeaderNavItemTitle;
19114
19195
  exports.HomeLayout = HomeLayout_default;
19115
19196
  exports.Image = Image2;
19116
19197
  exports.ImageInput = ImageInput_default;
19198
+ exports.InfiniteScrollTrigger = InfiniteScrollTrigger_default;
19117
19199
  exports.Info = Info_default;
19118
19200
  exports.Input = Input;
19119
19201
  exports.InputFile = InputFile;
@@ -19188,21 +19270,31 @@ exports.ValueBadge = ValueBadge_default;
19188
19270
  exports.WorldMap = WorldMap;
19189
19271
  exports.WorldMapCountryTable = WorldMapCountryTable;
19190
19272
  exports.YoutubeVideoPlayer = YoutubeVideo_default;
19273
+ exports.addReplyToCache = addReplyToCache;
19274
+ exports.applyReactionState = applyReactionState;
19191
19275
  exports.cn = cn;
19192
19276
  exports.createForceLayout = createForceLayout;
19193
19277
  exports.createGridLayout = createGridLayout;
19194
19278
  exports.createTreeLayout = createTreeLayout;
19279
+ exports.decrementReplyCount = decrementReplyCount;
19195
19280
  exports.enumValues = enumValues;
19196
19281
  exports.formatCommentDate = formatCommentDate;
19197
19282
  exports.getCurrencySymbol = getCurrencySymbol;
19198
19283
  exports.getLayout = getLayout;
19284
+ exports.getOptimisticDislikeState = getOptimisticDislikeState;
19285
+ exports.getOptimisticLikeState = getOptimisticLikeState;
19286
+ exports.incrementReplyCount = incrementReplyCount;
19199
19287
  exports.isMatch = isMatch;
19200
19288
  exports.isRenderFn = isRenderFn;
19201
19289
  exports.normalize = normalize;
19202
19290
  exports.registerLayout = registerLayout;
19291
+ exports.removeComment = removeComment;
19292
+ exports.removeCommentTreeFromCache = removeCommentTreeFromCache;
19203
19293
  exports.resolveAppearanceStyles = resolveAppearanceStyles;
19204
19294
  exports.resolveWithGlobal = resolveWithGlobal;
19205
19295
  exports.sendToast = sendToast;
19296
+ exports.updateComment = updateComment;
19297
+ exports.updateReplyCacheComment = updateReplyCacheComment;
19206
19298
  exports.useClickOutside = useClickOutside;
19207
19299
  exports.useCloudinaryConfig = useCloudinaryConfig;
19208
19300
  exports.useCurrentTheme = useCurrentTheme_default;