@edifice.io/react 2.1.2-develop-pedago.20250320195838 → 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,28 +7,25 @@ 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
- slicedReplies,
19
- defaultReplies,
13
+ displayedReplies,
14
+ showCommentForm,
15
+ showMoreReplies,
20
16
  handleMoreReplies
21
17
  } = useCommentReplies({
22
- parentComment,
23
- profiles,
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
- /* @__PURE__ */ jsx("div", { className: "comments-replies-list", children: slicedReplies.map((reply) => {
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
  }) }),
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") })
28
+ showMoreReplies && /* @__PURE__ */ jsx(Button, { variant: "ghost", color: "tertiary", onClick: handleMoreReplies, className: "ms-24", children: t("comment.more.replies") })
33
29
  ] });
34
30
  };
35
31
  export {
@@ -1,13 +1,12 @@
1
- import { CommentOptions, CommentProps, UserProfileResult } from '../types';
2
- export declare const useCommentReplies: ({ parentComment, profiles, options, }: {
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
- profile: "Student" | "Teacher" | "Relative" | "Personnel" | "Guest";
10
- slicedReplies: CommentProps[];
11
- defaultReplies: CommentProps[];
8
+ showCommentForm: boolean;
9
+ displayedReplies: CommentProps[];
10
+ showMoreReplies: boolean;
12
11
  handleMoreReplies: () => void;
13
12
  };
@@ -3,32 +3,31 @@ 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)) ?? [], slicedReplies = (defaultReplies == null ? void 0 : defaultReplies.sort((a, b) => b.createdAt - a.createdAt).slice(0, repliesLimit)) ?? [];
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
- profile,
27
- slicedReplies,
28
- defaultReplies,
25
+ showCommentForm,
26
+ displayedReplies,
27
+ showMoreReplies,
29
28
  handleMoreReplies: () => {
30
- const newLimit = slicedReplies.length + (additionalReplies ?? 2);
31
- newLimit !== slicedReplies.length && setRepliesLimit(newLimit);
29
+ const newLimit = displayedReplies.length + (additionalReplies ?? 2);
30
+ newLimit !== displayedReplies.length && setRepliesLimit(newLimit);
32
31
  }
33
32
  };
34
33
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edifice.io/react",
3
- "version": "2.1.2-develop-pedago.20250320195838",
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.20250320195838",
122
- "@edifice.io/tiptap-extensions": "2.1.2-develop-pedago.20250320195838",
123
- "@edifice.io/utilities": "2.1.2-develop-pedago.20250320195838"
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.20250320195838",
155
- "@edifice.io/config": "2.1.2-develop-pedago.20250320195838"
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",