@edifice.io/react 2.1.2-develop-pedago.20250320142932 → 2.1.2-develop-pedago.20250320195838
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/CommentList.js +2 -2
- package/dist/modules/comments/context/Context.d.ts +1 -1
- package/dist/modules/comments/hooks/useComments.d.ts +3 -4
- package/dist/modules/comments/hooks/useComments.js +12 -13
- package/dist/modules/comments/hooks/useCommentsContext.d.ts +1 -1
- package/dist/modules/comments/provider/CommentProvider.js +6 -7
- package/package.json +6 -6
|
@@ -6,10 +6,10 @@ function CommentList() {
|
|
|
6
6
|
const {
|
|
7
7
|
user
|
|
8
8
|
} = useEdificeClient(), {
|
|
9
|
-
|
|
9
|
+
displayedComments,
|
|
10
10
|
profiles
|
|
11
11
|
} = useCommentsContext();
|
|
12
|
-
return
|
|
12
|
+
return displayedComments == null ? void 0 : displayedComments.map((comment) => {
|
|
13
13
|
var _a;
|
|
14
14
|
const {
|
|
15
15
|
authorId
|
|
@@ -1,7 +1,7 @@
|
|
|
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
|
+
displayedComments: CommentProps[] | undefined;
|
|
5
5
|
defaultComments: CommentProps[] | undefined;
|
|
6
6
|
editCommentId: string | null;
|
|
7
7
|
replyToCommentId: string | null;
|
|
@@ -5,6 +5,7 @@ export declare const useComments: ({ defaultComments, options, type, callbacks,
|
|
|
5
5
|
type: CommentType;
|
|
6
6
|
callbacks: CommentCallbacks | null;
|
|
7
7
|
}) => {
|
|
8
|
+
t: import('i18next').TFunction<"translation", undefined>;
|
|
8
9
|
profilesQueries: {
|
|
9
10
|
data: ({
|
|
10
11
|
userId: string;
|
|
@@ -15,14 +16,12 @@ export declare const useComments: ({ defaultComments, options, type, callbacks,
|
|
|
15
16
|
title: string;
|
|
16
17
|
user: import('@edifice.io/client').IUserInfo | undefined;
|
|
17
18
|
emptyscreenPath: string;
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
displayedComments: CommentProps[];
|
|
20
|
+
showMoreComments: boolean;
|
|
20
21
|
editCommentId: string | null;
|
|
21
22
|
setEditCommentId: import('react').Dispatch<import('react').SetStateAction<string | null>>;
|
|
22
23
|
replyToCommentId: string | null;
|
|
23
24
|
setReplyToCommentId: import('react').Dispatch<import('react').SetStateAction<string | null>>;
|
|
24
|
-
limitedSortedParentCommentsCount: number;
|
|
25
|
-
t: import('i18next').TFunction<"translation", undefined>;
|
|
26
25
|
handleMoreComments: () => void;
|
|
27
26
|
handleDeleteComment: (id: string) => void;
|
|
28
27
|
handleCreateComment: (content: string, replyTo?: string) => void;
|
|
@@ -9,40 +9,39 @@ const useComments = ({
|
|
|
9
9
|
type,
|
|
10
10
|
callbacks
|
|
11
11
|
}) => {
|
|
12
|
-
var _a;
|
|
12
|
+
var _a, _b;
|
|
13
13
|
const [editCommentId, setEditCommentId] = useState(null), [replyToCommentId, setReplyToCommentId] = useState(null), [commentLimit, setCommentLimit] = useState(options.maxComments), {
|
|
14
14
|
t
|
|
15
15
|
} = useTranslation(), {
|
|
16
16
|
user
|
|
17
|
-
} = useEdificeClient(), usersIds = Array.from(new Set(defaultComments == null ? void 0 : defaultComments.map((comment) => comment.authorId))), profilesQueries = useProfileQueries(usersIds),
|
|
17
|
+
} = useEdificeClient(), usersIds = Array.from(new Set(defaultComments == null ? void 0 : defaultComments.map((comment) => comment.authorId))), profilesQueries = useProfileQueries(usersIds), idsOfDeletedCommentWithNoReply = useMemo(() => (defaultComments == null ? void 0 : defaultComments.filter((comment) => comment.deleted && !defaultComments.some((c) => c.replyTo === comment.id)).map((comment) => comment.id)) ?? [], [defaultComments]), displayedComments = useMemo(
|
|
18
18
|
() => {
|
|
19
19
|
var _a2;
|
|
20
|
-
const
|
|
21
|
-
return type === "edit" ?
|
|
20
|
+
const result = ((_a2 = defaultComments == null ? void 0 : defaultComments.filter((comment) => !comment.replyTo && !idsOfDeletedCommentWithNoReply.includes(comment.id))) == null ? void 0 : _a2.sort((a, b) => b.createdAt - a.createdAt)) ?? [];
|
|
21
|
+
return type === "edit" ? result.slice(0, commentLimit) ?? [] : result;
|
|
22
22
|
},
|
|
23
23
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
24
|
[commentLimit, defaultComments]
|
|
25
|
-
),
|
|
26
|
-
number:
|
|
25
|
+
), showMoreComments = (displayedComments == null ? void 0 : displayedComments.length) < (((_a = defaultComments == null ? void 0 : defaultComments.filter((comment) => !comment.replyTo && !idsOfDeletedCommentWithNoReply.includes(comment.id))) == null ? void 0 : _a.length) ?? 0), titleCommentsCount = ((_b = defaultComments == null ? void 0 : defaultComments.filter((comment) => !comment.deleted)) == null ? void 0 : _b.length) ?? 0, title = titleCommentsCount > 1 ? t("comment.several", {
|
|
26
|
+
number: titleCommentsCount
|
|
27
27
|
}) : t("comment.little", {
|
|
28
|
-
number:
|
|
28
|
+
number: titleCommentsCount
|
|
29
29
|
});
|
|
30
30
|
return {
|
|
31
|
+
t,
|
|
31
32
|
profilesQueries,
|
|
32
33
|
title,
|
|
33
34
|
user,
|
|
34
35
|
emptyscreenPath: illuPad,
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
displayedComments,
|
|
37
|
+
showMoreComments,
|
|
37
38
|
editCommentId,
|
|
38
39
|
setEditCommentId,
|
|
39
40
|
replyToCommentId,
|
|
40
41
|
setReplyToCommentId,
|
|
41
|
-
limitedSortedParentCommentsCount,
|
|
42
|
-
t,
|
|
43
42
|
handleMoreComments: () => {
|
|
44
|
-
const
|
|
45
|
-
newLimit !==
|
|
43
|
+
const newLimit = displayedComments.length + (options.additionalComments ?? 5);
|
|
44
|
+
newLimit !== displayedComments.length && setCommentLimit(newLimit);
|
|
46
45
|
},
|
|
47
46
|
handleDeleteComment: (id) => {
|
|
48
47
|
type === "edit" && (callbacks == null || callbacks.delete(id));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const useCommentsContext: () => {
|
|
2
|
-
|
|
2
|
+
displayedComments: import('../types').CommentProps[] | undefined;
|
|
3
3
|
defaultComments: import('../types').CommentProps[] | undefined;
|
|
4
4
|
editCommentId: string | null;
|
|
5
5
|
replyToCommentId: string | null;
|
|
@@ -28,13 +28,12 @@ const CommentProvider = ({
|
|
|
28
28
|
title,
|
|
29
29
|
user,
|
|
30
30
|
emptyscreenPath,
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
displayedComments,
|
|
32
|
+
showMoreComments,
|
|
33
33
|
editCommentId,
|
|
34
34
|
setEditCommentId,
|
|
35
35
|
replyToCommentId,
|
|
36
36
|
setReplyToCommentId,
|
|
37
|
-
limitedSortedParentCommentsCount,
|
|
38
37
|
t,
|
|
39
38
|
handleMoreComments,
|
|
40
39
|
handleDeleteComment,
|
|
@@ -50,7 +49,7 @@ const CommentProvider = ({
|
|
|
50
49
|
options
|
|
51
50
|
}), userRights = type === "edit" ? props.rights : void 0, values = useMemo(
|
|
52
51
|
() => ({
|
|
53
|
-
|
|
52
|
+
displayedComments,
|
|
54
53
|
defaultComments,
|
|
55
54
|
profiles: profilesQueries.data,
|
|
56
55
|
editCommentId,
|
|
@@ -68,7 +67,7 @@ const CommentProvider = ({
|
|
|
68
67
|
handleReset
|
|
69
68
|
}),
|
|
70
69
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
71
|
-
[
|
|
70
|
+
[displayedComments, editCommentId, profilesQueries, options]
|
|
72
71
|
);
|
|
73
72
|
return /* @__PURE__ */ jsx(CommentContext.Provider, { value: values, children: /* @__PURE__ */ jsxs("div", { className: "my-24", children: [
|
|
74
73
|
/* @__PURE__ */ jsx(CommentHeader, { title }),
|
|
@@ -76,10 +75,10 @@ const CommentProvider = ({
|
|
|
76
75
|
user && /* @__PURE__ */ jsx(CommentForm, { userId: user.userId }),
|
|
77
76
|
profilesQueries.isLoading ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
78
77
|
/* @__PURE__ */ jsx(CommentList, {}),
|
|
79
|
-
|
|
78
|
+
showMoreComments && /* @__PURE__ */ jsx(Button, { variant: "ghost", color: "tertiary", onClick: handleMoreComments, className: "my-16", children: t("comment.more") })
|
|
80
79
|
] })
|
|
81
80
|
] }),
|
|
82
|
-
!
|
|
81
|
+
!displayedComments.length && type === "edit" && /* @__PURE__ */ jsxs("div", { className: "comments-emptyscreen", children: [
|
|
83
82
|
/* @__PURE__ */ jsx("div", { className: "comments-emptyscreen-wrapper", children: /* @__PURE__ */ jsx(EmptyScreen, { imageSrc: emptyscreenPath, size: 150 }) }),
|
|
84
83
|
/* @__PURE__ */ jsx("p", { children: t("comment.emptyscreen") })
|
|
85
84
|
] })
|
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.20250320195838",
|
|
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.20250320195838",
|
|
122
|
+
"@edifice.io/tiptap-extensions": "2.1.2-develop-pedago.20250320195838",
|
|
123
|
+
"@edifice.io/utilities": "2.1.2-develop-pedago.20250320195838"
|
|
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/
|
|
155
|
-
"@edifice.io/
|
|
154
|
+
"@edifice.io/client": "2.1.2-develop-pedago.20250320195838",
|
|
155
|
+
"@edifice.io/config": "2.1.2-develop-pedago.20250320195838"
|
|
156
156
|
},
|
|
157
157
|
"peerDependencies": {
|
|
158
158
|
"@react-spring/web": "^9.7.5",
|