@edifice.io/react 2.1.2-develop-pedago.20250318163732 → 2.1.2-develop-pedago.20250320142932
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/modules/comments/components/Comment.d.ts +1 -2
- package/dist/modules/comments/components/Comment.js +14 -7
- package/dist/modules/comments/components/CommentList.js +6 -13
- package/dist/modules/comments/components/CommentReplies.d.ts +1 -2
- package/dist/modules/comments/components/CommentReplies.js +8 -7
- package/dist/modules/comments/context/Context.d.ts +5 -1
- package/dist/modules/comments/hooks/useCommentReplies.d.ts +1 -3
- package/dist/modules/comments/hooks/useCommentReplies.js +4 -3
- package/dist/modules/comments/hooks/useComments.d.ts +6 -3
- package/dist/modules/comments/hooks/useComments.js +22 -12
- package/dist/modules/comments/hooks/useCommentsContext.d.ts +5 -1
- package/dist/modules/comments/provider/CommentProvider.js +14 -7
- package/package.json +6 -6
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { UserProfile } from '@edifice.io/client';
|
|
2
2
|
import { CommentProps } from '../types';
|
|
3
|
-
export declare const Comment: ({ comment, userId, profile,
|
|
3
|
+
export declare const Comment: ({ comment, userId, profile, }: {
|
|
4
4
|
comment: CommentProps;
|
|
5
5
|
userId: string;
|
|
6
6
|
profile: UserProfile[number];
|
|
7
|
-
onReply?: (commentId: string) => void;
|
|
8
7
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -10,13 +10,13 @@ import { CommentDate } from "./CommentDate.js";
|
|
|
10
10
|
import { CommentTitle } from "./CommentTitle.js";
|
|
11
11
|
import { TextCounter } from "./TextCounter.js";
|
|
12
12
|
import { CommentDeleted } from "./CommentDeleted.js";
|
|
13
|
+
import { CommentReplies } from "./CommentReplies.js";
|
|
13
14
|
import Button from "../../../components/Button/Button.js";
|
|
14
15
|
import LoadingScreen from "../../../components/LoadingScreen/LoadingScreen.js";
|
|
15
16
|
const DeleteModal = /* @__PURE__ */ lazy(() => import("./DeleteModal.js")), Comment = ({
|
|
16
17
|
comment,
|
|
17
18
|
userId,
|
|
18
|
-
profile
|
|
19
|
-
onReply
|
|
19
|
+
profile
|
|
20
20
|
}) => {
|
|
21
21
|
const [value, setValue] = useState(""), {
|
|
22
22
|
id,
|
|
@@ -24,10 +24,12 @@ const DeleteModal = /* @__PURE__ */ lazy(() => import("./DeleteModal.js")), Comm
|
|
|
24
24
|
authorName,
|
|
25
25
|
createdAt,
|
|
26
26
|
updatedAt,
|
|
27
|
-
comment: content
|
|
27
|
+
comment: content,
|
|
28
|
+
replyTo
|
|
28
29
|
} = comment, [ref, onFocus, resizeTextarea] = useAutosizeTextarea(!0), [isDeleteModalOpen, setIsDeleteModalOpen] = useState(!1), {
|
|
29
30
|
t
|
|
30
31
|
} = useTranslation(), {
|
|
32
|
+
defaultComments,
|
|
31
33
|
editCommentId,
|
|
32
34
|
options,
|
|
33
35
|
type,
|
|
@@ -35,12 +37,16 @@ const DeleteModal = /* @__PURE__ */ lazy(() => import("./DeleteModal.js")), Comm
|
|
|
35
37
|
handleDeleteComment: onDeleteComment,
|
|
36
38
|
handleModifyComment,
|
|
37
39
|
handleReset,
|
|
38
|
-
handleUpdateComment
|
|
39
|
-
|
|
40
|
+
handleUpdateComment,
|
|
41
|
+
handleReplyToComment
|
|
42
|
+
} = useCommentsContext(), replies = (defaultComments == null ? void 0 : defaultComments.filter((comm) => comm.replyTo === comment.id)) ?? [], hasReplies = replies.length > 0, hasAllDeletedReplies = replies.every((reply) => reply.deleted), isEditing = editCommentId === comment.id, handleChangeContent = (event) => {
|
|
40
43
|
resizeTextarea(), setValue(event.target.value);
|
|
41
44
|
};
|
|
42
45
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
43
|
-
comment.deleted && /* @__PURE__ */
|
|
46
|
+
comment.deleted && hasReplies && !hasAllDeletedReplies && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
47
|
+
/* @__PURE__ */ jsx(CommentDeleted, {}),
|
|
48
|
+
/* @__PURE__ */ jsx(CommentReplies, { parentComment: comment })
|
|
49
|
+
] }),
|
|
44
50
|
!comment.deleted && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
45
51
|
/* @__PURE__ */ jsxs("div", { className: `${isEditing ? "border rounded-3 p-12 pb-8 d-flex gap-12 bg-gray-200 my-16" : "border rounded-3 p-12 pb-8 d-flex gap-12 mt-16"}`, children: [
|
|
46
52
|
/* @__PURE__ */ jsx(CommentAvatar, { id: authorId }),
|
|
@@ -65,7 +71,7 @@ const DeleteModal = /* @__PURE__ */ lazy(() => import("./DeleteModal.js")), Comm
|
|
|
65
71
|
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
66
72
|
/* @__PURE__ */ jsx("div", { className: "mt-8 mb-4", children: content }),
|
|
67
73
|
type === "edit" && /* @__PURE__ */ jsxs("div", { className: "ms-n8", children: [
|
|
68
|
-
!
|
|
74
|
+
!replyTo && /* @__PURE__ */ jsx(Button, { variant: "ghost", color: "tertiary", size: "sm", onClick: () => handleReplyToComment(comment.id), children: t("comment.reply") }),
|
|
69
75
|
userId === authorId && /* @__PURE__ */ jsx(Button, { variant: "ghost", color: "tertiary", size: "sm", onClick: () => {
|
|
70
76
|
handleModifyComment(comment.id), setValue(content);
|
|
71
77
|
}, children: t("comment.edit") }),
|
|
@@ -74,6 +80,7 @@ const DeleteModal = /* @__PURE__ */ lazy(() => import("./DeleteModal.js")), Comm
|
|
|
74
80
|
] })
|
|
75
81
|
] })
|
|
76
82
|
] }, id),
|
|
83
|
+
/* @__PURE__ */ jsx(CommentReplies, { parentComment: comment }),
|
|
77
84
|
/* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingScreen, { position: !1 }), children: isDeleteModalOpen && /* @__PURE__ */ jsx(DeleteModal, { isOpen: isDeleteModalOpen, onCancel: () => setIsDeleteModalOpen(!1), onSuccess: () => onDeleteComment(id) }) })
|
|
78
85
|
] })
|
|
79
86
|
] });
|
|
@@ -1,27 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useState } from "react";
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
3
2
|
import { useEdificeClient } from "../../../providers/EdificeClientProvider/EdificeClientProvider.hook.js";
|
|
4
3
|
import { useCommentsContext } from "../hooks/useCommentsContext.js";
|
|
5
4
|
import { Comment } from "./Comment.js";
|
|
6
|
-
import { CommentReplies } from "./CommentReplies.js";
|
|
7
5
|
function CommentList() {
|
|
8
|
-
const
|
|
6
|
+
const {
|
|
9
7
|
user
|
|
10
8
|
} = useEdificeClient(), {
|
|
11
|
-
|
|
9
|
+
limitedSortedParentComments,
|
|
12
10
|
profiles
|
|
13
|
-
} = useCommentsContext()
|
|
14
|
-
|
|
15
|
-
};
|
|
16
|
-
return comments == null ? void 0 : comments.map((comment) => {
|
|
11
|
+
} = useCommentsContext();
|
|
12
|
+
return limitedSortedParentComments == null ? void 0 : limitedSortedParentComments.map((comment) => {
|
|
17
13
|
var _a;
|
|
18
14
|
const {
|
|
19
15
|
authorId
|
|
20
16
|
} = comment, profile = ((_a = profiles == null ? void 0 : profiles.find((user2) => (user2 == null ? void 0 : user2.userId) === authorId)) == null ? void 0 : _a.profile) ?? "Guest";
|
|
21
|
-
return /* @__PURE__ */
|
|
22
|
-
!comment.replyTo && /* @__PURE__ */ jsx(Comment, { comment, profile, userId: user == null ? void 0 : user.userId, onReply: handleReply }),
|
|
23
|
-
/* @__PURE__ */ jsx(CommentReplies, { parentComment: comment, replyFormCommentId })
|
|
24
|
-
] }, comment.id);
|
|
17
|
+
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(Comment, { comment, profile, userId: user == null ? void 0 : user.userId }) }, comment.id);
|
|
25
18
|
});
|
|
26
19
|
}
|
|
27
20
|
export {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { CommentProps } from '../types';
|
|
2
|
-
export declare const CommentReplies: ({ parentComment,
|
|
2
|
+
export declare const CommentReplies: ({ parentComment, }: {
|
|
3
3
|
parentComment: CommentProps;
|
|
4
|
-
replyFormCommentId: string;
|
|
5
4
|
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -5,13 +5,12 @@ import { CommentForm } from "./CommentForm.js";
|
|
|
5
5
|
import { useCommentReplies } from "../hooks/useCommentReplies.js";
|
|
6
6
|
import Button from "../../../components/Button/Button.js";
|
|
7
7
|
const CommentReplies = ({
|
|
8
|
-
parentComment
|
|
9
|
-
replyFormCommentId
|
|
8
|
+
parentComment
|
|
10
9
|
}) => {
|
|
11
10
|
const {
|
|
12
|
-
comments,
|
|
13
11
|
profiles,
|
|
14
|
-
options
|
|
12
|
+
options,
|
|
13
|
+
replyToCommentId
|
|
15
14
|
} = useCommentsContext(), {
|
|
16
15
|
t,
|
|
17
16
|
user,
|
|
@@ -21,13 +20,15 @@ const CommentReplies = ({
|
|
|
21
20
|
handleMoreReplies
|
|
22
21
|
} = useCommentReplies({
|
|
23
22
|
parentComment,
|
|
24
|
-
comments,
|
|
25
23
|
profiles,
|
|
26
24
|
options
|
|
27
|
-
}), showCommentForm =
|
|
25
|
+
}), showCommentForm = replyToCommentId === parentComment.id && !parentComment.deleted;
|
|
28
26
|
return /* @__PURE__ */ jsxs("div", { className: "comments-replies-container", children: [
|
|
29
27
|
showCommentForm && /* @__PURE__ */ jsx("div", { className: "comments-replies-form", children: /* @__PURE__ */ jsx(CommentForm, { userId: user == null ? void 0 : user.userId, replyTo: parentComment.id }) }),
|
|
30
|
-
/* @__PURE__ */ jsx("div", { className: "comments-replies-list", children: slicedReplies.map((reply) =>
|
|
28
|
+
/* @__PURE__ */ jsx("div", { className: "comments-replies-list", children: slicedReplies.map((reply) => {
|
|
29
|
+
if (!reply.deleted)
|
|
30
|
+
return /* @__PURE__ */ jsx("div", { className: "comments-replies-reply", children: /* @__PURE__ */ jsx(Comment, { comment: reply, profile, userId: user == null ? void 0 : user.userId }) }, reply.id);
|
|
31
|
+
}) }),
|
|
31
32
|
slicedReplies.length < (defaultReplies == null ? void 0 : defaultReplies.length) && /* @__PURE__ */ jsx(Button, { variant: "ghost", color: "tertiary", onClick: handleMoreReplies, className: "ms-24", children: t("comment.more.replies") })
|
|
32
33
|
] });
|
|
33
34
|
};
|
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
import { RightRole } from '@edifice.io/client';
|
|
2
2
|
import { CommentOptions, CommentProps, CommentType, UserProfileResult } from '../types';
|
|
3
3
|
export declare const CommentContext: import('react').Context<{
|
|
4
|
-
|
|
4
|
+
limitedSortedParentComments: CommentProps[] | undefined;
|
|
5
|
+
defaultComments: CommentProps[] | undefined;
|
|
5
6
|
editCommentId: string | null;
|
|
7
|
+
replyToCommentId: string | null;
|
|
6
8
|
profiles: (UserProfileResult | undefined)[];
|
|
7
9
|
options: Partial<CommentOptions>;
|
|
8
10
|
type: CommentType;
|
|
9
11
|
userRights?: Record<RightRole, boolean>;
|
|
10
12
|
setEditCommentId: (value: string | null) => void;
|
|
13
|
+
setReplyToCommentId: (value: string | null) => void;
|
|
11
14
|
handleModifyComment: (commentId: string) => void;
|
|
12
15
|
handleCreateComment: (content: string, replyTo?: string) => void;
|
|
13
16
|
handleUpdateComment: (comment: string) => void;
|
|
14
17
|
handleDeleteComment: (id: string) => void;
|
|
18
|
+
handleReplyToComment: (commentId: string) => void;
|
|
15
19
|
handleReset: () => void;
|
|
16
20
|
} | null>;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { CommentOptions, CommentProps, UserProfileResult } from '../types';
|
|
2
|
-
export declare const useCommentReplies: ({ parentComment,
|
|
2
|
+
export declare const useCommentReplies: ({ parentComment, profiles, options, }: {
|
|
3
3
|
parentComment: CommentProps;
|
|
4
|
-
comments: CommentProps[] | undefined;
|
|
5
4
|
profiles: (UserProfileResult | undefined)[];
|
|
6
5
|
options: Partial<CommentOptions>;
|
|
7
6
|
}) => {
|
|
@@ -10,6 +9,5 @@ export declare const useCommentReplies: ({ parentComment, comments, profiles, op
|
|
|
10
9
|
profile: "Student" | "Teacher" | "Relative" | "Personnel" | "Guest";
|
|
11
10
|
slicedReplies: CommentProps[];
|
|
12
11
|
defaultReplies: CommentProps[];
|
|
13
|
-
orphanReplies: CommentProps[];
|
|
14
12
|
handleMoreReplies: () => void;
|
|
15
13
|
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useState } from "react";
|
|
2
2
|
import { useTranslation } from "react-i18next";
|
|
3
3
|
import { useEdificeClient } from "../../../providers/EdificeClientProvider/EdificeClientProvider.hook.js";
|
|
4
|
+
import { useCommentsContext } from "./useCommentsContext.js";
|
|
4
5
|
const useCommentReplies = ({
|
|
5
6
|
parentComment,
|
|
6
|
-
comments,
|
|
7
7
|
profiles,
|
|
8
8
|
options
|
|
9
9
|
}) => {
|
|
@@ -12,19 +12,20 @@ const useCommentReplies = ({
|
|
|
12
12
|
maxReplies,
|
|
13
13
|
additionalReplies
|
|
14
14
|
} = options, [repliesLimit, setRepliesLimit] = useState(maxReplies), {
|
|
15
|
+
defaultComments
|
|
16
|
+
} = useCommentsContext(), {
|
|
15
17
|
user
|
|
16
18
|
} = useEdificeClient(), {
|
|
17
19
|
t
|
|
18
20
|
} = useTranslation(), {
|
|
19
21
|
authorId
|
|
20
|
-
} = parentComment, profile = ((_a = profiles == null ? void 0 : profiles.find((user2) => (user2 == null ? void 0 : user2.userId) === authorId)) == null ? void 0 : _a.profile) ?? "Guest", defaultReplies = (
|
|
22
|
+
} = parentComment, profile = ((_a = profiles == null ? void 0 : profiles.find((user2) => (user2 == null ? void 0 : user2.userId) === authorId)) == null ? void 0 : _a.profile) ?? "Guest", defaultReplies = (defaultComments == null ? void 0 : defaultComments.filter((comment) => comment.replyTo === parentComment.id)) ?? [], slicedReplies = (defaultReplies == null ? void 0 : defaultReplies.sort((a, b) => b.createdAt - a.createdAt).slice(0, repliesLimit)) ?? [];
|
|
21
23
|
return {
|
|
22
24
|
t,
|
|
23
25
|
user,
|
|
24
26
|
profile,
|
|
25
27
|
slicedReplies,
|
|
26
28
|
defaultReplies,
|
|
27
|
-
orphanReplies,
|
|
28
29
|
handleMoreReplies: () => {
|
|
29
30
|
const newLimit = slicedReplies.length + (additionalReplies ?? 2);
|
|
30
31
|
newLimit !== slicedReplies.length && setRepliesLimit(newLimit);
|
|
@@ -15,16 +15,19 @@ export declare const useComments: ({ defaultComments, options, type, callbacks,
|
|
|
15
15
|
title: string;
|
|
16
16
|
user: import('@edifice.io/client').IUserInfo | undefined;
|
|
17
17
|
emptyscreenPath: string;
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
defaultParentCommentsCount: number;
|
|
19
|
+
limitedSortedParentComments: CommentProps[];
|
|
20
20
|
editCommentId: string | null;
|
|
21
21
|
setEditCommentId: import('react').Dispatch<import('react').SetStateAction<string | null>>;
|
|
22
|
-
|
|
22
|
+
replyToCommentId: string | null;
|
|
23
|
+
setReplyToCommentId: import('react').Dispatch<import('react').SetStateAction<string | null>>;
|
|
24
|
+
limitedSortedParentCommentsCount: number;
|
|
23
25
|
t: import('i18next').TFunction<"translation", undefined>;
|
|
24
26
|
handleMoreComments: () => void;
|
|
25
27
|
handleDeleteComment: (id: string) => void;
|
|
26
28
|
handleCreateComment: (content: string, replyTo?: string) => void;
|
|
27
29
|
handleModifyComment: (commentId: string) => void;
|
|
28
30
|
handleUpdateComment: (comment: string) => Promise<void>;
|
|
31
|
+
handleReplyToComment: (commentId: string) => void;
|
|
29
32
|
handleReset: () => void;
|
|
30
33
|
};
|
|
@@ -9,39 +9,46 @@ const useComments = ({
|
|
|
9
9
|
type,
|
|
10
10
|
callbacks
|
|
11
11
|
}) => {
|
|
12
|
-
|
|
12
|
+
var _a;
|
|
13
|
+
const [editCommentId, setEditCommentId] = useState(null), [replyToCommentId, setReplyToCommentId] = useState(null), [commentLimit, setCommentLimit] = useState(options.maxComments), {
|
|
13
14
|
t
|
|
14
15
|
} = useTranslation(), {
|
|
15
16
|
user
|
|
16
|
-
} = useEdificeClient(), usersIds = Array.from(new Set(defaultComments == null ? void 0 : defaultComments.map((comment) => comment.authorId))), profilesQueries = useProfileQueries(usersIds),
|
|
17
|
-
() =>
|
|
17
|
+
} = useEdificeClient(), usersIds = Array.from(new Set(defaultComments == null ? void 0 : defaultComments.map((comment) => comment.authorId))), profilesQueries = useProfileQueries(usersIds), limitedSortedParentComments = useMemo(
|
|
18
|
+
() => {
|
|
19
|
+
var _a2;
|
|
20
|
+
const filteredAndSortedComments = ((_a2 = defaultComments == null ? void 0 : defaultComments.filter((comment) => !comment.replyTo)) == null ? void 0 : _a2.sort((a, b) => b.createdAt - a.createdAt)) ?? [];
|
|
21
|
+
return type === "edit" ? filteredAndSortedComments.slice(0, commentLimit) ?? [] : filteredAndSortedComments;
|
|
22
|
+
},
|
|
18
23
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
19
24
|
[commentLimit, defaultComments]
|
|
20
|
-
),
|
|
21
|
-
number:
|
|
25
|
+
), limitedSortedParentCommentsCount = (limitedSortedParentComments == null ? void 0 : limitedSortedParentComments.length) ?? 0, defaultParentCommentsCount = ((_a = defaultComments == null ? void 0 : defaultComments.filter((comment) => !comment.replyTo)) == null ? void 0 : _a.length) ?? 0, title = defaultComments != null && defaultComments.length && (defaultComments == null ? void 0 : defaultComments.length) > 1 ? t("comment.several", {
|
|
26
|
+
number: defaultComments == null ? void 0 : defaultComments.length
|
|
22
27
|
}) : t("comment.little", {
|
|
23
|
-
number:
|
|
28
|
+
number: defaultComments == null ? void 0 : defaultComments.length
|
|
24
29
|
});
|
|
25
30
|
return {
|
|
26
31
|
profilesQueries,
|
|
27
32
|
title,
|
|
28
33
|
user,
|
|
29
34
|
emptyscreenPath: illuPad,
|
|
30
|
-
|
|
31
|
-
|
|
35
|
+
defaultParentCommentsCount,
|
|
36
|
+
limitedSortedParentComments,
|
|
32
37
|
editCommentId,
|
|
33
38
|
setEditCommentId,
|
|
34
|
-
|
|
39
|
+
replyToCommentId,
|
|
40
|
+
setReplyToCommentId,
|
|
41
|
+
limitedSortedParentCommentsCount,
|
|
35
42
|
t,
|
|
36
43
|
handleMoreComments: () => {
|
|
37
|
-
const newLimit = (
|
|
38
|
-
newLimit !==
|
|
44
|
+
const filteredComments = limitedSortedParentComments == null ? void 0 : limitedSortedParentComments.filter((comment) => !comment.replyTo), newLimit = (filteredComments == null ? void 0 : filteredComments.length) + (options.additionalComments ?? 5);
|
|
45
|
+
newLimit !== (filteredComments == null ? void 0 : filteredComments.length) && setCommentLimit(newLimit);
|
|
39
46
|
},
|
|
40
47
|
handleDeleteComment: (id) => {
|
|
41
48
|
type === "edit" && (callbacks == null || callbacks.delete(id));
|
|
42
49
|
},
|
|
43
50
|
handleCreateComment: (content, replyTo) => {
|
|
44
|
-
type === "edit" && (callbacks == null || callbacks.post(content, replyTo));
|
|
51
|
+
type === "edit" && (callbacks == null || callbacks.post(content, replyTo)), replyTo && setReplyToCommentId(null);
|
|
45
52
|
},
|
|
46
53
|
handleModifyComment: (commentId) => {
|
|
47
54
|
setEditCommentId(commentId);
|
|
@@ -52,6 +59,9 @@ const useComments = ({
|
|
|
52
59
|
commentId: editCommentId
|
|
53
60
|
})), setEditCommentId(null));
|
|
54
61
|
},
|
|
62
|
+
handleReplyToComment: (commentId) => {
|
|
63
|
+
setReplyToCommentId(commentId);
|
|
64
|
+
},
|
|
55
65
|
handleReset: () => {
|
|
56
66
|
editCommentId && setEditCommentId(null);
|
|
57
67
|
}
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
export declare const useCommentsContext: () => {
|
|
2
|
-
|
|
2
|
+
limitedSortedParentComments: import('../types').CommentProps[] | undefined;
|
|
3
|
+
defaultComments: import('../types').CommentProps[] | undefined;
|
|
3
4
|
editCommentId: string | null;
|
|
5
|
+
replyToCommentId: string | null;
|
|
4
6
|
profiles: (import('../types').UserProfileResult | undefined)[];
|
|
5
7
|
options: Partial<import('../types').CommentOptions>;
|
|
6
8
|
type: import('../types').CommentType;
|
|
7
9
|
userRights?: Record<import('@edifice.io/client').RightRole, boolean>;
|
|
8
10
|
setEditCommentId: (value: string | null) => void;
|
|
11
|
+
setReplyToCommentId: (value: string | null) => void;
|
|
9
12
|
handleModifyComment: (commentId: string) => void;
|
|
10
13
|
handleCreateComment: (content: string, replyTo?: string) => void;
|
|
11
14
|
handleUpdateComment: (comment: string) => void;
|
|
12
15
|
handleDeleteComment: (id: string) => void;
|
|
16
|
+
handleReplyToComment: (commentId: string) => void;
|
|
13
17
|
handleReset: () => void;
|
|
14
18
|
};
|
|
@@ -28,17 +28,20 @@ const CommentProvider = ({
|
|
|
28
28
|
title,
|
|
29
29
|
user,
|
|
30
30
|
emptyscreenPath,
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
defaultParentCommentsCount,
|
|
32
|
+
limitedSortedParentComments,
|
|
33
33
|
editCommentId,
|
|
34
34
|
setEditCommentId,
|
|
35
|
-
|
|
35
|
+
replyToCommentId,
|
|
36
|
+
setReplyToCommentId,
|
|
37
|
+
limitedSortedParentCommentsCount,
|
|
36
38
|
t,
|
|
37
39
|
handleMoreComments,
|
|
38
40
|
handleDeleteComment,
|
|
39
41
|
handleCreateComment,
|
|
40
42
|
handleModifyComment,
|
|
41
43
|
handleUpdateComment,
|
|
44
|
+
handleReplyToComment,
|
|
42
45
|
handleReset
|
|
43
46
|
} = useComments({
|
|
44
47
|
type,
|
|
@@ -47,21 +50,25 @@ const CommentProvider = ({
|
|
|
47
50
|
options
|
|
48
51
|
}), userRights = type === "edit" ? props.rights : void 0, values = useMemo(
|
|
49
52
|
() => ({
|
|
50
|
-
|
|
53
|
+
limitedSortedParentComments,
|
|
54
|
+
defaultComments,
|
|
51
55
|
profiles: profilesQueries.data,
|
|
52
56
|
editCommentId,
|
|
57
|
+
replyToCommentId,
|
|
53
58
|
options,
|
|
54
59
|
type,
|
|
55
60
|
userRights,
|
|
56
61
|
setEditCommentId,
|
|
62
|
+
setReplyToCommentId,
|
|
57
63
|
handleCreateComment,
|
|
58
64
|
handleModifyComment,
|
|
59
65
|
handleUpdateComment,
|
|
60
66
|
handleDeleteComment,
|
|
67
|
+
handleReplyToComment,
|
|
61
68
|
handleReset
|
|
62
69
|
}),
|
|
63
70
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
64
|
-
[
|
|
71
|
+
[limitedSortedParentComments, editCommentId, profilesQueries, options]
|
|
65
72
|
);
|
|
66
73
|
return /* @__PURE__ */ jsx(CommentContext.Provider, { value: values, children: /* @__PURE__ */ jsxs("div", { className: "my-24", children: [
|
|
67
74
|
/* @__PURE__ */ jsx(CommentHeader, { title }),
|
|
@@ -69,10 +76,10 @@ const CommentProvider = ({
|
|
|
69
76
|
user && /* @__PURE__ */ jsx(CommentForm, { userId: user.userId }),
|
|
70
77
|
profilesQueries.isLoading ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
71
78
|
/* @__PURE__ */ jsx(CommentList, {}),
|
|
72
|
-
|
|
79
|
+
limitedSortedParentCommentsCount !== defaultParentCommentsCount && /* @__PURE__ */ jsx(Button, { variant: "ghost", color: "tertiary", onClick: handleMoreComments, className: "my-16", children: t("comment.more") })
|
|
73
80
|
] })
|
|
74
81
|
] }),
|
|
75
|
-
!
|
|
82
|
+
!limitedSortedParentCommentsCount && type === "edit" && /* @__PURE__ */ jsxs("div", { className: "comments-emptyscreen", children: [
|
|
76
83
|
/* @__PURE__ */ jsx("div", { className: "comments-emptyscreen-wrapper", children: /* @__PURE__ */ jsx(EmptyScreen, { imageSrc: emptyscreenPath, size: 150 }) }),
|
|
77
84
|
/* @__PURE__ */ jsx("p", { children: t("comment.emptyscreen") })
|
|
78
85
|
] })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@edifice.io/react",
|
|
3
|
-
"version": "2.1.2-develop-pedago.
|
|
3
|
+
"version": "2.1.2-develop-pedago.20250320142932",
|
|
4
4
|
"description": "Edifice React Library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -118,9 +118,9 @@
|
|
|
118
118
|
"react-slugify": "^3.0.3",
|
|
119
119
|
"swiper": "^10.1.0",
|
|
120
120
|
"ua-parser-js": "^1.0.36",
|
|
121
|
-
"@edifice.io/bootstrap": "2.1.2-develop-pedago.
|
|
122
|
-
"@edifice.io/tiptap-extensions": "2.1.2-develop-pedago.
|
|
123
|
-
"@edifice.io/utilities": "2.1.2-develop-pedago.
|
|
121
|
+
"@edifice.io/bootstrap": "2.1.2-develop-pedago.20250320142932",
|
|
122
|
+
"@edifice.io/tiptap-extensions": "2.1.2-develop-pedago.20250320142932",
|
|
123
|
+
"@edifice.io/utilities": "2.1.2-develop-pedago.20250320142932"
|
|
124
124
|
},
|
|
125
125
|
"devDependencies": {
|
|
126
126
|
"@babel/plugin-transform-react-pure-annotations": "^7.23.3",
|
|
@@ -151,8 +151,8 @@
|
|
|
151
151
|
"vite": "^5.4.11",
|
|
152
152
|
"vite-plugin-dts": "^4.1.0",
|
|
153
153
|
"vite-tsconfig-paths": "^5.0.1",
|
|
154
|
-
"@edifice.io/config": "2.1.2-develop-pedago.
|
|
155
|
-
"@edifice.io/client": "2.1.2-develop-pedago.
|
|
154
|
+
"@edifice.io/config": "2.1.2-develop-pedago.20250320142932",
|
|
155
|
+
"@edifice.io/client": "2.1.2-develop-pedago.20250320142932"
|
|
156
156
|
},
|
|
157
157
|
"peerDependencies": {
|
|
158
158
|
"@react-spring/web": "^9.7.5",
|