@edifice.io/react 2.1.2-develop-pedago.20250324160922 → 2.1.2-develop-pedago.20250325165832
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.
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useCommentsContext } from "../hooks/useCommentsContext.js";
|
|
3
2
|
import { Comment } from "./Comment.js";
|
|
4
3
|
import { CommentForm } from "./CommentForm.js";
|
|
5
4
|
import { useCommentReplies } from "../hooks/useCommentReplies.js";
|
|
@@ -8,24 +7,21 @@ const CommentReplies = ({
|
|
|
8
7
|
parentComment
|
|
9
8
|
}) => {
|
|
10
9
|
const {
|
|
11
|
-
profiles,
|
|
12
|
-
options,
|
|
13
|
-
replyToCommentId
|
|
14
|
-
} = useCommentsContext(), {
|
|
15
10
|
t,
|
|
11
|
+
profiles,
|
|
16
12
|
user,
|
|
17
|
-
profile,
|
|
18
13
|
displayedReplies,
|
|
14
|
+
showCommentForm,
|
|
19
15
|
showMoreReplies,
|
|
20
16
|
handleMoreReplies
|
|
21
17
|
} = useCommentReplies({
|
|
22
|
-
parentComment
|
|
23
|
-
|
|
24
|
-
options
|
|
25
|
-
}), showCommentForm = replyToCommentId === parentComment.id && !parentComment.deleted;
|
|
18
|
+
parentComment
|
|
19
|
+
});
|
|
26
20
|
return /* @__PURE__ */ jsxs("div", { className: "comments-replies-container", children: [
|
|
27
21
|
showCommentForm && /* @__PURE__ */ jsx("div", { className: "comments-replies-form", children: /* @__PURE__ */ jsx(CommentForm, { userId: user == null ? void 0 : user.userId, replyTo: parentComment.id }) }),
|
|
28
22
|
/* @__PURE__ */ jsx("div", { className: "comments-replies-list", children: displayedReplies.map((reply) => {
|
|
23
|
+
var _a;
|
|
24
|
+
const profile = ((_a = profiles == null ? void 0 : profiles.find((user2) => (user2 == null ? void 0 : user2.userId) === reply.authorId)) == null ? void 0 : _a.profile) ?? "Guest";
|
|
29
25
|
if (!reply.deleted)
|
|
30
26
|
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
27
|
}) }),
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const useCommentReplies: ({ parentComment,
|
|
1
|
+
import { CommentProps } from '../types';
|
|
2
|
+
export declare const useCommentReplies: ({ parentComment, }: {
|
|
3
3
|
parentComment: CommentProps;
|
|
4
|
-
profiles: (UserProfileResult | undefined)[];
|
|
5
|
-
options: Partial<CommentOptions>;
|
|
6
4
|
}) => {
|
|
7
5
|
t: import('i18next').TFunction<"translation", undefined>;
|
|
6
|
+
profiles: (import('../types').UserProfileResult | undefined)[];
|
|
8
7
|
user: import('@edifice.io/client').IUserInfo | undefined;
|
|
9
|
-
|
|
8
|
+
showCommentForm: boolean;
|
|
10
9
|
displayedReplies: CommentProps[];
|
|
11
10
|
showMoreReplies: boolean;
|
|
12
11
|
handleMoreReplies: () => void;
|
|
@@ -3,27 +3,26 @@ import { useTranslation } from "react-i18next";
|
|
|
3
3
|
import { useEdificeClient } from "../../../providers/EdificeClientProvider/EdificeClientProvider.hook.js";
|
|
4
4
|
import { useCommentsContext } from "./useCommentsContext.js";
|
|
5
5
|
const useCommentReplies = ({
|
|
6
|
-
parentComment
|
|
7
|
-
profiles,
|
|
8
|
-
options
|
|
6
|
+
parentComment
|
|
9
7
|
}) => {
|
|
10
|
-
var _a;
|
|
11
8
|
const {
|
|
9
|
+
profiles,
|
|
10
|
+
options,
|
|
11
|
+
replyToCommentId,
|
|
12
|
+
defaultComments
|
|
13
|
+
} = useCommentsContext(), {
|
|
12
14
|
maxReplies,
|
|
13
15
|
additionalReplies
|
|
14
16
|
} = options, [repliesLimit, setRepliesLimit] = useState(maxReplies), {
|
|
15
|
-
defaultComments
|
|
16
|
-
} = useCommentsContext(), {
|
|
17
17
|
user
|
|
18
18
|
} = useEdificeClient(), {
|
|
19
19
|
t
|
|
20
|
-
} = useTranslation(),
|
|
21
|
-
authorId
|
|
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 && !comment.deleted)) ?? [], displayedReplies = (defaultReplies == null ? void 0 : defaultReplies.sort((a, b) => a.createdAt - b.createdAt).slice(0, repliesLimit)) ?? [], showMoreReplies = displayedReplies.length < defaultReplies.length;
|
|
20
|
+
} = useTranslation(), showCommentForm = replyToCommentId === parentComment.id && !parentComment.deleted, defaultReplies = (defaultComments == null ? void 0 : defaultComments.filter((comment) => comment.replyTo === parentComment.id && !comment.deleted)) ?? [], displayedReplies = (defaultReplies == null ? void 0 : defaultReplies.sort((a, b) => a.createdAt - b.createdAt).slice(0, repliesLimit)) ?? [], showMoreReplies = displayedReplies.length < defaultReplies.length;
|
|
23
21
|
return {
|
|
24
22
|
t,
|
|
23
|
+
profiles,
|
|
25
24
|
user,
|
|
26
|
-
|
|
25
|
+
showCommentForm,
|
|
27
26
|
displayedReplies,
|
|
28
27
|
showMoreReplies,
|
|
29
28
|
handleMoreReplies: () => {
|
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.20250325165832",
|
|
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.20250325165832",
|
|
122
|
+
"@edifice.io/tiptap-extensions": "2.1.2-develop-pedago.20250325165832",
|
|
123
|
+
"@edifice.io/utilities": "2.1.2-develop-pedago.20250325165832"
|
|
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/client": "2.1.2-develop-pedago.
|
|
155
|
-
"@edifice.io/config": "2.1.2-develop-pedago.
|
|
154
|
+
"@edifice.io/client": "2.1.2-develop-pedago.20250325165832",
|
|
155
|
+
"@edifice.io/config": "2.1.2-develop-pedago.20250325165832"
|
|
156
156
|
},
|
|
157
157
|
"peerDependencies": {
|
|
158
158
|
"@react-spring/web": "^9.7.5",
|