elseware-ui 2.31.4 → 2.31.6
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.css +66 -0
- package/dist/index.css.map +1 -1
- package/dist/index.d.mts +71 -2
- package/dist/index.d.ts +71 -2
- package/dist/index.js +81 -64
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +82 -65
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import React$1, { HTMLAttributes, ReactNode, JSX, FC, MouseEvent, MutableRefObject } from 'react';
|
|
2
|
+
import React$1, { HTMLAttributes, ReactNode, JSX, FC, ComponentType, MouseEvent, MutableRefObject } from 'react';
|
|
3
3
|
import { ChartData, ChartOptions } from 'chart.js';
|
|
4
4
|
import * as d3 from 'd3';
|
|
5
5
|
import * as formik from 'formik';
|
|
@@ -1435,16 +1435,85 @@ interface CommentDataSource {
|
|
|
1435
1435
|
reportComment?(commentId: string, reason: string, description?: string): Promise<void>;
|
|
1436
1436
|
}
|
|
1437
1437
|
|
|
1438
|
+
interface CommentHeaderProps {
|
|
1439
|
+
comment: CommentEntity;
|
|
1440
|
+
}
|
|
1441
|
+
interface CommentContentProps {
|
|
1442
|
+
comment: CommentEntity;
|
|
1443
|
+
}
|
|
1444
|
+
interface CommentActionsProps {
|
|
1445
|
+
comment: CommentEntity;
|
|
1446
|
+
onLike?: () => void;
|
|
1447
|
+
onDislike?: () => void;
|
|
1448
|
+
onReply?: () => void;
|
|
1449
|
+
}
|
|
1450
|
+
interface CommentMenuProps {
|
|
1451
|
+
comment: CommentEntity;
|
|
1452
|
+
open: boolean;
|
|
1453
|
+
setOpen: (open: boolean) => void;
|
|
1454
|
+
canEdit?: boolean;
|
|
1455
|
+
canDelete?: boolean;
|
|
1456
|
+
canReport?: boolean;
|
|
1457
|
+
onEdit?: () => void;
|
|
1458
|
+
onDelete?: () => void;
|
|
1459
|
+
onReport?: () => void;
|
|
1460
|
+
}
|
|
1461
|
+
interface CommentComposerProps {
|
|
1462
|
+
avatar?: string;
|
|
1463
|
+
onSubmit: (content: string) => Promise<void> | void;
|
|
1464
|
+
}
|
|
1465
|
+
interface ReplyComposerProps {
|
|
1466
|
+
avatar?: string;
|
|
1467
|
+
username?: string;
|
|
1468
|
+
onSubmit: (content: string) => Promise<void> | void;
|
|
1469
|
+
}
|
|
1470
|
+
interface CommentRepliesToggleProps {
|
|
1471
|
+
collapsed: boolean;
|
|
1472
|
+
repliesCount: number;
|
|
1473
|
+
onToggle: () => void;
|
|
1474
|
+
}
|
|
1475
|
+
interface CommentComponents {
|
|
1476
|
+
/**
|
|
1477
|
+
* Root comment composer
|
|
1478
|
+
*/
|
|
1479
|
+
Composer?: ComponentType<CommentComposerProps>;
|
|
1480
|
+
/**
|
|
1481
|
+
* Comment header section
|
|
1482
|
+
*/
|
|
1483
|
+
Header?: ComponentType<CommentHeaderProps>;
|
|
1484
|
+
/**
|
|
1485
|
+
* Comment content renderer
|
|
1486
|
+
*/
|
|
1487
|
+
Content?: ComponentType<CommentContentProps>;
|
|
1488
|
+
/**
|
|
1489
|
+
* Like / Dislike / Reply actions
|
|
1490
|
+
*/
|
|
1491
|
+
Actions?: ComponentType<CommentActionsProps>;
|
|
1492
|
+
/**
|
|
1493
|
+
* Comment menu (Edit/Delete/Report)
|
|
1494
|
+
*/
|
|
1495
|
+
Menu?: ComponentType<CommentMenuProps>;
|
|
1496
|
+
/**
|
|
1497
|
+
* Reply composer shown below a comment
|
|
1498
|
+
*/
|
|
1499
|
+
ReplyComposer?: ComponentType<ReplyComposerProps>;
|
|
1500
|
+
/**
|
|
1501
|
+
* Replies expand/collapse component
|
|
1502
|
+
*/
|
|
1503
|
+
RepliesToggle?: ComponentType<CommentRepliesToggleProps>;
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1438
1506
|
interface CommentThreadProps {
|
|
1439
1507
|
postId: string;
|
|
1440
1508
|
currentUser: CommentAuthor;
|
|
1441
1509
|
dataSource: CommentDataSource;
|
|
1442
1510
|
loading?: boolean;
|
|
1511
|
+
components?: CommentComponents;
|
|
1443
1512
|
onEdit?: (comment: CommentEntity) => void;
|
|
1444
1513
|
onDelete?: (comment: CommentEntity) => void;
|
|
1445
1514
|
onReport?: (comment: CommentEntity) => void;
|
|
1446
1515
|
}
|
|
1447
|
-
declare function CommentThread({ currentUser, dataSource, loading, onEdit, onDelete, onReport, }: CommentThreadProps): react_jsx_runtime.JSX.Element;
|
|
1516
|
+
declare function CommentThread({ currentUser, dataSource, loading, components, onEdit, onDelete, onReport, }: CommentThreadProps): react_jsx_runtime.JSX.Element;
|
|
1448
1517
|
|
|
1449
1518
|
type SortOption = {
|
|
1450
1519
|
value: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import React$1, { HTMLAttributes, ReactNode, JSX, FC, MouseEvent, MutableRefObject } from 'react';
|
|
2
|
+
import React$1, { HTMLAttributes, ReactNode, JSX, FC, ComponentType, MouseEvent, MutableRefObject } from 'react';
|
|
3
3
|
import { ChartData, ChartOptions } from 'chart.js';
|
|
4
4
|
import * as d3 from 'd3';
|
|
5
5
|
import * as formik from 'formik';
|
|
@@ -1435,16 +1435,85 @@ interface CommentDataSource {
|
|
|
1435
1435
|
reportComment?(commentId: string, reason: string, description?: string): Promise<void>;
|
|
1436
1436
|
}
|
|
1437
1437
|
|
|
1438
|
+
interface CommentHeaderProps {
|
|
1439
|
+
comment: CommentEntity;
|
|
1440
|
+
}
|
|
1441
|
+
interface CommentContentProps {
|
|
1442
|
+
comment: CommentEntity;
|
|
1443
|
+
}
|
|
1444
|
+
interface CommentActionsProps {
|
|
1445
|
+
comment: CommentEntity;
|
|
1446
|
+
onLike?: () => void;
|
|
1447
|
+
onDislike?: () => void;
|
|
1448
|
+
onReply?: () => void;
|
|
1449
|
+
}
|
|
1450
|
+
interface CommentMenuProps {
|
|
1451
|
+
comment: CommentEntity;
|
|
1452
|
+
open: boolean;
|
|
1453
|
+
setOpen: (open: boolean) => void;
|
|
1454
|
+
canEdit?: boolean;
|
|
1455
|
+
canDelete?: boolean;
|
|
1456
|
+
canReport?: boolean;
|
|
1457
|
+
onEdit?: () => void;
|
|
1458
|
+
onDelete?: () => void;
|
|
1459
|
+
onReport?: () => void;
|
|
1460
|
+
}
|
|
1461
|
+
interface CommentComposerProps {
|
|
1462
|
+
avatar?: string;
|
|
1463
|
+
onSubmit: (content: string) => Promise<void> | void;
|
|
1464
|
+
}
|
|
1465
|
+
interface ReplyComposerProps {
|
|
1466
|
+
avatar?: string;
|
|
1467
|
+
username?: string;
|
|
1468
|
+
onSubmit: (content: string) => Promise<void> | void;
|
|
1469
|
+
}
|
|
1470
|
+
interface CommentRepliesToggleProps {
|
|
1471
|
+
collapsed: boolean;
|
|
1472
|
+
repliesCount: number;
|
|
1473
|
+
onToggle: () => void;
|
|
1474
|
+
}
|
|
1475
|
+
interface CommentComponents {
|
|
1476
|
+
/**
|
|
1477
|
+
* Root comment composer
|
|
1478
|
+
*/
|
|
1479
|
+
Composer?: ComponentType<CommentComposerProps>;
|
|
1480
|
+
/**
|
|
1481
|
+
* Comment header section
|
|
1482
|
+
*/
|
|
1483
|
+
Header?: ComponentType<CommentHeaderProps>;
|
|
1484
|
+
/**
|
|
1485
|
+
* Comment content renderer
|
|
1486
|
+
*/
|
|
1487
|
+
Content?: ComponentType<CommentContentProps>;
|
|
1488
|
+
/**
|
|
1489
|
+
* Like / Dislike / Reply actions
|
|
1490
|
+
*/
|
|
1491
|
+
Actions?: ComponentType<CommentActionsProps>;
|
|
1492
|
+
/**
|
|
1493
|
+
* Comment menu (Edit/Delete/Report)
|
|
1494
|
+
*/
|
|
1495
|
+
Menu?: ComponentType<CommentMenuProps>;
|
|
1496
|
+
/**
|
|
1497
|
+
* Reply composer shown below a comment
|
|
1498
|
+
*/
|
|
1499
|
+
ReplyComposer?: ComponentType<ReplyComposerProps>;
|
|
1500
|
+
/**
|
|
1501
|
+
* Replies expand/collapse component
|
|
1502
|
+
*/
|
|
1503
|
+
RepliesToggle?: ComponentType<CommentRepliesToggleProps>;
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1438
1506
|
interface CommentThreadProps {
|
|
1439
1507
|
postId: string;
|
|
1440
1508
|
currentUser: CommentAuthor;
|
|
1441
1509
|
dataSource: CommentDataSource;
|
|
1442
1510
|
loading?: boolean;
|
|
1511
|
+
components?: CommentComponents;
|
|
1443
1512
|
onEdit?: (comment: CommentEntity) => void;
|
|
1444
1513
|
onDelete?: (comment: CommentEntity) => void;
|
|
1445
1514
|
onReport?: (comment: CommentEntity) => void;
|
|
1446
1515
|
}
|
|
1447
|
-
declare function CommentThread({ currentUser, dataSource, loading, onEdit, onDelete, onReport, }: CommentThreadProps): react_jsx_runtime.JSX.Element;
|
|
1516
|
+
declare function CommentThread({ currentUser, dataSource, loading, components, onEdit, onDelete, onReport, }: CommentThreadProps): react_jsx_runtime.JSX.Element;
|
|
1448
1517
|
|
|
1449
1518
|
type SortOption = {
|
|
1450
1519
|
value: string;
|
package/dist/index.js
CHANGED
|
@@ -17550,15 +17550,16 @@ function CommentComposer({
|
|
|
17550
17550
|
}
|
|
17551
17551
|
var CommentComposer_default = CommentComposer;
|
|
17552
17552
|
function CommentActions({
|
|
17553
|
-
|
|
17554
|
-
dislikes = 0,
|
|
17555
|
-
liked = false,
|
|
17556
|
-
disliked = false,
|
|
17557
|
-
canReply = true,
|
|
17553
|
+
comment,
|
|
17558
17554
|
onLike,
|
|
17559
17555
|
onDislike,
|
|
17560
17556
|
onReply
|
|
17561
17557
|
}) {
|
|
17558
|
+
const likes = comment.likes ?? 0;
|
|
17559
|
+
const dislikes = comment.dislikes ?? 0;
|
|
17560
|
+
const liked = comment.liked ?? false;
|
|
17561
|
+
const disliked = comment.disliked ?? false;
|
|
17562
|
+
const canReply = comment.permissions?.canReply ?? true;
|
|
17562
17563
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
17563
17564
|
"div",
|
|
17564
17565
|
{
|
|
@@ -17611,14 +17612,8 @@ function CommentActions({
|
|
|
17611
17612
|
);
|
|
17612
17613
|
}
|
|
17613
17614
|
var CommentActions_default = CommentActions;
|
|
17614
|
-
function CommentContent({
|
|
17615
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
17616
|
-
"div",
|
|
17617
|
-
{
|
|
17618
|
-
className: "\n text-sm\n leading-relaxed\n whitespace-pre-wrap\n break-words\n text-gray-700\n dark:text-gray-300\n ",
|
|
17619
|
-
children: content
|
|
17620
|
-
}
|
|
17621
|
-
);
|
|
17615
|
+
function CommentContent({ comment }) {
|
|
17616
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "whitespace-pre-wrap break-words text-sm text-gray-700 dark:text-gray-300", children: comment.content });
|
|
17622
17617
|
}
|
|
17623
17618
|
var CommentContent_default = CommentContent;
|
|
17624
17619
|
|
|
@@ -17657,31 +17652,29 @@ function formatCommentDate(date) {
|
|
|
17657
17652
|
}
|
|
17658
17653
|
return "Just now";
|
|
17659
17654
|
}
|
|
17660
|
-
function CommentHeader({
|
|
17661
|
-
|
|
17662
|
-
username
|
|
17663
|
-
firstName,
|
|
17664
|
-
lastName,
|
|
17665
|
-
createdAt,
|
|
17666
|
-
edited
|
|
17667
|
-
}) {
|
|
17668
|
-
const displayName = firstName || lastName ? `${firstName ?? ""} ${lastName ?? ""}`.trim() : username;
|
|
17655
|
+
function CommentHeader({ comment }) {
|
|
17656
|
+
const author = comment.author;
|
|
17657
|
+
const displayName = author?.firstName || author?.lastName ? `${author?.firstName ?? ""} ${author?.lastName ?? ""}`.trim() : author?.username ?? "Unknown";
|
|
17669
17658
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3 min-w-0", children: [
|
|
17670
|
-
/* @__PURE__ */ jsxRuntime.jsx(Avatar, { src: avatar, size: "sm" }),
|
|
17659
|
+
/* @__PURE__ */ jsxRuntime.jsx(Avatar, { src: author?.avatar, size: "sm" }),
|
|
17671
17660
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 flex-wrap min-w-0", children: [
|
|
17672
17661
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-semibold text-sm text-gray-900 dark:text-gray-100", children: displayName }),
|
|
17673
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
17674
|
-
|
|
17675
|
-
|
|
17662
|
+
author?.username && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
17663
|
+
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-sm text-gray-500 dark:text-gray-400", children: [
|
|
17664
|
+
"@",
|
|
17665
|
+
author.username
|
|
17666
|
+
] }),
|
|
17667
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-gray-500 dark:text-gray-400", children: "\xB7" })
|
|
17676
17668
|
] }),
|
|
17677
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-gray-500 dark:text-gray-400", children:
|
|
17678
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-
|
|
17679
|
-
edited && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-gray-400 dark:text-gray-500", children: "(edited)" })
|
|
17669
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-gray-500 dark:text-gray-400", children: formatCommentDate(comment.createdAt) }),
|
|
17670
|
+
comment.edited && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-gray-400 dark:text-gray-500", children: "(edited)" })
|
|
17680
17671
|
] })
|
|
17681
17672
|
] });
|
|
17682
17673
|
}
|
|
17683
17674
|
var CommentHeader_default = CommentHeader;
|
|
17684
17675
|
function CommentMenu({
|
|
17676
|
+
open,
|
|
17677
|
+
setOpen,
|
|
17685
17678
|
canEdit,
|
|
17686
17679
|
canDelete,
|
|
17687
17680
|
canReport,
|
|
@@ -17689,7 +17682,6 @@ function CommentMenu({
|
|
|
17689
17682
|
onDelete,
|
|
17690
17683
|
onReport
|
|
17691
17684
|
}) {
|
|
17692
|
-
const [open, setOpen] = React4.useState(false);
|
|
17693
17685
|
const ref = React4.useRef(null);
|
|
17694
17686
|
React4.useEffect(() => {
|
|
17695
17687
|
function handleOutsideClick(event) {
|
|
@@ -17699,7 +17691,7 @@ function CommentMenu({
|
|
|
17699
17691
|
}
|
|
17700
17692
|
document.addEventListener("mousedown", handleOutsideClick);
|
|
17701
17693
|
return () => document.removeEventListener("mousedown", handleOutsideClick);
|
|
17702
|
-
}, []);
|
|
17694
|
+
}, [setOpen]);
|
|
17703
17695
|
const hasActions = canEdit || canDelete || canReport;
|
|
17704
17696
|
if (!hasActions) {
|
|
17705
17697
|
return null;
|
|
@@ -17709,7 +17701,7 @@ function CommentMenu({
|
|
|
17709
17701
|
"button",
|
|
17710
17702
|
{
|
|
17711
17703
|
type: "button",
|
|
17712
|
-
onClick: () => setOpen(
|
|
17704
|
+
onClick: () => setOpen(!open),
|
|
17713
17705
|
className: "\n text-gray-500\n hover:text-gray-900\n dark:hover:text-gray-100\n transition-colors\n ",
|
|
17714
17706
|
children: /* @__PURE__ */ jsxRuntime.jsx(bi.BiDotsVerticalRounded, { size: 18 })
|
|
17715
17707
|
}
|
|
@@ -17818,6 +17810,7 @@ var COMMENT_INDENTATION = 24;
|
|
|
17818
17810
|
function CommentItem({
|
|
17819
17811
|
comment,
|
|
17820
17812
|
depth = 0,
|
|
17813
|
+
components,
|
|
17821
17814
|
onLike,
|
|
17822
17815
|
onDislike,
|
|
17823
17816
|
onReply,
|
|
@@ -17828,10 +17821,19 @@ function CommentItem({
|
|
|
17828
17821
|
const [collapsed, setCollapsed] = React4.useState(false);
|
|
17829
17822
|
const [isReplying, setIsReplying] = React4.useState(false);
|
|
17830
17823
|
const resolvedDepth = Math.min(depth, MAX_COMMENT_DEPTH);
|
|
17824
|
+
const {
|
|
17825
|
+
Header: HeaderComponent = CommentHeader_default,
|
|
17826
|
+
Content: ContentComponent = CommentContent_default,
|
|
17827
|
+
Actions: ActionsComponent = CommentActions_default,
|
|
17828
|
+
Menu: MenuComponent = CommentMenu_default,
|
|
17829
|
+
ReplyComposer: ReplyComposerComponent = ReplyComposer_default,
|
|
17830
|
+
RepliesToggle: RepliesToggleComponent = CommentRepliesToggle_default
|
|
17831
|
+
} = components ?? {};
|
|
17831
17832
|
async function handleReply(content) {
|
|
17832
17833
|
await onReply?.(comment, content);
|
|
17833
17834
|
setIsReplying(false);
|
|
17834
17835
|
}
|
|
17836
|
+
const [menuOpen, setMenuOpen] = React4.useState(false);
|
|
17835
17837
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
17836
17838
|
"div",
|
|
17837
17839
|
{
|
|
@@ -17842,20 +17844,13 @@ function CommentItem({
|
|
|
17842
17844
|
children: [
|
|
17843
17845
|
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-1 flex-col gap-3 min-w-0", children: [
|
|
17844
17846
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between gap-3", children: [
|
|
17847
|
+
/* @__PURE__ */ jsxRuntime.jsx(HeaderComponent, { comment }),
|
|
17845
17848
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
17846
|
-
|
|
17847
|
-
{
|
|
17848
|
-
avatar: comment.author?.avatar,
|
|
17849
|
-
username: comment.author?.username ?? "unknown",
|
|
17850
|
-
firstName: comment.author?.firstName,
|
|
17851
|
-
lastName: comment.author?.lastName,
|
|
17852
|
-
createdAt: comment.createdAt,
|
|
17853
|
-
edited: comment.edited
|
|
17854
|
-
}
|
|
17855
|
-
),
|
|
17856
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
17857
|
-
CommentMenu_default,
|
|
17849
|
+
MenuComponent,
|
|
17858
17850
|
{
|
|
17851
|
+
comment,
|
|
17852
|
+
open: menuOpen,
|
|
17853
|
+
setOpen: setMenuOpen,
|
|
17859
17854
|
canEdit: comment.permissions?.canEdit,
|
|
17860
17855
|
canDelete: comment.permissions?.canDelete,
|
|
17861
17856
|
canReport: comment.permissions?.canReport,
|
|
@@ -17865,22 +17860,18 @@ function CommentItem({
|
|
|
17865
17860
|
}
|
|
17866
17861
|
)
|
|
17867
17862
|
] }),
|
|
17868
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
17863
|
+
/* @__PURE__ */ jsxRuntime.jsx(ContentComponent, { comment }),
|
|
17869
17864
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
17870
|
-
|
|
17865
|
+
ActionsComponent,
|
|
17871
17866
|
{
|
|
17872
|
-
|
|
17873
|
-
dislikes: comment.dislikes,
|
|
17874
|
-
liked: comment.liked,
|
|
17875
|
-
disliked: comment.disliked,
|
|
17876
|
-
canReply: comment.permissions?.canReply,
|
|
17867
|
+
comment,
|
|
17877
17868
|
onLike: () => onLike?.(comment),
|
|
17878
17869
|
onDislike: () => onDislike?.(comment),
|
|
17879
17870
|
onReply: () => setIsReplying((prev) => !prev)
|
|
17880
17871
|
}
|
|
17881
17872
|
),
|
|
17882
17873
|
isReplying && /* @__PURE__ */ jsxRuntime.jsx(
|
|
17883
|
-
|
|
17874
|
+
ReplyComposerComponent,
|
|
17884
17875
|
{
|
|
17885
17876
|
avatar: comment.author?.avatar,
|
|
17886
17877
|
username: comment.author?.username,
|
|
@@ -17888,7 +17879,7 @@ function CommentItem({
|
|
|
17888
17879
|
}
|
|
17889
17880
|
),
|
|
17890
17881
|
!!comment.replies?.length && /* @__PURE__ */ jsxRuntime.jsx(
|
|
17891
|
-
|
|
17882
|
+
RepliesToggleComponent,
|
|
17892
17883
|
{
|
|
17893
17884
|
collapsed,
|
|
17894
17885
|
repliesCount: comment.replies.length,
|
|
@@ -17908,6 +17899,7 @@ function CommentItem({
|
|
|
17908
17899
|
{
|
|
17909
17900
|
comments: comment.replies,
|
|
17910
17901
|
depth: depth + 1,
|
|
17902
|
+
components,
|
|
17911
17903
|
onLike,
|
|
17912
17904
|
onDislike,
|
|
17913
17905
|
onReply,
|
|
@@ -17926,6 +17918,7 @@ var CommentItem_default = CommentItem;
|
|
|
17926
17918
|
function CommentList({
|
|
17927
17919
|
comments,
|
|
17928
17920
|
depth = 0,
|
|
17921
|
+
components,
|
|
17929
17922
|
onLike,
|
|
17930
17923
|
onDislike,
|
|
17931
17924
|
onReply,
|
|
@@ -17941,6 +17934,7 @@ function CommentList({
|
|
|
17941
17934
|
{
|
|
17942
17935
|
comment,
|
|
17943
17936
|
depth,
|
|
17937
|
+
components,
|
|
17944
17938
|
onLike,
|
|
17945
17939
|
onDislike,
|
|
17946
17940
|
onReply,
|
|
@@ -18009,12 +18003,14 @@ function CommentThread({
|
|
|
18009
18003
|
currentUser,
|
|
18010
18004
|
dataSource,
|
|
18011
18005
|
loading = false,
|
|
18006
|
+
components,
|
|
18012
18007
|
onEdit,
|
|
18013
18008
|
onDelete,
|
|
18014
18009
|
onReport
|
|
18015
18010
|
}) {
|
|
18016
18011
|
const [comments, setComments] = React4.useState([]);
|
|
18017
18012
|
const [isLoadingComments, setIsLoadingComments] = React4.useState(true);
|
|
18013
|
+
const ComposerComponent = components?.ReplyComposer ?? CommentComposer_default;
|
|
18018
18014
|
React4.useEffect(() => {
|
|
18019
18015
|
async function loadComments() {
|
|
18020
18016
|
try {
|
|
@@ -18041,35 +18037,55 @@ function CommentThread({
|
|
|
18041
18037
|
setComments((prev) => insertReply(prev, parentComment.id, reply));
|
|
18042
18038
|
}
|
|
18043
18039
|
async function handleLike(comment) {
|
|
18044
|
-
const
|
|
18040
|
+
const optimistic = {
|
|
18041
|
+
liked: !comment.liked,
|
|
18042
|
+
disliked: false,
|
|
18043
|
+
likes: comment.liked ? Math.max(comment.likes - 1, 0) : comment.likes + 1,
|
|
18044
|
+
dislikes: comment.disliked ? Math.max(comment.dislikes - 1, 0) : comment.dislikes
|
|
18045
|
+
};
|
|
18045
18046
|
setComments(
|
|
18046
18047
|
(prev) => updateComment(prev, comment.id, (item) => ({
|
|
18047
18048
|
...item,
|
|
18048
|
-
likes:
|
|
18049
|
-
dislikes:
|
|
18050
|
-
liked:
|
|
18051
|
-
disliked:
|
|
18049
|
+
likes: optimistic.likes,
|
|
18050
|
+
dislikes: optimistic.dislikes,
|
|
18051
|
+
liked: optimistic.liked,
|
|
18052
|
+
disliked: optimistic.disliked
|
|
18052
18053
|
}))
|
|
18053
18054
|
);
|
|
18055
|
+
try {
|
|
18056
|
+
await dataSource.toggleLike(comment.id);
|
|
18057
|
+
} catch {
|
|
18058
|
+
setComments((prev) => updateComment(prev, comment.id, () => comment));
|
|
18059
|
+
}
|
|
18054
18060
|
}
|
|
18055
18061
|
async function handleDislike(comment) {
|
|
18056
|
-
const
|
|
18062
|
+
const optimistic = {
|
|
18063
|
+
liked: false,
|
|
18064
|
+
disliked: !comment.disliked,
|
|
18065
|
+
likes: comment.liked ? Math.max(comment.likes - 1, 0) : comment.likes,
|
|
18066
|
+
dislikes: comment.disliked ? Math.max(comment.dislikes - 1, 0) : comment.dislikes + 1
|
|
18067
|
+
};
|
|
18057
18068
|
setComments(
|
|
18058
18069
|
(prev) => updateComment(prev, comment.id, (item) => ({
|
|
18059
18070
|
...item,
|
|
18060
|
-
likes:
|
|
18061
|
-
dislikes:
|
|
18062
|
-
liked:
|
|
18063
|
-
disliked:
|
|
18071
|
+
likes: optimistic.likes,
|
|
18072
|
+
dislikes: optimistic.dislikes,
|
|
18073
|
+
liked: optimistic.liked,
|
|
18074
|
+
disliked: optimistic.disliked
|
|
18064
18075
|
}))
|
|
18065
18076
|
);
|
|
18077
|
+
try {
|
|
18078
|
+
await dataSource.toggleDislike(comment.id);
|
|
18079
|
+
} catch {
|
|
18080
|
+
setComments((prev) => updateComment(prev, comment.id, () => comment));
|
|
18081
|
+
}
|
|
18066
18082
|
}
|
|
18067
18083
|
if (loading || isLoadingComments) {
|
|
18068
18084
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-6", children: "Loading comments..." });
|
|
18069
18085
|
}
|
|
18070
18086
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-8", children: [
|
|
18071
18087
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
18072
|
-
|
|
18088
|
+
ComposerComponent,
|
|
18073
18089
|
{
|
|
18074
18090
|
avatar: currentUser.avatar,
|
|
18075
18091
|
onSubmit: handleCreateComment
|
|
@@ -18079,6 +18095,7 @@ function CommentThread({
|
|
|
18079
18095
|
CommentList_default,
|
|
18080
18096
|
{
|
|
18081
18097
|
comments,
|
|
18098
|
+
components,
|
|
18082
18099
|
onLike: handleLike,
|
|
18083
18100
|
onDislike: handleDislike,
|
|
18084
18101
|
onReply: handleReply,
|