@edifice.io/react 2.1.2-develop-pedago.20250305164234 → 2.1.2-develop-pedago.20250311124111

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,7 +1,8 @@
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, onReply, }: {
4
4
  comment: CommentProps;
5
5
  userId: string;
6
6
  profile: UserProfile[number];
7
+ onReply?: (commentId: string) => void;
7
8
  }) => import("react/jsx-runtime").JSX.Element;
@@ -1,4 +1,4 @@
1
- import { jsxs, jsx, Fragment } from "react/jsx-runtime";
1
+ import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
2
  import { useState, Suspense, lazy } from "react";
3
3
  import { useTranslation } from "react-i18next";
4
4
  import SvgIconSave from "../../icons/components/IconSave.js";
@@ -14,7 +14,8 @@ import LoadingScreen from "../../../components/LoadingScreen/LoadingScreen.js";
14
14
  const DeleteModal = /* @__PURE__ */ lazy(() => import("./DeleteModal.js")), Comment = ({
15
15
  comment,
16
16
  userId,
17
- profile
17
+ profile,
18
+ onReply
18
19
  }) => {
19
20
  const [value, setValue] = useState(""), {
20
21
  id,
@@ -37,38 +38,41 @@ const DeleteModal = /* @__PURE__ */ lazy(() => import("./DeleteModal.js")), Comm
37
38
  } = useCommentsContext(), isEditing = editCommentId === comment.id, handleChangeContent = (event) => {
38
39
  resizeTextarea(), setValue(event.target.value);
39
40
  };
40
- return /* @__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: [
41
- /* @__PURE__ */ jsx(CommentAvatar, { id: authorId }),
42
- /* @__PURE__ */ jsxs("div", { className: "flex flex-fill", children: [
43
- /* @__PURE__ */ jsxs("div", { className: "d-flex align-items-center gap-12", children: [
44
- /* @__PURE__ */ jsx(CommentTitle, { children: authorName }),
45
- /* @__PURE__ */ jsx(BadgeProfile, { profile }),
46
- /* @__PURE__ */ jsx(CommentDate, { createdAt, updatedAt })
47
- ] }),
48
- isEditing ? /* @__PURE__ */ jsxs(Fragment, { children: [
49
- /* @__PURE__ */ jsx("div", { className: "mt-8 mb-4", children: /* @__PURE__ */ jsx("textarea", { id: "update-comment", ref, value, className: "form-control", placeholder: t("comment.placeholder"), maxLength: options.maxCommentLength, onChange: handleChangeContent, rows: 1, style: {
50
- resize: "none",
51
- overflow: "hidden"
52
- }, onFocus }) }),
53
- /* @__PURE__ */ jsxs("div", { className: "d-flex justify-content-between align-items-center", children: [
54
- /* @__PURE__ */ jsx(Button, { variant: "ghost", color: "tertiary", size: "sm", onClick: handleReset, children: t("comment.cancel") }),
55
- /* @__PURE__ */ jsxs("div", { className: "d-flex justify-content-end align-items-center gap-4", children: [
56
- /* @__PURE__ */ jsx(TextCounter, { content: value, maxLength: options.maxCommentLength }),
57
- /* @__PURE__ */ jsx(Button, { type: "submit", variant: "ghost", size: "sm", leftIcon: /* @__PURE__ */ jsx(SvgIconSave, {}), disabled: !(content != null && content.length), onClick: () => handleUpdateComment(value), children: t("comment.save") })
41
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
42
+ /* @__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: [
43
+ /* @__PURE__ */ jsx(CommentAvatar, { id: authorId }),
44
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-fill", children: [
45
+ /* @__PURE__ */ jsxs("div", { className: "d-flex align-items-center gap-12", children: [
46
+ /* @__PURE__ */ jsx(CommentTitle, { children: authorName }),
47
+ /* @__PURE__ */ jsx(BadgeProfile, { profile }),
48
+ /* @__PURE__ */ jsx(CommentDate, { createdAt, updatedAt })
49
+ ] }),
50
+ isEditing ? /* @__PURE__ */ jsxs(Fragment, { children: [
51
+ /* @__PURE__ */ jsx("div", { className: "mt-8 mb-4", children: /* @__PURE__ */ jsx("textarea", { id: "update-comment", ref, value, className: "form-control", placeholder: t("comment.placeholder"), maxLength: options.maxCommentLength, onChange: handleChangeContent, rows: 1, style: {
52
+ resize: "none",
53
+ overflow: "hidden"
54
+ }, onFocus }) }),
55
+ /* @__PURE__ */ jsxs("div", { className: "d-flex justify-content-between align-items-center", children: [
56
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", color: "tertiary", size: "sm", onClick: handleReset, children: t("comment.cancel") }),
57
+ /* @__PURE__ */ jsxs("div", { className: "d-flex justify-content-end align-items-center gap-4", children: [
58
+ /* @__PURE__ */ jsx(TextCounter, { content: value, maxLength: options.maxCommentLength }),
59
+ /* @__PURE__ */ jsx(Button, { type: "submit", variant: "ghost", size: "sm", leftIcon: /* @__PURE__ */ jsx(SvgIconSave, {}), disabled: !(content != null && content.length), onClick: () => handleUpdateComment(value), children: t("comment.save") })
60
+ ] })
61
+ ] })
62
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
63
+ /* @__PURE__ */ jsx("div", { className: "mt-8 mb-4", children: content }),
64
+ type === "edit" && /* @__PURE__ */ jsxs("div", { className: "ms-n8", children: [
65
+ !comment.replyTo && /* @__PURE__ */ jsx(Button, { variant: "ghost", color: "tertiary", size: "sm", onClick: () => onReply == null ? void 0 : onReply(comment.id), children: t("comment.reply") }),
66
+ userId === authorId && /* @__PURE__ */ jsx(Button, { variant: "ghost", color: "tertiary", size: "sm", onClick: () => {
67
+ handleModifyComment(comment.id), setValue(content);
68
+ }, children: t("comment.edit") }),
69
+ (userId === authorId || (userRights == null ? void 0 : userRights.manager)) && /* @__PURE__ */ jsx(Button, { variant: "ghost", color: "tertiary", size: "sm", onClick: () => setIsDeleteModalOpen(!0), children: t("comment.remove") })
58
70
  ] })
59
- ] })
60
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
61
- /* @__PURE__ */ jsx("div", { className: "mt-8 mb-4", children: content }),
62
- type === "edit" && /* @__PURE__ */ jsxs("div", { className: "ms-n8", children: [
63
- userId === authorId && /* @__PURE__ */ jsx(Button, { variant: "ghost", color: "tertiary", size: "sm", onClick: () => {
64
- handleModifyComment(comment.id), setValue(content);
65
- }, children: t("comment.edit") }),
66
- (userId === authorId || (userRights == null ? void 0 : userRights.manager)) && /* @__PURE__ */ jsx(Button, { variant: "ghost", color: "tertiary", size: "sm", onClick: () => setIsDeleteModalOpen(!0), children: t("comment.remove") })
67
71
  ] })
68
72
  ] })
69
- ] }),
73
+ ] }, id),
70
74
  /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingScreen, { position: !1 }), children: isDeleteModalOpen && /* @__PURE__ */ jsx(DeleteModal, { isOpen: isDeleteModalOpen, onCancel: () => setIsDeleteModalOpen(!1), onSuccess: () => onDeleteComment(id) }) })
71
- ] }, id);
75
+ ] });
72
76
  };
73
77
  export {
74
78
  Comment
@@ -1,3 +1,4 @@
1
- export declare const CommentForm: ({ userId }: {
1
+ export declare const CommentForm: ({ userId, replyTo, }: {
2
2
  userId: string;
3
+ replyTo?: string;
3
4
  }) => import("react/jsx-runtime").JSX.Element;
@@ -5,19 +5,23 @@ import { useAutosizeTextarea } from "../hooks/useAutosizeTextarea.js";
5
5
  import { useCommentsContext } from "../hooks/useCommentsContext.js";
6
6
  import { CommentAvatar } from "./CommentAvatar.js";
7
7
  import { TextCounter } from "./TextCounter.js";
8
+ import { useState } from "react";
8
9
  import Button from "../../../components/Button/Button.js";
9
10
  const CommentForm = ({
10
- userId
11
+ userId,
12
+ replyTo
11
13
  }) => {
12
- const {
13
- t
14
- } = useTranslation(), {
15
- content,
16
- handleChangeContent,
14
+ const [content, setContent] = useState(""), {
17
15
  handleCreateComment,
18
16
  options,
19
17
  type
20
- } = useCommentsContext(), [ref, onFocus] = useAutosizeTextarea();
18
+ } = useCommentsContext(), [ref, onFocus] = useAutosizeTextarea(), {
19
+ t
20
+ } = useTranslation(), handleChangeContent = (event) => {
21
+ setContent(event.target.value);
22
+ }, handleSubmit = () => {
23
+ handleCreateComment(content, replyTo), setContent("");
24
+ };
21
25
  return /* @__PURE__ */ jsx(Fragment, { children: type === "edit" && /* @__PURE__ */ jsxs("div", { className: "border rounded-3 p-12 pb-8 d-flex gap-12 bg-gray-200", children: [
22
26
  /* @__PURE__ */ jsx(CommentAvatar, { id: userId }),
23
27
  /* @__PURE__ */ jsxs("div", { className: "d-flex flex-column flex-fill gap-4", children: [
@@ -27,7 +31,7 @@ const CommentForm = ({
27
31
  } }),
28
32
  /* @__PURE__ */ jsxs("div", { className: "d-flex justify-content-end align-items-center gap-4", children: [
29
33
  /* @__PURE__ */ jsx(TextCounter, { content, maxLength: options.maxCommentLength }),
30
- /* @__PURE__ */ jsx(Button, { type: "submit", variant: "ghost", size: "sm", leftIcon: /* @__PURE__ */ jsx(SvgIconSend, {}), disabled: !(content != null && content.length), onClick: () => handleCreateComment(content), children: t("comment.post") })
34
+ /* @__PURE__ */ jsx(Button, { type: "submit", variant: "ghost", size: "sm", leftIcon: /* @__PURE__ */ jsx(SvgIconSend, {}), disabled: !(content != null && content.length), onClick: handleSubmit, children: t("comment.post") })
31
35
  ] })
32
36
  ] })
33
37
  ] }) });
@@ -1,20 +1,27 @@
1
- import { jsx } from "react/jsx-runtime";
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useState } from "react";
2
3
  import { useEdificeClient } from "../../../providers/EdificeClientProvider/EdificeClientProvider.hook.js";
3
4
  import { useCommentsContext } from "../hooks/useCommentsContext.js";
4
5
  import { Comment } from "./Comment.js";
6
+ import { CommentReplies } from "./CommentReplies.js";
5
7
  function CommentList() {
6
- const {
8
+ const [replyFormCommentId, setReplyFormCommentId] = useState(""), {
7
9
  user
8
10
  } = useEdificeClient(), {
9
11
  comments,
10
12
  profiles
11
- } = useCommentsContext();
13
+ } = useCommentsContext(), handleReply = (commentId) => {
14
+ setReplyFormCommentId(commentId);
15
+ };
12
16
  return comments == null ? void 0 : comments.map((comment) => {
13
17
  var _a;
14
18
  const {
15
19
  authorId
16
20
  } = comment, profile = ((_a = profiles == null ? void 0 : profiles.find((user2) => (user2 == null ? void 0 : user2.userId) === authorId)) == null ? void 0 : _a.profile) ?? "Guest";
17
- return /* @__PURE__ */ jsx(Comment, { comment, profile, userId: user == null ? void 0 : user.userId }, comment.id);
21
+ return /* @__PURE__ */ jsxs("div", { children: [
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);
18
25
  });
19
26
  }
20
27
  export {
@@ -0,0 +1,5 @@
1
+ import { CommentProps } from '../types';
2
+ export declare const CommentReplies: ({ parentComment, replyFormCommentId, }: {
3
+ parentComment: CommentProps;
4
+ replyFormCommentId: string;
5
+ }) => import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,36 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useCommentsContext } from "../hooks/useCommentsContext.js";
3
+ import { Comment } from "./Comment.js";
4
+ import { CommentForm } from "./CommentForm.js";
5
+ import { useCommentReplies } from "../hooks/useCommentReplies.js";
6
+ import Button from "../../../components/Button/Button.js";
7
+ const CommentReplies = ({
8
+ parentComment,
9
+ replyFormCommentId
10
+ }) => {
11
+ const {
12
+ comments,
13
+ profiles,
14
+ options
15
+ } = useCommentsContext(), {
16
+ t,
17
+ user,
18
+ profile,
19
+ slicedReplies,
20
+ defaultReplies,
21
+ handleMoreReplies
22
+ } = useCommentReplies({
23
+ parentComment,
24
+ comments,
25
+ profiles,
26
+ options
27
+ });
28
+ return /* @__PURE__ */ jsxs("div", { className: "comments-replies-container", children: [
29
+ replyFormCommentId === parentComment.id && /* @__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) => /* @__PURE__ */ jsx("div", { className: "comments-replies-reply", children: /* @__PURE__ */ jsx(Comment, { comment: reply, profile, userId: user == null ? void 0 : user.userId }) }, reply.id)) }),
31
+ 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
+ };
34
+ export {
35
+ CommentReplies
36
+ };
@@ -18,3 +18,7 @@ export declare const DEFAULT_ADD_COMMENTS = 5;
18
18
  * Limit to display replies of a comment
19
19
  */
20
20
  export declare const DEFAULT_MAX_REPLIES = 5;
21
+ /**
22
+ * Number of comments to add when adding more comment in the limited list
23
+ */
24
+ export declare const DEFAULT_ADD_REPLIES = 5;
@@ -1,6 +1,7 @@
1
- const DEFAULT_MAX_COMMENT_LENGTH = 200, DEFAULT_MAX_REPLY_LENGTH = 200, DEFAULT_MAX_COMMENTS = 4, DEFAULT_ADD_COMMENTS = 5, DEFAULT_MAX_REPLIES = 5;
1
+ const DEFAULT_MAX_COMMENT_LENGTH = 200, DEFAULT_MAX_REPLY_LENGTH = 200, DEFAULT_MAX_COMMENTS = 4, DEFAULT_ADD_COMMENTS = 5, DEFAULT_MAX_REPLIES = 5, DEFAULT_ADD_REPLIES = 5;
2
2
  export {
3
3
  DEFAULT_ADD_COMMENTS,
4
+ DEFAULT_ADD_REPLIES,
4
5
  DEFAULT_MAX_COMMENTS,
5
6
  DEFAULT_MAX_COMMENT_LENGTH,
6
7
  DEFAULT_MAX_REPLIES,
@@ -2,7 +2,6 @@ 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
  comments: CommentProps[] | undefined;
5
- content: string;
6
5
  editCommentId: string | null;
7
6
  profiles: (UserProfileResult | undefined)[];
8
7
  options: Partial<CommentOptions>;
@@ -10,8 +9,7 @@ export declare const CommentContext: import('react').Context<{
10
9
  userRights?: Record<RightRole, boolean>;
11
10
  setEditCommentId: (value: string | null) => void;
12
11
  handleModifyComment: (commentId: string) => void;
13
- handleChangeContent: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;
14
- handleCreateComment: (content: string) => void;
12
+ handleCreateComment: (content: string, replyTo?: string) => void;
15
13
  handleUpdateComment: (comment: string) => void;
16
14
  handleDeleteComment: (id: string) => void;
17
15
  handleReset: () => void;
@@ -0,0 +1,15 @@
1
+ import { CommentOptions, CommentProps, UserProfileResult } from '../types';
2
+ export declare const useCommentReplies: ({ parentComment, comments, profiles, options, }: {
3
+ parentComment: CommentProps;
4
+ comments: CommentProps[] | undefined;
5
+ profiles: (UserProfileResult | undefined)[];
6
+ options: Partial<CommentOptions>;
7
+ }) => {
8
+ t: import('i18next').TFunction<"translation", undefined>;
9
+ user: import('@edifice.io/client').IUserInfo | undefined;
10
+ profile: "Student" | "Teacher" | "Relative" | "Personnel" | "Guest";
11
+ slicedReplies: CommentProps[];
12
+ defaultReplies: CommentProps[];
13
+ orphanReplies: CommentProps[];
14
+ handleMoreReplies: () => void;
15
+ };
@@ -0,0 +1,36 @@
1
+ import { useState } from "react";
2
+ import { useTranslation } from "react-i18next";
3
+ import { useEdificeClient } from "../../../providers/EdificeClientProvider/EdificeClientProvider.hook.js";
4
+ const useCommentReplies = ({
5
+ parentComment,
6
+ comments,
7
+ profiles,
8
+ options
9
+ }) => {
10
+ var _a;
11
+ const {
12
+ maxReplies,
13
+ additionalReplies
14
+ } = options, [repliesLimit, setRepliesLimit] = useState(maxReplies), {
15
+ user
16
+ } = useEdificeClient(), {
17
+ t
18
+ } = useTranslation(), {
19
+ 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 = (comments == null ? void 0 : comments.filter((comment) => comment.replyTo === parentComment.id)) ?? [], slicedReplies = (defaultReplies == null ? void 0 : defaultReplies.sort((a, b) => b.createdAt - a.createdAt).slice(0, repliesLimit)) ?? [], orphanReplies = (comments == null ? void 0 : comments.filter((comment) => comment.replyTo && !comments.find((c) => c.id === comment.replyTo))) ?? [];
21
+ return {
22
+ t,
23
+ user,
24
+ profile,
25
+ slicedReplies,
26
+ defaultReplies,
27
+ orphanReplies,
28
+ handleMoreReplies: () => {
29
+ const newLimit = slicedReplies.length + (additionalReplies ?? 2);
30
+ newLimit !== slicedReplies.length && setRepliesLimit(newLimit);
31
+ }
32
+ };
33
+ };
34
+ export {
35
+ useCommentReplies
36
+ };
@@ -12,7 +12,6 @@ export declare const useComments: ({ defaultComments, options, type, callbacks,
12
12
  } | undefined)[];
13
13
  isLoading: boolean;
14
14
  };
15
- content: string;
16
15
  title: string;
17
16
  user: import('@edifice.io/client').IUserInfo | undefined;
18
17
  emptyscreenPath: string;
@@ -23,9 +22,8 @@ export declare const useComments: ({ defaultComments, options, type, callbacks,
23
22
  commentsCount: number;
24
23
  t: import('i18next').TFunction<"translation", undefined>;
25
24
  handleMoreComments: () => void;
26
- handleChangeContent: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;
27
25
  handleDeleteComment: (id: string) => void;
28
- handleCreateComment: (content: string) => void;
26
+ handleCreateComment: (content: string, replyTo?: string) => void;
29
27
  handleModifyComment: (commentId: string) => void;
30
28
  handleUpdateComment: (comment: string) => Promise<void>;
31
29
  handleReset: () => void;
@@ -9,7 +9,7 @@ const useComments = ({
9
9
  type,
10
10
  callbacks
11
11
  }) => {
12
- const [content, setContent] = useState(""), [editCommentId, setEditCommentId] = useState(null), [commentLimit, setCommentLimit] = useState(options.maxComments), {
12
+ const [editCommentId, setEditCommentId] = useState(null), [commentLimit, setCommentLimit] = useState(options.maxComments), {
13
13
  t
14
14
  } = useTranslation(), {
15
15
  user
@@ -24,7 +24,6 @@ const useComments = ({
24
24
  });
25
25
  return {
26
26
  profilesQueries,
27
- content,
28
27
  title,
29
28
  user,
30
29
  emptyscreenPath: illuPad,
@@ -38,14 +37,11 @@ const useComments = ({
38
37
  const newLimit = (comments == null ? void 0 : comments.length) + (options.additionalComments ?? 5);
39
38
  newLimit !== comments.length && setCommentLimit(newLimit);
40
39
  },
41
- handleChangeContent: (event) => {
42
- setContent(event.target.value);
43
- },
44
40
  handleDeleteComment: (id) => {
45
41
  type === "edit" && (callbacks == null || callbacks.delete(id));
46
42
  },
47
- handleCreateComment: (content2) => {
48
- type === "edit" && (callbacks == null || callbacks.post(content2)), setContent("");
43
+ handleCreateComment: (content, replyTo) => {
44
+ type === "edit" && (callbacks == null || callbacks.post(content, replyTo));
49
45
  },
50
46
  handleModifyComment: (commentId) => {
51
47
  setEditCommentId(commentId);
@@ -57,7 +53,7 @@ const useComments = ({
57
53
  })), setEditCommentId(null));
58
54
  },
59
55
  handleReset: () => {
60
- setContent(""), editCommentId && setEditCommentId(null);
56
+ editCommentId && setEditCommentId(null);
61
57
  }
62
58
  };
63
59
  };
@@ -1,6 +1,5 @@
1
1
  export declare const useCommentsContext: () => {
2
2
  comments: import('../types').CommentProps[] | undefined;
3
- content: string;
4
3
  editCommentId: string | null;
5
4
  profiles: (import('../types').UserProfileResult | undefined)[];
6
5
  options: Partial<import('../types').CommentOptions>;
@@ -8,8 +7,7 @@ export declare const useCommentsContext: () => {
8
7
  userRights?: Record<import('@edifice.io/client').RightRole, boolean>;
9
8
  setEditCommentId: (value: string | null) => void;
10
9
  handleModifyComment: (commentId: string) => void;
11
- handleChangeContent: (event: React.ChangeEvent<HTMLTextAreaElement>) => void;
12
- handleCreateComment: (content: string) => void;
10
+ handleCreateComment: (content: string, replyTo?: string) => void;
13
11
  handleUpdateComment: (comment: string) => void;
14
12
  handleDeleteComment: (id: string) => void;
15
13
  handleReset: () => void;
@@ -3,7 +3,7 @@ import { useMemo } from "react";
3
3
  import { CommentForm } from "../components/CommentForm.js";
4
4
  import { CommentHeader } from "../components/CommentHeader.js";
5
5
  import { CommentList } from "../components/CommentList.js";
6
- import { DEFAULT_MAX_REPLIES, DEFAULT_ADD_COMMENTS, DEFAULT_MAX_COMMENTS, DEFAULT_MAX_REPLY_LENGTH, DEFAULT_MAX_COMMENT_LENGTH } from "../constants.js";
6
+ import { DEFAULT_ADD_REPLIES, DEFAULT_MAX_REPLIES, DEFAULT_ADD_COMMENTS, DEFAULT_MAX_COMMENTS, DEFAULT_MAX_REPLY_LENGTH, DEFAULT_MAX_COMMENT_LENGTH } from "../constants.js";
7
7
  import { CommentContext } from "../context/Context.js";
8
8
  import { useComments } from "../hooks/useComments.js";
9
9
  import Button from "../../../components/Button/Button.js";
@@ -19,12 +19,12 @@ const CommentProvider = ({
19
19
  maxComments: DEFAULT_MAX_COMMENTS,
20
20
  additionalComments: DEFAULT_ADD_COMMENTS,
21
21
  maxReplies: DEFAULT_MAX_REPLIES,
22
+ additionalReplies: DEFAULT_ADD_REPLIES,
22
23
  ...commentOptions
23
24
  }, {
24
25
  type
25
26
  } = props, {
26
27
  profilesQueries,
27
- content,
28
28
  title,
29
29
  user,
30
30
  emptyscreenPath,
@@ -35,7 +35,6 @@ const CommentProvider = ({
35
35
  commentsCount,
36
36
  t,
37
37
  handleMoreComments,
38
- handleChangeContent,
39
38
  handleDeleteComment,
40
39
  handleCreateComment,
41
40
  handleModifyComment,
@@ -49,7 +48,6 @@ const CommentProvider = ({
49
48
  }), userRights = type === "edit" ? props.rights : void 0, values = useMemo(
50
49
  () => ({
51
50
  comments,
52
- content,
53
51
  profiles: profilesQueries.data,
54
52
  editCommentId,
55
53
  options,
@@ -60,11 +58,10 @@ const CommentProvider = ({
60
58
  handleModifyComment,
61
59
  handleUpdateComment,
62
60
  handleDeleteComment,
63
- handleReset,
64
- handleChangeContent
61
+ handleReset
65
62
  }),
66
63
  // eslint-disable-next-line react-hooks/exhaustive-deps
67
- [comments, content, editCommentId, profilesQueries, options]
64
+ [comments, editCommentId, profilesQueries, options]
68
65
  );
69
66
  return /* @__PURE__ */ jsx(CommentContext.Provider, { value: values, children: /* @__PURE__ */ jsxs("div", { className: "my-24", children: [
70
67
  /* @__PURE__ */ jsx(CommentHeader, { title }),
@@ -24,13 +24,18 @@ export interface CommentProps {
24
24
  * Date when comment was updated
25
25
  */
26
26
  updatedAt?: number;
27
+ /**
28
+ * The comment parent ID.
29
+ */
30
+ replyTo?: string;
27
31
  }
28
32
  export interface CommentCallbacks {
29
33
  /**
30
34
  * Method to create a new comment
31
35
  * Get the new comment in the callback function
36
+ * If replyTo is provided, it is a reply to a comment
32
37
  */
33
- post: (comment: string) => Promise<void>;
38
+ post: (comment: string, replyTo?: string) => Promise<void>;
34
39
  /**
35
40
  * Method to update a comment
36
41
  * Get the comment and commentId in the callback function
@@ -91,6 +96,10 @@ export type CommentOptions = {
91
96
  * Limit on displaying replies to a comment
92
97
  */
93
98
  maxReplies: number;
99
+ /**
100
+ * Number of replies to load additionally in the limited list
101
+ */
102
+ additionalReplies: number;
94
103
  };
95
104
  export interface UserProfileResult {
96
105
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edifice.io/react",
3
- "version": "2.1.2-develop-pedago.20250305164234",
3
+ "version": "2.1.2-develop-pedago.20250311124111",
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.20250305164234",
122
- "@edifice.io/tiptap-extensions": "2.1.2-develop-pedago.20250305164234",
123
- "@edifice.io/utilities": "2.1.2-develop-pedago.20250305164234"
121
+ "@edifice.io/bootstrap": "2.1.2-develop-pedago.20250311124111",
122
+ "@edifice.io/utilities": "2.1.2-develop-pedago.20250311124111",
123
+ "@edifice.io/tiptap-extensions": "2.1.2-develop-pedago.20250311124111"
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.20250305164234",
155
- "@edifice.io/config": "2.1.2-develop-pedago.20250305164234"
154
+ "@edifice.io/client": "2.1.2-develop-pedago.20250311124111",
155
+ "@edifice.io/config": "2.1.2-develop-pedago.20250311124111"
156
156
  },
157
157
  "peerDependencies": {
158
158
  "@react-spring/web": "^9.7.5",