@focus-reactive/payload-plugin-comments 1.1.1 → 1.3.0
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/api/mutations/useAddCommentMutation.d.ts +18 -0
- package/dist/api/mutations/useAddCommentMutation.d.ts.map +1 -0
- package/dist/api/mutations/useAddCommentMutation.js +52 -0
- package/dist/api/mutations/useAddCommentMutation.js.map +1 -0
- package/dist/api/mutations/useDeleteCommentMutation.d.ts +11 -0
- package/dist/api/mutations/useDeleteCommentMutation.d.ts.map +1 -0
- package/dist/api/mutations/useDeleteCommentMutation.js +31 -0
- package/dist/api/mutations/useDeleteCommentMutation.js.map +1 -0
- package/dist/api/mutations/useResolveCommentMutation.d.ts +13 -0
- package/dist/api/mutations/useResolveCommentMutation.d.ts.map +1 -0
- package/dist/api/mutations/useResolveCommentMutation.js +41 -0
- package/dist/api/mutations/useResolveCommentMutation.js.map +1 -0
- package/dist/api/queries/useCommentsQuery.d.ts +3 -0
- package/dist/api/queries/useCommentsQuery.d.ts.map +1 -0
- package/dist/api/queries/useCommentsQuery.js +40 -0
- package/dist/api/queries/useCommentsQuery.js.map +1 -0
- package/dist/api/queries/useDocumentTitlesQuery.d.ts +3 -0
- package/dist/api/queries/useDocumentTitlesQuery.d.ts.map +1 -0
- package/dist/api/queries/useDocumentTitlesQuery.js +32 -0
- package/dist/api/queries/useDocumentTitlesQuery.js.map +1 -0
- package/dist/api/queries/useFieldLabelsQuery.d.ts +3 -0
- package/dist/api/queries/useFieldLabelsQuery.d.ts.map +1 -0
- package/dist/api/queries/useFieldLabelsQuery.js +23 -0
- package/dist/api/queries/useFieldLabelsQuery.js.map +1 -0
- package/dist/api/queries/useMentionableUsersQuery.d.ts +2 -0
- package/dist/api/queries/useMentionableUsersQuery.d.ts.map +1 -0
- package/dist/api/queries/useMentionableUsersQuery.js +25 -0
- package/dist/api/queries/useMentionableUsersQuery.js.map +1 -0
- package/dist/api/queryKeys.d.ts +23 -0
- package/dist/api/queryKeys.d.ts.map +1 -0
- package/dist/api/queryKeys.js +40 -0
- package/dist/api/queryKeys.js.map +1 -0
- package/dist/components/CommentEditor/index.d.ts.map +1 -1
- package/dist/components/CommentEditor/index.js +5 -3
- package/dist/components/CommentEditor/index.js.map +1 -1
- package/dist/components/CommentItem/StrikethoroughOverlay/clamp.d.ts +2 -0
- package/dist/components/CommentItem/StrikethoroughOverlay/clamp.d.ts.map +1 -0
- package/dist/components/CommentItem/StrikethoroughOverlay/clamp.js +7 -0
- package/dist/components/CommentItem/StrikethoroughOverlay/clamp.js.map +1 -0
- package/dist/components/CommentItem/StrikethoroughOverlay/index.d.ts +8 -0
- package/dist/components/CommentItem/StrikethoroughOverlay/index.d.ts.map +1 -0
- package/dist/components/CommentItem/StrikethoroughOverlay/index.js +24 -0
- package/dist/components/CommentItem/StrikethoroughOverlay/index.js.map +1 -0
- package/dist/components/CommentItem/StrikethoroughOverlay/measureLineRects.d.ts +3 -0
- package/dist/components/CommentItem/StrikethoroughOverlay/measureLineRects.d.ts.map +1 -0
- package/dist/components/CommentItem/StrikethoroughOverlay/measureLineRects.js +29 -0
- package/dist/components/CommentItem/StrikethoroughOverlay/measureLineRects.js.map +1 -0
- package/dist/components/CommentItem/StrikethoroughOverlay/useStrikethroughAnimation.d.ts +7 -0
- package/dist/components/CommentItem/StrikethoroughOverlay/useStrikethroughAnimation.d.ts.map +1 -0
- package/dist/components/CommentItem/StrikethoroughOverlay/useStrikethroughAnimation.js +114 -0
- package/dist/components/CommentItem/StrikethoroughOverlay/useStrikethroughAnimation.js.map +1 -0
- package/dist/components/CommentItem/index.d.ts.map +1 -1
- package/dist/components/CommentItem/index.js +37 -18
- package/dist/components/CommentItem/index.js.map +1 -1
- package/dist/components/CommentsDrawer/components/Header.d.ts.map +1 -1
- package/dist/components/CommentsDrawer/components/Header.js +4 -33
- package/dist/components/CommentsDrawer/components/Header.js.map +1 -1
- package/dist/components/CommentsHeaderButton/index.js +2 -2
- package/dist/components/CommentsHeaderButton/index.js.map +1 -1
- package/dist/components/CommentsPanel/components/CollapsibleGroup.d.ts +8 -2
- package/dist/components/CommentsPanel/components/CollapsibleGroup.d.ts.map +1 -1
- package/dist/components/CommentsPanel/components/CollapsibleGroup.js +8 -3
- package/dist/components/CommentsPanel/components/CollapsibleGroup.js.map +1 -1
- package/dist/components/CommentsPanel/components/DocumentView.d.ts.map +1 -1
- package/dist/components/CommentsPanel/components/DocumentView.js +11 -17
- package/dist/components/CommentsPanel/components/DocumentView.js.map +1 -1
- package/dist/components/CommentsPanel/components/FieldGroupSection.d.ts.map +1 -1
- package/dist/components/CommentsPanel/components/FieldGroupSection.js +46 -22
- package/dist/components/CommentsPanel/components/FieldGroupSection.js.map +1 -1
- package/dist/components/CommentsPanel/components/GlobalDocumentView.d.ts.map +1 -1
- package/dist/components/CommentsPanel/components/GlobalDocumentView.js +3 -9
- package/dist/components/CommentsPanel/components/GlobalDocumentView.js.map +1 -1
- package/dist/components/CommentsPanel/components/GlobalView.d.ts.map +1 -1
- package/dist/components/CommentsPanel/components/GlobalView.js +38 -41
- package/dist/components/CommentsPanel/components/GlobalView.js.map +1 -1
- package/dist/components/CommentsPanel/hooks/useCollapseState.d.ts +1 -1
- package/dist/components/CommentsPanel/hooks/useCollapseState.d.ts.map +1 -1
- package/dist/components/CommentsPanel/hooks/useCollapseState.js +4 -1
- package/dist/components/CommentsPanel/hooks/useCollapseState.js.map +1 -1
- package/dist/components/CommentsPanel/hooks/useScrollToTargetFieldGroup.d.ts.map +1 -1
- package/dist/components/CommentsPanel/hooks/useScrollToTargetFieldGroup.js +6 -7
- package/dist/components/CommentsPanel/hooks/useScrollToTargetFieldGroup.js.map +1 -1
- package/dist/components/CommentsPanel/index.d.ts.map +1 -1
- package/dist/components/CommentsPanel/index.js +14 -11
- package/dist/components/CommentsPanel/index.js.map +1 -1
- package/dist/components/FieldCommentLabel/hooks/useFieldBreadcrumb.d.ts +2 -0
- package/dist/components/FieldCommentLabel/hooks/useFieldBreadcrumb.d.ts.map +1 -0
- package/dist/components/FieldCommentLabel/hooks/useFieldBreadcrumb.js +52 -0
- package/dist/components/FieldCommentLabel/hooks/useFieldBreadcrumb.js.map +1 -0
- package/dist/components/FieldCommentLabel/index.d.ts.map +1 -1
- package/dist/components/FieldCommentLabel/index.js +53 -41
- package/dist/components/FieldCommentLabel/index.js.map +1 -1
- package/dist/components/FieldCommentLabel/utils/exludeComments.js +2 -2
- package/dist/components/FieldCommentLabel/utils/exludeComments.js.map +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +5 -4
- package/dist/constants.js.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +6 -2
- package/dist/plugin.js.map +1 -1
- package/dist/providers/CommentsDrawerProvider/index.d.ts +8 -0
- package/dist/providers/CommentsDrawerProvider/index.d.ts.map +1 -1
- package/dist/providers/CommentsDrawerProvider/index.js +22 -6
- package/dist/providers/CommentsDrawerProvider/index.js.map +1 -1
- package/dist/providers/CommentsProvider/index.d.ts +7 -17
- package/dist/providers/CommentsProvider/index.d.ts.map +1 -1
- package/dist/providers/CommentsProvider/index.js +105 -196
- package/dist/providers/CommentsProvider/index.js.map +1 -1
- package/dist/providers/CommentsProviderWrapper/index.d.ts +1 -1
- package/dist/providers/CommentsProviderWrapper/index.d.ts.map +1 -1
- package/dist/providers/CommentsProviderWrapper/index.js +11 -1
- package/dist/providers/CommentsProviderWrapper/index.js.map +1 -1
- package/dist/services/findAllComments.d.ts +4 -1
- package/dist/services/findAllComments.d.ts.map +1 -1
- package/dist/services/findAllComments.js +36 -10
- package/dist/services/findAllComments.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/translations/en.d.ts.map +1 -1
- package/dist/translations/en.js +3 -7
- package/dist/translations/en.js.map +1 -1
- package/dist/translations/types.d.ts +2 -6
- package/dist/translations/types.d.ts.map +1 -1
- package/dist/types/general.d.ts +0 -2
- package/dist/types/general.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -2
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/query.d.ts +11 -0
- package/dist/types/query.d.ts.map +1 -0
- package/dist/types/query.js +1 -0
- package/dist/types/query.js.map +1 -0
- package/dist/utils/comment/filterCommentsByLocale.d.ts.map +1 -1
- package/dist/utils/comment/filterCommentsByLocale.js +0 -1
- package/dist/utils/comment/filterCommentsByLocale.js.map +1 -1
- package/dist/utils/query/toQueryContext.d.ts +3 -0
- package/dist/utils/query/toQueryContext.d.ts.map +1 -0
- package/dist/utils/query/toQueryContext.js +20 -0
- package/dist/utils/query/toQueryContext.js.map +1 -0
- package/package.json +2 -5
- package/dist/components/CommentsPanel/constants.d.ts +0 -3
- package/dist/components/CommentsPanel/constants.d.ts.map +0 -1
- package/dist/components/CommentsPanel/constants.js +0 -9
- package/dist/components/CommentsPanel/constants.js.map +0 -1
- package/dist/components/CommentsPanel/utils/filterComments.d.ts +0 -9
- package/dist/components/CommentsPanel/utils/filterComments.d.ts.map +0 -1
- package/dist/components/CommentsPanel/utils/filterComments.js +0 -17
- package/dist/components/CommentsPanel/utils/filterComments.js.map +0 -1
- package/dist/components/FieldCommentLabel/AddCommentPopup.d.ts +0 -8
- package/dist/components/FieldCommentLabel/AddCommentPopup.d.ts.map +0 -1
- package/dist/components/FieldCommentLabel/AddCommentPopup.js +0 -50
- package/dist/components/FieldCommentLabel/AddCommentPopup.js.map +0 -1
- package/dist/providers/GlobalCommentsLoader/GlobalCommentsHydrator.d.ts +0 -13
- package/dist/providers/GlobalCommentsLoader/GlobalCommentsHydrator.d.ts.map +0 -1
- package/dist/providers/GlobalCommentsLoader/GlobalCommentsHydrator.js +0 -22
- package/dist/providers/GlobalCommentsLoader/GlobalCommentsHydrator.js.map +0 -1
- package/dist/providers/GlobalCommentsLoader/index.d.ts +0 -10
- package/dist/providers/GlobalCommentsLoader/index.d.ts.map +0 -1
- package/dist/providers/GlobalCommentsLoader/index.js +0 -31
- package/dist/providers/GlobalCommentsLoader/index.js.map +0 -1
- package/dist/services/syncAllCommentsData.d.ts +0 -12
- package/dist/services/syncAllCommentsData.d.ts.map +0 -1
- package/dist/services/syncAllCommentsData.js +0 -48
- package/dist/services/syncAllCommentsData.js.map +0 -1
|
@@ -1,225 +1,134 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
useCallback,
|
|
6
|
-
useContext,
|
|
7
|
-
useOptimistic,
|
|
8
|
-
useState
|
|
9
|
-
} from "react";
|
|
10
|
-
import { useAuth, useLocale } from "@payloadcms/ui";
|
|
3
|
+
import { createContext, useCallback, useContext } from "react";
|
|
4
|
+
import { useAuth, useConfig } from "@payloadcms/ui";
|
|
11
5
|
import { usePathname } from "next/navigation";
|
|
12
|
-
import {
|
|
13
|
-
import { deleteComment } from "../../services/deleteComment";
|
|
14
|
-
import { resolveComment as resolveCommentService } from "../../services/resolveComment";
|
|
15
|
-
import { syncAllCommentsData } from "../../services/syncAllCommentsData";
|
|
16
|
-
import { parseMentionIds } from "../../utils/mention/parseMentionIds";
|
|
6
|
+
import { toQueryContext } from "../../utils/query/toQueryContext";
|
|
17
7
|
import { defineModeByPathname } from "../../utils/mode/defineModeByPathname";
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return state.filter(({ id }) => id !== action.id);
|
|
25
|
-
case "update":
|
|
26
|
-
return state.map((c) => c.id === action.comment.id ? action.comment : c);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
8
|
+
import { getEntitiesLabels } from "../../services/getEntitiesLabels";
|
|
9
|
+
import { parseMentionIds } from "../../utils/mention/parseMentionIds";
|
|
10
|
+
import { getDefaultErrorMessage } from "../../utils/error/getDefaultErrorMessage";
|
|
11
|
+
import { useAddCommentMutation } from "../../api/mutations/useAddCommentMutation";
|
|
12
|
+
import { useDeleteCommentMutation } from "../../api/mutations/useDeleteCommentMutation";
|
|
13
|
+
import { useResolveCommentMutation } from "../../api/mutations/useResolveCommentMutation";
|
|
29
14
|
const CommentsContext = createContext(null);
|
|
30
15
|
function CommentsProvider({ children, usernameFieldPath }) {
|
|
31
16
|
const { user } = useAuth();
|
|
32
17
|
const pathname = usePathname();
|
|
33
|
-
const {
|
|
34
|
-
const [allComments, setAllComments] = useState([]);
|
|
35
|
-
const [optimisticComments, applyOptimistic] = useOptimistic(
|
|
36
|
-
allComments,
|
|
37
|
-
optimisticReducer
|
|
38
|
-
);
|
|
39
|
-
const [documentTitles, setDocumentTitles] = useState({});
|
|
40
|
-
const [collectionLabels, setCollectionLabels] = useState({});
|
|
41
|
-
const [globalLabels, setGlobalLabels] = useState({});
|
|
42
|
-
const [mentionUsers, setMentionUsers] = useState([]);
|
|
43
|
-
const [fieldLabelRegistry, setFieldLabelRegistry] = useState({});
|
|
44
|
-
const [filter, setFilter] = useState("open");
|
|
45
|
-
const [loadError, setLoadError] = useState(false);
|
|
46
|
-
const [syncCommentsStatus, setSyncCommentsStatus] = useState("idle");
|
|
18
|
+
const { config } = useConfig();
|
|
47
19
|
const { mode, collectionSlug, documentId, globalSlug } = defineModeByPathname(pathname);
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
20
|
+
const queryContext = toQueryContext(mode, collectionSlug, documentId, globalSlug);
|
|
21
|
+
const pluginConfig = config.admin?.custom?.commentsPlugin;
|
|
22
|
+
const collectionLabels = getEntitiesLabels(
|
|
23
|
+
config.collections ?? [],
|
|
24
|
+
pluginConfig?.collections ?? []
|
|
25
|
+
);
|
|
26
|
+
const globalLabels = getEntitiesLabels(
|
|
27
|
+
config.globals ?? [],
|
|
28
|
+
pluginConfig?.globals ?? []
|
|
29
|
+
);
|
|
30
|
+
const addMutation = useAddCommentMutation();
|
|
31
|
+
const deleteMutation = useDeleteCommentMutation();
|
|
32
|
+
const resolveMutation = useResolveCommentMutation();
|
|
33
|
+
const addComment = useCallback(
|
|
34
|
+
async (text, fieldPath, documentIdOverride, collectionSlugOverride, locale, globalSlugOverride) => {
|
|
35
|
+
const resolvedGlobalSlug = globalSlugOverride ?? (mode === "global-document" ? globalSlug : null);
|
|
36
|
+
const resolvedDocId = documentIdOverride ?? documentId;
|
|
37
|
+
const resolvedSlug = collectionSlugOverride ?? collectionSlug;
|
|
38
|
+
if (!resolvedGlobalSlug && (!resolvedDocId || !resolvedSlug)) {
|
|
39
|
+
return {
|
|
40
|
+
success: false,
|
|
41
|
+
error: "No document registered"
|
|
42
|
+
};
|
|
69
43
|
}
|
|
70
|
-
|
|
71
|
-
|
|
44
|
+
try {
|
|
45
|
+
const res = await addMutation.mutateAsync({
|
|
46
|
+
ctx: queryContext,
|
|
47
|
+
text,
|
|
48
|
+
fieldPath: fieldPath ?? null,
|
|
49
|
+
documentId: resolvedGlobalSlug ? null : resolvedDocId,
|
|
50
|
+
collectionSlug: resolvedGlobalSlug ? null : resolvedSlug,
|
|
51
|
+
globalSlug: resolvedGlobalSlug ?? null,
|
|
52
|
+
locale: locale ?? null,
|
|
53
|
+
mentionIds: parseMentionIds(text),
|
|
54
|
+
currentUser: user
|
|
55
|
+
});
|
|
56
|
+
if (!res.success)
|
|
57
|
+
return {
|
|
58
|
+
success: false,
|
|
59
|
+
error: res.error
|
|
60
|
+
};
|
|
61
|
+
return { success: true };
|
|
62
|
+
} catch (e) {
|
|
63
|
+
return {
|
|
64
|
+
success: false,
|
|
65
|
+
error: getDefaultErrorMessage(e)
|
|
66
|
+
};
|
|
72
67
|
}
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
},
|
|
69
|
+
[addMutation, mode, globalSlug, documentId, collectionSlug, queryContext, user]
|
|
70
|
+
);
|
|
71
|
+
const removeComment = useCallback(
|
|
72
|
+
async (id) => {
|
|
73
|
+
try {
|
|
74
|
+
const res = await deleteMutation.mutateAsync({
|
|
75
|
+
ctx: queryContext,
|
|
76
|
+
commentId: id
|
|
77
|
+
});
|
|
78
|
+
if (!res.success)
|
|
79
|
+
return {
|
|
80
|
+
success: false,
|
|
81
|
+
error: res.error
|
|
82
|
+
};
|
|
83
|
+
return { success: true };
|
|
84
|
+
} catch (e) {
|
|
85
|
+
return {
|
|
86
|
+
success: false,
|
|
87
|
+
error: getDefaultErrorMessage(e)
|
|
88
|
+
};
|
|
75
89
|
}
|
|
76
|
-
setLoadError(nextLoadError);
|
|
77
90
|
},
|
|
78
|
-
[]
|
|
91
|
+
[deleteMutation, queryContext]
|
|
79
92
|
);
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
collectionSlug: resolvedGlobalSlug ? null : resolvedSlug,
|
|
101
|
-
globalSlug: resolvedGlobalSlug ?? null,
|
|
102
|
-
isResolved: false,
|
|
103
|
-
mentions,
|
|
104
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
105
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
106
|
-
author: user
|
|
107
|
-
};
|
|
108
|
-
applyOptimistic({ type: "add", comment: optimisticComment });
|
|
109
|
-
const result = await createComment({
|
|
110
|
-
documentId: resolvedGlobalSlug ? null : resolvedDocId,
|
|
111
|
-
collectionSlug: resolvedGlobalSlug ? null : resolvedSlug,
|
|
112
|
-
globalSlug: resolvedGlobalSlug,
|
|
113
|
-
text,
|
|
114
|
-
fieldPath,
|
|
115
|
-
mentionIds,
|
|
116
|
-
locale
|
|
117
|
-
});
|
|
118
|
-
if (result.success) {
|
|
119
|
-
applyOptimistic({ type: "remove", id: tempId });
|
|
120
|
-
setAllComments((prev) => [result.data, ...prev.filter((c) => c.id !== tempId)]);
|
|
121
|
-
return { success: true };
|
|
122
|
-
}
|
|
123
|
-
return {
|
|
124
|
-
success: false,
|
|
125
|
-
error: result.error
|
|
126
|
-
};
|
|
127
|
-
};
|
|
128
|
-
const removeComment = async (id) => {
|
|
129
|
-
applyOptimistic({ type: "remove", id });
|
|
130
|
-
const result = await deleteComment(id);
|
|
131
|
-
if (result.success) {
|
|
132
|
-
setAllComments((prev) => prev.filter((c) => c.id !== id));
|
|
133
|
-
return { success: true };
|
|
134
|
-
}
|
|
135
|
-
return {
|
|
136
|
-
success: false,
|
|
137
|
-
error: result.error
|
|
138
|
-
};
|
|
139
|
-
};
|
|
140
|
-
const syncComments = async () => {
|
|
141
|
-
setSyncCommentsStatus("loading");
|
|
142
|
-
const allCommentsDataResult = await syncAllCommentsData({ locale: currentLocale });
|
|
143
|
-
if (!allCommentsDataResult.success) {
|
|
144
|
-
setSyncCommentsStatus("error");
|
|
145
|
-
return;
|
|
146
|
-
}
|
|
147
|
-
const {
|
|
148
|
-
comments,
|
|
149
|
-
documentTitles: documentTitles2,
|
|
150
|
-
mentionUsers: mentionUsers2,
|
|
151
|
-
fieldLabels,
|
|
152
|
-
collectionLabels: syncedLabels,
|
|
153
|
-
globalLabels: syncedGlobalLabels
|
|
154
|
-
} = allCommentsDataResult.data;
|
|
155
|
-
setAllComments((prev) => {
|
|
156
|
-
const serverIds = new Set(comments.map((c) => c.id));
|
|
157
|
-
const localOnly = prev.filter((c) => c.id > 0 && !serverIds.has(c.id));
|
|
158
|
-
return [...localOnly, ...comments];
|
|
159
|
-
});
|
|
160
|
-
setDocumentTitles(documentTitles2);
|
|
161
|
-
setMentionUsers(mentionUsers2);
|
|
162
|
-
setFieldLabelRegistry(fieldLabels);
|
|
163
|
-
setCollectionLabels(syncedLabels);
|
|
164
|
-
setGlobalLabels(syncedGlobalLabels);
|
|
165
|
-
setSyncCommentsStatus("success");
|
|
166
|
-
};
|
|
167
|
-
const resolveComment = async (id, resolved) => {
|
|
168
|
-
const existing = optimisticComments.find((c) => c.id === id);
|
|
169
|
-
if (existing) {
|
|
170
|
-
applyOptimistic({
|
|
171
|
-
type: "update",
|
|
172
|
-
comment: {
|
|
173
|
-
...existing,
|
|
174
|
-
isResolved: resolved
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
const result = await resolveCommentService(id, resolved);
|
|
179
|
-
if (result.success) {
|
|
180
|
-
setAllComments((prev) => prev.map((c) => c.id === id ? result.data : c));
|
|
181
|
-
return { success: true };
|
|
182
|
-
}
|
|
183
|
-
return {
|
|
184
|
-
success: false,
|
|
185
|
-
error: result.error
|
|
186
|
-
};
|
|
187
|
-
};
|
|
188
|
-
const updateDocumentTitle = (collectionSlug2, documentId2, value) => {
|
|
189
|
-
setDocumentTitles((prev) => ({
|
|
190
|
-
...prev,
|
|
191
|
-
[collectionSlug2]: {
|
|
192
|
-
...prev[collectionSlug2],
|
|
193
|
-
[documentId2]: value
|
|
93
|
+
const resolveComment = useCallback(
|
|
94
|
+
async (id, resolved) => {
|
|
95
|
+
try {
|
|
96
|
+
const res = await resolveMutation.mutateAsync({
|
|
97
|
+
ctx: queryContext,
|
|
98
|
+
commentId: id,
|
|
99
|
+
resolved,
|
|
100
|
+
currentUser: user
|
|
101
|
+
});
|
|
102
|
+
if (!res.success)
|
|
103
|
+
return {
|
|
104
|
+
success: false,
|
|
105
|
+
error: res.error
|
|
106
|
+
};
|
|
107
|
+
return { success: true };
|
|
108
|
+
} catch (e) {
|
|
109
|
+
return {
|
|
110
|
+
success: false,
|
|
111
|
+
error: getDefaultErrorMessage(e)
|
|
112
|
+
};
|
|
194
113
|
}
|
|
195
|
-
}
|
|
196
|
-
|
|
114
|
+
},
|
|
115
|
+
[resolveMutation, queryContext, user]
|
|
116
|
+
);
|
|
197
117
|
return /* @__PURE__ */ jsx(
|
|
198
118
|
CommentsContext.Provider,
|
|
199
119
|
{
|
|
200
120
|
value: {
|
|
201
|
-
allComments: optimisticComments,
|
|
202
|
-
visibleComments,
|
|
203
|
-
documentTitles,
|
|
204
|
-
collectionLabels,
|
|
205
|
-
globalLabels,
|
|
206
121
|
mode,
|
|
207
122
|
collectionSlug,
|
|
208
123
|
documentId,
|
|
209
124
|
globalSlug,
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
fieldLabelRegistry,
|
|
214
|
-
syncCommentsStatus,
|
|
125
|
+
queryContext,
|
|
126
|
+
collectionLabels,
|
|
127
|
+
globalLabels,
|
|
215
128
|
usernameFieldPath,
|
|
216
|
-
setFilter,
|
|
217
|
-
hydrateComments,
|
|
218
|
-
syncComments,
|
|
219
129
|
addComment,
|
|
220
130
|
removeComment,
|
|
221
|
-
resolveComment
|
|
222
|
-
updateDocumentTitle
|
|
131
|
+
resolveComment
|
|
223
132
|
},
|
|
224
133
|
children
|
|
225
134
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/providers/CommentsProvider/index.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n createContext,\n type Dispatch,\n type ReactNode,\n type SetStateAction,\n useCallback,\n useContext,\n useOptimistic,\n useState,\n} from \"react\";\nimport { useAuth, useLocale } from \"@payloadcms/ui\";\nimport { usePathname } from \"next/navigation\";\nimport type { Comment, EntityLabelsMap, User } from \"../../types\";\nimport { createComment } from \"../../services/createComment\";\nimport { deleteComment } from \"../../services/deleteComment\";\nimport { resolveComment as resolveCommentService } from \"../../services/resolveComment\";\nimport { syncAllCommentsData } from \"../../services/syncAllCommentsData\";\nimport type { FilterMode, GlobalFieldLabelRegistry, LoadingStatus, DocumentTitles, Mode } from \"../../types\";\nimport { parseMentionIds } from \"../../utils/mention/parseMentionIds\";\nimport { defineModeByPathname } from \"../../utils/mode/defineModeByPathname\";\nimport { extractVisibleComments } from \"../../utils/comment/extractVisibleComments\";\n\ntype OptimisticAction =\n | { type: \"add\"; comment: Comment }\n | { type: \"remove\"; id: string | number }\n | { type: \"update\"; comment: Comment };\n\nfunction optimisticReducer(state: Comment[], action: OptimisticAction) {\n switch (action.type) {\n case \"add\":\n return [action.comment, ...state];\n case \"remove\":\n return state.filter(({ id }) => id !== action.id);\n case \"update\":\n return state.map((c) => (c.id === action.comment.id ? action.comment : c));\n }\n}\n\ninterface MutationResult {\n success: boolean;\n error?: string;\n}\n\ninterface CommentsContextProps {\n allComments: Comment[];\n visibleComments: Comment[];\n documentTitles: DocumentTitles;\n collectionLabels: EntityLabelsMap;\n globalLabels: EntityLabelsMap;\n mode: Mode;\n collectionSlug: string | null | undefined;\n documentId: number | null | undefined;\n globalSlug: string | null;\n mentionUsers: User[];\n loadError: boolean;\n filter: FilterMode;\n fieldLabelRegistry: GlobalFieldLabelRegistry;\n syncCommentsStatus: LoadingStatus;\n usernameFieldPath: string | undefined;\n setFilter: Dispatch<SetStateAction<FilterMode>>;\n hydrateComments: (\n incoming?: Comment[],\n incomingTitles?: DocumentTitles,\n incomingMentionUsers?: User[],\n fieldLabels?: GlobalFieldLabelRegistry,\n incomingCollectionLabels?: EntityLabelsMap,\n nextLoadError?: boolean,\n incomingGlobalLabels?: EntityLabelsMap,\n ) => void;\n syncComments: () => Promise<void>;\n addComment: (\n text: string,\n fieldPath?: string | null,\n documentId?: number,\n collectionSlug?: string,\n locale?: string | null,\n globalSlugOverride?: string,\n ) => Promise<MutationResult>;\n removeComment: (id: string | number) => Promise<MutationResult>;\n resolveComment: (id: string | number, resolved: boolean) => Promise<MutationResult>;\n updateDocumentTitle: (collectionSlug: string, documentId: string, value: string) => void;\n}\n\nconst CommentsContext = createContext<CommentsContextProps | null>(null);\n\ninterface Props {\n children: ReactNode;\n usernameFieldPath?: string;\n}\n\nexport function CommentsProvider({ children, usernameFieldPath }: Props) {\n const { user } = useAuth();\n const pathname = usePathname();\n const { code: currentLocale } = useLocale();\n\n const [allComments, setAllComments] = useState<Comment[]>([]);\n const [optimisticComments, applyOptimistic] = useOptimistic<Comment[], OptimisticAction>(\n allComments,\n optimisticReducer,\n );\n\n const [documentTitles, setDocumentTitles] = useState<DocumentTitles>({});\n const [collectionLabels, setCollectionLabels] = useState<EntityLabelsMap>({});\n const [globalLabels, setGlobalLabels] = useState<EntityLabelsMap>({});\n const [mentionUsers, setMentionUsers] = useState<User[]>([]);\n const [fieldLabelRegistry, setFieldLabelRegistry] = useState<GlobalFieldLabelRegistry>({});\n const [filter, setFilter] = useState<FilterMode>(\"open\");\n const [loadError, setLoadError] = useState(false);\n const [syncCommentsStatus, setSyncCommentsStatus] = useState<LoadingStatus>(\"idle\");\n\n const { mode, collectionSlug, documentId, globalSlug } = defineModeByPathname(pathname);\n\n const visibleComments = extractVisibleComments({\n comments: optimisticComments,\n mode,\n collectionSlug,\n documentId,\n globalSlug,\n currentLocale,\n });\n\n const hydrateComments = useCallback(\n (\n incoming?: Comment[],\n incomingTitles?: DocumentTitles,\n incomingMentionUsers?: User[],\n fieldLabels?: GlobalFieldLabelRegistry,\n incomingCollectionLabels?: EntityLabelsMap,\n nextLoadError = false,\n incomingGlobalLabels?: EntityLabelsMap,\n ) => {\n if (incoming !== undefined) {\n setAllComments(incoming);\n }\n\n if (incomingTitles) {\n setDocumentTitles(incomingTitles);\n }\n\n if (incomingMentionUsers) {\n setMentionUsers(incomingMentionUsers);\n }\n\n if (fieldLabels) {\n setFieldLabelRegistry(fieldLabels);\n }\n\n if (incomingCollectionLabels) {\n setCollectionLabels(incomingCollectionLabels);\n }\n\n if (incomingGlobalLabels) {\n setGlobalLabels(incomingGlobalLabels);\n }\n\n setLoadError(nextLoadError);\n },\n [],\n );\n\n const addComment = async (\n text: string,\n fieldPath?: string | null,\n documentIdOverride?: number,\n collectionSlugOverride?: string,\n locale?: string | null,\n globalSlugOverride?: string,\n ): Promise<MutationResult> => {\n const resolvedGlobalSlug = globalSlugOverride ?? (mode === \"global-document\" ? globalSlug : null);\n const resolvedDocId = documentIdOverride ?? documentId;\n const resolvedSlug = collectionSlugOverride ?? collectionSlug;\n\n if (!resolvedGlobalSlug && (!resolvedDocId || !resolvedSlug)) {\n return {\n success: false,\n error: \"No document registered\",\n };\n }\n\n const tempId = -Date.now();\n\n const mentionIds = parseMentionIds(text);\n const selectedMentionUsers = mentionUsers.filter(({ id }) => mentionIds.includes(id));\n const mentions = selectedMentionUsers.map((user) => ({ id: null, user }));\n\n const optimisticComment: Comment = {\n id: tempId,\n text,\n fieldPath,\n locale: locale ?? null,\n documentId: resolvedGlobalSlug ? null : resolvedDocId,\n collectionSlug: resolvedGlobalSlug ? null : resolvedSlug,\n globalSlug: resolvedGlobalSlug ?? null,\n isResolved: false,\n mentions,\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n author: user as Comment[\"author\"],\n };\n\n applyOptimistic({ type: \"add\", comment: optimisticComment });\n\n const result = await createComment({\n documentId: resolvedGlobalSlug ? null : resolvedDocId,\n collectionSlug: resolvedGlobalSlug ? null : resolvedSlug,\n globalSlug: resolvedGlobalSlug,\n text,\n fieldPath,\n mentionIds,\n locale,\n });\n\n if (result.success) {\n applyOptimistic({ type: \"remove\", id: tempId });\n setAllComments((prev) => [result.data, ...prev.filter((c) => c.id !== tempId)]);\n\n return { success: true };\n }\n\n return {\n success: false,\n error: result.error,\n };\n };\n\n const removeComment = async (id: string | number): Promise<MutationResult> => {\n applyOptimistic({ type: \"remove\", id });\n\n const result = await deleteComment(id);\n\n if (result.success) {\n setAllComments((prev) => prev.filter((c) => c.id !== id));\n\n return { success: true };\n }\n\n return {\n success: false,\n error: result.error,\n };\n };\n\n const syncComments = async () => {\n setSyncCommentsStatus(\"loading\");\n\n const allCommentsDataResult = await syncAllCommentsData({ locale: currentLocale });\n\n if (!allCommentsDataResult.success) {\n setSyncCommentsStatus(\"error\");\n\n return;\n }\n\n const {\n comments,\n documentTitles,\n mentionUsers,\n fieldLabels,\n collectionLabels: syncedLabels,\n globalLabels: syncedGlobalLabels,\n } = allCommentsDataResult.data;\n\n setAllComments((prev) => {\n const serverIds = new Set(comments.map((c) => c.id));\n const localOnly = prev.filter((c) => c.id > 0 && !serverIds.has(c.id));\n\n return [...localOnly, ...comments];\n });\n setDocumentTitles(documentTitles);\n setMentionUsers(mentionUsers);\n setFieldLabelRegistry(fieldLabels);\n setCollectionLabels(syncedLabels);\n setGlobalLabels(syncedGlobalLabels);\n setSyncCommentsStatus(\"success\");\n };\n\n const resolveComment = async (id: string | number, resolved: boolean): Promise<MutationResult> => {\n const existing = optimisticComments.find((c) => c.id === id);\n\n if (existing) {\n applyOptimistic({\n type: \"update\",\n comment: {\n ...existing,\n isResolved: resolved,\n },\n });\n }\n\n const result = await resolveCommentService(id, resolved);\n\n if (result.success) {\n setAllComments((prev) => prev.map((c) => (c.id === id ? result.data : c)));\n\n return { success: true };\n }\n\n return {\n success: false,\n error: result.error,\n };\n };\n\n const updateDocumentTitle = (collectionSlug: string, documentId: string, value: string) => {\n setDocumentTitles((prev) => ({\n ...prev,\n [collectionSlug]: {\n ...prev[collectionSlug],\n [documentId]: value,\n },\n }));\n };\n\n return (\n <CommentsContext.Provider\n value={{\n allComments: optimisticComments,\n visibleComments,\n documentTitles,\n collectionLabels,\n globalLabels,\n mode,\n collectionSlug,\n documentId,\n globalSlug,\n mentionUsers,\n loadError,\n filter,\n fieldLabelRegistry,\n syncCommentsStatus,\n usernameFieldPath,\n setFilter,\n hydrateComments,\n syncComments,\n addComment,\n removeComment,\n resolveComment,\n updateDocumentTitle,\n }}>\n {children}\n </CommentsContext.Provider>\n );\n}\n\nexport function useComments() {\n const context = useContext(CommentsContext);\n\n if (!context) throw new Error(\"useComments must be used within a CommentsProvider\");\n\n return context;\n}\n"],"mappings":";AA4TI;AA1TJ;AAAA,EACE;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;A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AoB,UAAkB;AACzF,sBAAkB,CAAC,UAAU;AAAA,MAC3B,GAAG;AAAA,MACH,CAACD,eAAc,GAAG;AAAA,QAChB,GAAG,KAAKA,eAAc;AAAA,QACtB,CAACC,WAAU,GAAG;AAAA,MAChB;AAAA,IACF,EAAE;AAAA,EACJ;AAEA,SACE;AAAA,IAAC,gBAAgB;AAAA,IAAhB;AAAA,MACC,OAAO;AAAA,QACL,aAAa;AAAA,QACb;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACC;AAAA;AAAA,EACH;AAEJ;AAEO,SAAS,cAAc;AAC5B,QAAM,UAAU,WAAW,eAAe;AAE1C,MAAI,CAAC,QAAS,OAAM,IAAI,MAAM,oDAAoD;AAElF,SAAO;AACT;","names":["user","documentTitles","mentionUsers","collectionSlug","documentId"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/providers/CommentsProvider/index.tsx"],"sourcesContent":["\"use client\";\n\nimport { createContext, type ReactNode, useCallback, useContext } from \"react\";\nimport { useAuth, useConfig } from \"@payloadcms/ui\";\nimport { usePathname } from \"next/navigation\";\nimport type { EntityLabelsMap, Comment, CommentsPluginConfigStorage } from \"../../types\";\nimport type { QueryContext } from \"../../types\";\nimport { toQueryContext } from \"../../utils/query/toQueryContext\";\nimport { defineModeByPathname } from \"../../utils/mode/defineModeByPathname\";\nimport { getEntitiesLabels } from \"../../services/getEntitiesLabels\";\nimport type { EntityConfig } from \"../../types\";\nimport { parseMentionIds } from \"../../utils/mention/parseMentionIds\";\nimport { getDefaultErrorMessage } from \"../../utils/error/getDefaultErrorMessage\";\nimport { useAddCommentMutation } from \"../../api/mutations/useAddCommentMutation\";\nimport { useDeleteCommentMutation } from \"../../api/mutations/useDeleteCommentMutation\";\nimport { useResolveCommentMutation } from \"../../api/mutations/useResolveCommentMutation\";\nimport type { Mode } from \"../../types\";\n\ninterface MutationResult {\n success: boolean;\n error?: string;\n}\n\ninterface CommentsContextProps {\n mode: Mode;\n collectionSlug: string | null | undefined;\n documentId: number | null | undefined;\n globalSlug: string | null;\n queryContext: QueryContext;\n collectionLabels: EntityLabelsMap;\n globalLabels: EntityLabelsMap;\n usernameFieldPath: string | undefined;\n addComment: (\n text: string,\n fieldPath?: string | null,\n documentId?: number,\n collectionSlug?: string,\n locale?: string | null,\n globalSlugOverride?: string,\n ) => Promise<MutationResult>;\n removeComment: (id: string | number) => Promise<MutationResult>;\n resolveComment: (id: string | number, resolved: boolean) => Promise<MutationResult>;\n}\n\nconst CommentsContext = createContext<CommentsContextProps | null>(null);\n\ninterface Props {\n children: ReactNode;\n usernameFieldPath?: string;\n}\n\nexport function CommentsProvider({ children, usernameFieldPath }: Props) {\n const { user } = useAuth();\n const pathname = usePathname();\n const { config } = useConfig();\n\n const { mode, collectionSlug, documentId, globalSlug } = defineModeByPathname(pathname);\n const queryContext = toQueryContext(mode, collectionSlug, documentId, globalSlug);\n\n const pluginConfig = config.admin?.custom?.commentsPlugin as CommentsPluginConfigStorage | undefined;\n const collectionLabels = getEntitiesLabels(\n (config.collections ?? []) as unknown as EntityConfig[],\n pluginConfig?.collections ?? [],\n );\n const globalLabels = getEntitiesLabels(\n (config.globals ?? []) as unknown as EntityConfig[],\n pluginConfig?.globals ?? [],\n );\n\n const addMutation = useAddCommentMutation();\n const deleteMutation = useDeleteCommentMutation();\n const resolveMutation = useResolveCommentMutation();\n\n const addComment = useCallback(\n async (\n text: string,\n fieldPath?: string | null,\n documentIdOverride?: number,\n collectionSlugOverride?: string,\n locale?: string | null,\n globalSlugOverride?: string,\n ): Promise<MutationResult> => {\n const resolvedGlobalSlug = globalSlugOverride ?? (mode === \"global-document\" ? globalSlug : null);\n const resolvedDocId = documentIdOverride ?? documentId;\n const resolvedSlug = collectionSlugOverride ?? collectionSlug;\n\n if (!resolvedGlobalSlug && (!resolvedDocId || !resolvedSlug)) {\n return {\n success: false,\n error: \"No document registered\",\n };\n }\n\n try {\n const res = await addMutation.mutateAsync({\n ctx: queryContext,\n text,\n fieldPath: fieldPath ?? null,\n documentId: resolvedGlobalSlug ? null : resolvedDocId,\n collectionSlug: resolvedGlobalSlug ? null : resolvedSlug,\n globalSlug: resolvedGlobalSlug ?? null,\n locale: locale ?? null,\n mentionIds: parseMentionIds(text),\n currentUser: user as Comment[\"author\"],\n });\n\n if (!res.success)\n return {\n success: false,\n error: res.error,\n };\n\n return { success: true };\n } catch (e) {\n return {\n success: false,\n error: getDefaultErrorMessage(e),\n };\n }\n },\n [addMutation, mode, globalSlug, documentId, collectionSlug, queryContext, user],\n );\n\n const removeComment = useCallback(\n async (id: string | number): Promise<MutationResult> => {\n try {\n const res = await deleteMutation.mutateAsync({\n ctx: queryContext,\n commentId: id,\n });\n\n if (!res.success)\n return {\n success: false,\n error: res.error,\n };\n\n return { success: true };\n } catch (e) {\n return {\n success: false,\n error: getDefaultErrorMessage(e),\n };\n }\n },\n [deleteMutation, queryContext],\n );\n\n const resolveComment = useCallback(\n async (id: string | number, resolved: boolean): Promise<MutationResult> => {\n try {\n const res = await resolveMutation.mutateAsync({\n ctx: queryContext,\n commentId: id,\n resolved,\n currentUser: user as Comment[\"author\"],\n });\n\n if (!res.success)\n return {\n success: false,\n error: res.error,\n };\n\n return { success: true };\n } catch (e) {\n return {\n success: false,\n error: getDefaultErrorMessage(e),\n };\n }\n },\n [resolveMutation, queryContext, user],\n );\n\n return (\n <CommentsContext.Provider\n value={{\n mode,\n collectionSlug,\n documentId,\n globalSlug,\n queryContext,\n collectionLabels,\n globalLabels,\n usernameFieldPath,\n addComment,\n removeComment,\n resolveComment,\n }}>\n {children}\n </CommentsContext.Provider>\n );\n}\n\nexport function useComments() {\n const context = useContext(CommentsContext);\n\n if (!context) throw new Error(\"useCom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ACT,OAAO,IAAI;AAAA,UACb;AAEF,eAAO,EAAE,SAAS,KAAK;AAAA,MACzB,SAAS,GAAG;AACV,eAAO;AAAA,UACL,SAAS;AAAA,UACT,OAAO,uBAAuB,CAAC;AAAA,QACjC;AAAA,MACF;AAAA,IACF;AAAA,IACA,CAAC,iBAAiB,cAAc,IAAI;AAAA,EACtC;AAEA,SACE;AAAA,IAAC,gBAAgB;AAAA,IAAhB;AAAA,MACC,OAAO;AAAA,QACL;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,MACC;AAAA;AAAA,EACH;AAEJ;AAEO,SAAS,cAAc;AAC5B,QAAM,UAAU,WAAW,eAAe;AAE1C,MAAI,CAAC,QAAS,OAAM,IAAI,MAAM,oDAAoD;AAElF,SAAO;AACT;","names":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/CommentsProviderWrapper/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/CommentsProviderWrapper/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAOjD,UAAU,KAAK;IACb,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,uBAAuB,CAAC,EAAE,QAAQ,EAAE,EAAE,KAAK,2CAuB1D"}
|
|
@@ -1,14 +1,24 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
|
|
3
5
|
import { useConfig } from "@payloadcms/ui";
|
|
4
6
|
import { CommentsDrawerProvider } from "../CommentsDrawerProvider";
|
|
5
7
|
import { CommentsProvider } from "../CommentsProvider";
|
|
6
8
|
function CommentsProviderWrapper({ children }) {
|
|
7
9
|
const { config } = useConfig();
|
|
10
|
+
const [queryClient] = useState(
|
|
11
|
+
() => new QueryClient({
|
|
12
|
+
defaultOptions: {
|
|
13
|
+
queries: { retry: 1 },
|
|
14
|
+
mutations: { retry: 0 }
|
|
15
|
+
}
|
|
16
|
+
})
|
|
17
|
+
);
|
|
8
18
|
const pluginConfig = config.admin?.custom?.commentsPlugin;
|
|
9
19
|
const usernameFieldRawPath = pluginConfig?.usernameFieldPath;
|
|
10
20
|
const usernameFieldPath = usernameFieldRawPath === "" ? void 0 : usernameFieldRawPath;
|
|
11
|
-
return /* @__PURE__ */ jsx(CommentsProvider, { usernameFieldPath, children: /* @__PURE__ */ jsx(CommentsDrawerProvider, { children }) });
|
|
21
|
+
return /* @__PURE__ */ jsx(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsx(CommentsProvider, { usernameFieldPath, children: /* @__PURE__ */ jsx(CommentsDrawerProvider, { children }) }) });
|
|
12
22
|
}
|
|
13
23
|
export {
|
|
14
24
|
CommentsProviderWrapper
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/providers/CommentsProviderWrapper/index.tsx"],"sourcesContent":["\"use client\";\n\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../../src/providers/CommentsProviderWrapper/index.tsx"],"sourcesContent":["\"use client\";\n\nimport { useState, type ReactNode } from \"react\";\nimport { QueryClient, QueryClientProvider } from \"@tanstack/react-query\";\nimport { useConfig } from \"@payloadcms/ui\";\nimport { CommentsDrawerProvider } from \"../CommentsDrawerProvider\";\nimport { CommentsProvider } from \"../CommentsProvider\";\nimport type { CommentsPluginConfigStorage } from \"../../types\";\n\ninterface Props {\n children: ReactNode;\n}\n\nexport function CommentsProviderWrapper({ children }: Props) {\n const { config } = useConfig();\n const [queryClient] = useState(\n () =>\n new QueryClient({\n defaultOptions: {\n queries: { retry: 1 },\n mutations: { retry: 0 },\n },\n }),\n );\n\n const pluginConfig = config.admin?.custom?.commentsPlugin as CommentsPluginConfigStorage | undefined;\n const usernameFieldRawPath = pluginConfig?.usernameFieldPath;\n const usernameFieldPath = usernameFieldRawPath === \"\" ? undefined : usernameFieldRawPath;\n\n return (\n <QueryClientProvider client={queryClient}>\n <CommentsProvider usernameFieldPath={usernameFieldPath}>\n <CommentsDrawerProvider>{children}</CommentsDrawerProvider>\n </CommentsProvider>\n </QueryClientProvider>\n );\n}\n"],"mappings":";AAgCQ;AA9BR,SAAS,gBAAgC;AACzC,SAAS,aAAa,2BAA2B;AACjD,SAAS,iBAAiB;AAC1B,SAAS,8BAA8B;AACvC,SAAS,wBAAwB;AAO1B,SAAS,wBAAwB,EAAE,SAAS,GAAU;AAC3D,QAAM,EAAE,OAAO,IAAI,UAAU;AAC7B,QAAM,CAAC,WAAW,IAAI;AAAA,IACpB,MACE,IAAI,YAAY;AAAA,MACd,gBAAgB;AAAA,QACd,SAAS,EAAE,OAAO,EAAE;AAAA,QACpB,WAAW,EAAE,OAAO,EAAE;AAAA,MACxB;AAAA,IACF,CAAC;AAAA,EACL;AAEA,QAAM,eAAe,OAAO,OAAO,QAAQ;AAC3C,QAAM,uBAAuB,cAAc;AAC3C,QAAM,oBAAoB,yBAAyB,KAAK,SAAY;AAEpE,SACE,oBAAC,uBAAoB,QAAQ,aAC3B,8BAAC,oBAAiB,mBAChB,8BAAC,0BAAwB,UAAS,GACpC,GACF;AAEJ;","names":[]}
|
|
@@ -5,7 +5,10 @@ interface Props {
|
|
|
5
5
|
enabledGlobals?: string[];
|
|
6
6
|
user?: TypedUser | null;
|
|
7
7
|
options?: BaseServiceOptions;
|
|
8
|
+
docId?: string | number;
|
|
9
|
+
filterCollectionSlug?: string;
|
|
10
|
+
filterGlobalSlug?: string;
|
|
8
11
|
}
|
|
9
|
-
export declare function findAllComments({ enabledCollections, enabledGlobals, options }?: Props): Promise<Response<Comment[]>>;
|
|
12
|
+
export declare function findAllComments({ enabledCollections, enabledGlobals, options, docId, filterCollectionSlug, filterGlobalSlug, }?: Props): Promise<Response<Comment[]>>;
|
|
10
13
|
export {};
|
|
11
14
|
//# sourceMappingURL=findAllComments.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findAllComments.d.ts","sourceRoot":"","sources":["../../src/services/findAllComments.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAS,MAAM,SAAS,CAAC;AAIhD,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAGtE,UAAU,KAAK;IACb,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,IAAI,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IACxB,OAAO,CAAC,EAAE,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"findAllComments.d.ts","sourceRoot":"","sources":["../../src/services/findAllComments.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAS,MAAM,SAAS,CAAC;AAIhD,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAGtE,UAAU,KAAK;IACb,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,IAAI,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IACxB,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,wBAAsB,eAAe,CAAC,EACpC,kBAAkB,EAClB,cAAc,EACd,OAAO,EACP,KAAK,EACL,oBAAoB,EACpB,gBAAgB,GACjB,GAAE,KAAU,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC,CAkE3C"}
|
|
@@ -3,23 +3,49 @@ import { extractPayload } from "../utils/payload/extractPayload";
|
|
|
3
3
|
import { DEFAULT_COLLECTION_SLUG } from "../constants";
|
|
4
4
|
import { getDefaultErrorMessage } from "../utils/error/getDefaultErrorMessage";
|
|
5
5
|
import { getCurrentTenantId } from "./getCurrentTenantId";
|
|
6
|
-
async function findAllComments({
|
|
6
|
+
async function findAllComments({
|
|
7
|
+
enabledCollections,
|
|
8
|
+
enabledGlobals,
|
|
9
|
+
options,
|
|
10
|
+
docId,
|
|
11
|
+
filterCollectionSlug,
|
|
12
|
+
filterGlobalSlug
|
|
13
|
+
} = {}) {
|
|
7
14
|
try {
|
|
8
15
|
const payload = await extractPayload(options?.payload);
|
|
9
16
|
const tenantId = await getCurrentTenantId(payload);
|
|
10
17
|
const where = {};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
if (docId && filterCollectionSlug) {
|
|
19
|
+
where.and = [
|
|
20
|
+
{
|
|
21
|
+
documentId: { equals: docId }
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
collectionSlug: { equals: filterCollectionSlug }
|
|
25
|
+
}
|
|
17
26
|
];
|
|
27
|
+
} else if (filterGlobalSlug) {
|
|
28
|
+
where.globalSlug = { equals: filterGlobalSlug };
|
|
29
|
+
} else {
|
|
30
|
+
const hasCollections = (enabledCollections?.length ?? 0) > 0;
|
|
31
|
+
const hasGlobals = (enabledGlobals?.length ?? 0) > 0;
|
|
32
|
+
if (hasCollections || hasGlobals) {
|
|
33
|
+
where.or = [
|
|
34
|
+
...hasCollections ? [
|
|
35
|
+
{
|
|
36
|
+
collectionSlug: { in: enabledCollections }
|
|
37
|
+
}
|
|
38
|
+
] : [],
|
|
39
|
+
...hasGlobals ? [
|
|
40
|
+
{
|
|
41
|
+
globalSlug: { in: enabledGlobals }
|
|
42
|
+
}
|
|
43
|
+
] : []
|
|
44
|
+
];
|
|
45
|
+
}
|
|
18
46
|
}
|
|
19
47
|
if (tenantId) {
|
|
20
|
-
where.tenant = {
|
|
21
|
-
equals: tenantId
|
|
22
|
-
};
|
|
48
|
+
where.tenant = { equals: tenantId };
|
|
23
49
|
}
|
|
24
50
|
const { docs: comments } = await payload.find({
|
|
25
51
|
collection: DEFAULT_COLLECTION_SLUG,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/services/findAllComments.ts"],"sourcesContent":["\"use server\";\n\nimport type { TypedUser, Where } from \"payload\";\nimport { extractPayload } from \"../utils/payload/extractPayload\";\nimport { DEFAULT_COLLECTION_SLUG } from \"../constants\";\nimport { getDefaultErrorMessage } from \"../utils/error/getDefaultErrorMessage\";\nimport type { Response, Comment, BaseServiceOptions } from \"../types\";\nimport { getCurrentTenantId } from \"./getCurrentTenantId\";\n\ninterface Props {\n enabledCollections?: string[];\n enabledGlobals?: string[];\n user?: TypedUser | null;\n options?: BaseServiceOptions;\n}\n\nexport async function findAllComments({
|
|
1
|
+
{"version":3,"sources":["../../src/services/findAllComments.ts"],"sourcesContent":["\"use server\";\n\nimport type { TypedUser, Where } from \"payload\";\nimport { extractPayload } from \"../utils/payload/extractPayload\";\nimport { DEFAULT_COLLECTION_SLUG } from \"../constants\";\nimport { getDefaultErrorMessage } from \"../utils/error/getDefaultErrorMessage\";\nimport type { Response, Comment, BaseServiceOptions } from \"../types\";\nimport { getCurrentTenantId } from \"./getCurrentTenantId\";\n\ninterface Props {\n enabledCollections?: string[];\n enabledGlobals?: string[];\n user?: TypedUser | null;\n options?: BaseServiceOptions;\n docId?: string | number;\n filterCollectionSlug?: string;\n filterGlobalSlug?: string;\n}\n\nexport async function findAllComments({\n enabledCollections,\n enabledGlobals,\n options,\n docId,\n filterCollectionSlug,\n filterGlobalSlug,\n}: Props = {}): Promise<Response<Comment[]>> {\n try {\n const payload = await extractPayload(options?.payload);\n const tenantId = await getCurrentTenantId(payload);\n\n const where: Where = {};\n\n if (docId && filterCollectionSlug) {\n where.and = [\n {\n documentId: { equals: docId },\n },\n {\n collectionSlug: { equals: filterCollectionSlug },\n },\n ];\n } else if (filterGlobalSlug) {\n where.globalSlug = { equals: filterGlobalSlug };\n } else {\n const hasCollections = (enabledCollections?.length ?? 0) > 0;\n const hasGlobals = (enabledGlobals?.length ?? 0) > 0;\n\n if (hasCollections || hasGlobals) {\n where.or = [\n ...(hasCollections ?\n [\n {\n collectionSlug: { in: enabledCollections },\n },\n ]\n : []),\n ...(hasGlobals ?\n [\n {\n globalSlug: { in: enabledGlobals },\n },\n ]\n : []),\n ];\n }\n }\n\n if (tenantId) {\n where.tenant = { equals: tenantId };\n }\n\n const { docs: comments } = await payload.find({\n collection: DEFAULT_COLLECTION_SLUG,\n where: Object.keys(where).length ? where : undefined,\n sort: \"createdAt\",\n limit: 200,\n depth: 1,\n overrideAccess: true,\n });\n\n return {\n success: true,\n data: comments as unknown as Comment[],\n };\n } catch (e) {\n console.error(\"findAllComments failed:\", e);\n return {\n success: false,\n error: getDefaultErrorMessage(e),\n };\n }\n}\n"],"mappings":";AAGA,SAAS,sBAAsB;AAC/B,SAAS,+BAA+B;AACxC,SAAS,8BAA8B;AAEvC,SAAS,0BAA0B;AAYnC,eAAsB,gBAAgB;AAAA,EACpC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,IAAW,CAAC,GAAiC;AAC3C,MAAI;AACF,UAAM,UAAU,MAAM,eAAe,SAAS,OAAO;AACrD,UAAM,WAAW,MAAM,mBAAmB,OAAO;AAEjD,UAAM,QAAe,CAAC;AAEtB,QAAI,SAAS,sBAAsB;AACjC,YAAM,MAAM;AAAA,QACV;AAAA,UACE,YAAY,EAAE,QAAQ,MAAM;AAAA,QAC9B;AAAA,QACA;AAAA,UACE,gBAAgB,EAAE,QAAQ,qBAAqB;AAAA,QACjD;AAAA,MACF;AAAA,IACF,WAAW,kBAAkB;AAC3B,YAAM,aAAa,EAAE,QAAQ,iBAAiB;AAAA,IAChD,OAAO;AACL,YAAM,kBAAkB,oBAAoB,UAAU,KAAK;AAC3D,YAAM,cAAc,gBAAgB,UAAU,KAAK;AAEnD,UAAI,kBAAkB,YAAY;AAChC,cAAM,KAAK;AAAA,UACT,GAAI,iBACF;AAAA,YACE;AAAA,cACE,gBAAgB,EAAE,IAAI,mBAAmB;AAAA,YAC3C;AAAA,UACF,IACA,CAAC;AAAA,UACH,GAAI,aACF;AAAA,YACE;AAAA,cACE,YAAY,EAAE,IAAI,eAAe;AAAA,YACnC;AAAA,UACF,IACA,CAAC;AAAA,QACL;AAAA,MACF;AAAA,IACF;AAEA,QAAI,UAAU;AACZ,YAAM,SAAS,EAAE,QAAQ,SAAS;AAAA,IACpC;AAEA,UAAM,EAAE,MAAM,SAAS,IAAI,MAAM,QAAQ,KAAK;AAAA,MAC5C,YAAY;AAAA,MACZ,OAAO,OAAO,KAAK,KAAK,EAAE,SAAS,QAAQ;AAAA,MAC3C,MAAM;AAAA,MACN,OAAO;AAAA,MACP,OAAO;AAAA,MACP,gBAAgB;AAAA,IAClB,CAAC;AAED,WAAO;AAAA,MACL,SAAS;AAAA,MACT,MAAM;AAAA,IACR;AAAA,EACF,SAAS,GAAG;AACV,YAAQ,MAAM,2BAA2B,CAAC;AAC1C,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OAAO,uBAAuB,CAAC;AAAA,IACjC;AAAA,EACF;AACF;","names":[]}
|
package/dist/styles.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! tailwindcss v4.2.1 | MIT License | https://tailwindcss.com */
|
|
2
|
-
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial;--tw-content:""}}}:root,:host{--color-black:#000;--spacing:.25rem;--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--leading-normal:1.5;--radius-sm:.25rem;--radius-md:.375rem;--animate-spin:spin 1s linear infinite;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1)}.pointer-events-none{pointer-events:none}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.sticky{position:sticky}.inset-0{inset:calc(var(--spacing) * 0)}.start{inset-inline-start:var(--spacing)}.top-0{top:calc(var(--spacing) * 0)}.top-3{top:calc(var(--spacing) * 3)}.right-3{right:calc(var(--spacing) * 3)}.z-29{z-index:29}.m-0{margin:calc(var(--spacing) * 0)}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.mb-3{margin-bottom:calc(var(--spacing) * 3)}.ml-auto{margin-left:auto}.box-border{box-sizing:border-box}.block{display:block}.flex{display:flex}.hidden{display:none}.h-4{height:calc(var(--spacing) * 4)}.h-9{height:calc(var(--spacing) * 9)}.h-\[20px\]{height:20px}.h-\[24px\]{height:24px}.min-h-5{min-height:calc(var(--spacing) * 5)}.w-4{width:calc(var(--spacing) * 4)}.w-9{width:calc(var(--spacing) * 9)}.w-80{width:calc(var(--spacing) * 80)}.w-\[20px\]{width:20px}.w-\[24px\]{width:24px}.w-auto{width:auto}.w-full{width:100%}.w-px{width:1px}.max-w-150{max-width:calc(var(--spacing) * 150)}.flex-1{flex:1}.shrink-0{flex-shrink:0}.-rotate-90{rotate:-90deg}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.animate-spin{animation:var(--animate-spin)}.cursor-pointer{cursor:pointer}.flex-col{flex-direction:column}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-md{border-radius:var(--radius-md)}.rounded-sm{border-radius:var(--radius-sm)}.border{border-style:var(--tw-border-style);border-width:1px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-none{--tw-border-style:none;border-style:none}.border-\(--theme-elevation-100\){border-color:var(--theme-elevation-100)}.border-transparent{border-color:#0000}.bg-\(--theme-bg\){background-color:var(--theme-bg)}.bg-\(--theme-elevation-0\){background-color:var(--theme-elevation-0)}.bg-\(--theme-elevation-100\){background-color:var(--theme-elevation-100)}.bg-\(--theme-elevation-150\){background-color:var(--theme-elevation-150)}.bg-\(--theme-elevation-1000\){background-color:var(--theme-elevation-1000)}.bg-\[\#36c5f021\]{background-color:#36c5f021}.bg-\[\#f0be3621\]{background-color:#f0be3621}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab, red, red)){.bg-black\/50{background-color:color-mix(in oklab, var(--color-black) 50%, transparent)}}.bg-transparent{background-color:#0000}.p-0{padding:calc(var(--spacing) * 0)}.p-1{padding:calc(var(--spacing) * 1)}.px-0\.5{padding-inline:calc(var(--spacing) * .5)}.px-1{padding-inline:calc(var(--spacing) * 1)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-5{padding-block:calc(var(--spacing) * 5)}.py-6{padding-block:calc(var(--spacing) * 6)}.pt-2{padding-top:calc(var(--spacing) * 2)}.pb-1\.25{padding-bottom:calc(var(--spacing) * 1.25)}.pb-5{padding-bottom:calc(var(--spacing) * 5)}.pl-3{padding-left:calc(var(--spacing) * 3)}.text-center{text-align:center}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-\[11px\]{font-size:11px}.text-\[12px\]{font-size:12px}.text-\[13px\]{font-size:13px}.text-\[14px\]{font-size:14px}.leading-5{--tw-leading:calc(var(--spacing) * 5);line-height:calc(var(--spacing) * 5)}.leading-none{--tw-leading:1;line-height:1}.leading-normal{--tw-leading:var(--leading-normal);line-height:var(--leading-normal)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.wrap-break-word{overflow-wrap:break-word}.whitespace-pre-wrap{white-space:pre-wrap}.text-\(--theme-elevation-0\){color:var(--theme-elevation-0)}.text-\(--theme-elevation-450\){color:var(--theme-elevation-450)}.text-\(--theme-elevation-500\){color:var(--theme-elevation-500)}.text-\(--theme-elevation-600\){color:var(--theme-elevation-600)}.text-\(--theme-text\){color:var(--theme-text)}.text-\[\#1264a3\]{color:#1264a3}.text-\[\#a36e12\]{color:#a36e12}.opacity-0{opacity:0}.opacity-100{opacity:1}.shadow-\[0_-2px_16px_-2px_rgba\(0\,0\,0\,0\.2\)\]{--tw-shadow:0 -2px 16px -2px var(--tw-shadow-color,#0003);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-150{--tw-duration:.15s;transition-duration:.15s}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}.group-focus-within\:flex:is(:where(.group):focus-within *){display:flex}@media (hover:hover){.group-hover\:pointer-events-auto:is(:where(.group):hover *){pointer-events:auto}.group-hover\:opacity-100:is(:where(.group):hover *){opacity:1}}.focus-within\:border-\(--theme-elevation-150\):focus-within{border-color:var(--theme-elevation-150)}@media (hover:hover){.hover\:bg-\(--theme-elevation-50\):hover{background-color:var(--theme-elevation-50)}.hover\:bg-\(--theme-elevation-150\):hover{background-color:var(--theme-elevation-150)}.hover\:bg-\(--theme-elevation-800\):hover{background-color:var(--theme-elevation-800)}.hover\:text-\(--theme-text\):hover{color:var(--theme-text)}}.\[\&\.is-empty\]\:before\:pointer-events-none.is-empty:before{content:var(--tw-content);pointer-events:none}.\[\&\.is-empty\]\:before\:absolute.is-empty:before{content:var(--tw-content);position:absolute}.\[\&\.is-empty\]\:before\:text-\(--theme-elevation-450\).is-empty:before{content:var(--tw-content);color:var(--theme-elevation-450)}.\[\&\.is-empty\]\:before\:content-\[attr\(data-placeholder\)\].is-empty:before{--tw-content:attr(data-placeholder);content:var(--tw-content)}.comments-drawer .gutter{padding:0 20px!important}.comments-drawer .drawer__content{--gutter-h:1px}.comments-drawer header .rs__control{min-width:120px;min-height:0;padding:2px 4px;font-size:13px}.comments-drawer header .rs__single-value,.comments-drawer header .rs__option{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-content{syntax:"*";inherits:false;initial-value:""}@keyframes spin{to{transform:rotate(360deg)}}
|
|
2
|
+
@layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial;--tw-content:""}}}:root,:host{--color-green-500:oklch(72.3% .219 149.579);--color-black:#000;--spacing:.25rem;--text-2xl:1.5rem;--text-2xl--line-height:calc(2 / 1.5);--font-weight-medium:500;--font-weight-semibold:600;--font-weight-bold:700;--leading-normal:1.5;--radius-sm:.25rem;--radius-md:.375rem;--default-transition-duration:.15s;--default-transition-timing-function:cubic-bezier(.4, 0, .2, 1)}.pointer-events-none{pointer-events:none}.absolute{position:absolute}.fixed{position:fixed}.relative{position:relative}.sticky{position:sticky}.inset-0{inset:calc(var(--spacing) * 0)}.start{inset-inline-start:var(--spacing)}.end{inset-inline-end:var(--spacing)}.top-0{top:calc(var(--spacing) * 0)}.top-3{top:calc(var(--spacing) * 3)}.right-3{right:calc(var(--spacing) * 3)}.z-10{z-index:10}.z-29{z-index:29}.m-0{margin:calc(var(--spacing) * 0)}.mb-1{margin-bottom:calc(var(--spacing) * 1)}.ml-auto{margin-left:auto}.box-border{box-sizing:border-box}.block{display:block}.flex{display:flex}.hidden{display:none}.h-4{height:calc(var(--spacing) * 4)}.h-9{height:calc(var(--spacing) * 9)}.h-\[20px\]{height:20px}.h-\[24px\]{height:24px}.h-px{height:1px}.max-h-32{max-height:calc(var(--spacing) * 32)}.min-h-5{min-height:calc(var(--spacing) * 5)}.w-4{width:calc(var(--spacing) * 4)}.w-9{width:calc(var(--spacing) * 9)}.w-\[20px\]{width:20px}.w-\[24px\]{width:24px}.w-auto{width:auto}.w-full{width:100%}.w-px{width:1px}.max-w-150{max-width:calc(var(--spacing) * 150)}.min-w-0{min-width:calc(var(--spacing) * 0)}.flex-1{flex:1}.shrink-0{flex-shrink:0}.-rotate-90{rotate:-90deg}.transform{transform:var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,)}.cursor-pointer{cursor:pointer}.flex-col{flex-direction:column}.items-center{align-items:center}.items-start{align-items:flex-start}.justify-center{justify-content:center}.justify-end{justify-content:flex-end}.gap-1{gap:calc(var(--spacing) * 1)}.gap-1\.5{gap:calc(var(--spacing) * 1.5)}.gap-2{gap:calc(var(--spacing) * 2)}.gap-2\.5{gap:calc(var(--spacing) * 2.5)}.gap-3{gap:calc(var(--spacing) * 3)}.truncate{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.overflow-y-auto{overflow-y:auto}.rounded{border-radius:.25rem}.rounded-full{border-radius:3.40282e38px}.rounded-md{border-radius:var(--radius-md)}.rounded-sm{border-radius:var(--radius-sm)}.border{border-style:var(--tw-border-style);border-width:1px}.border-l-2{border-left-style:var(--tw-border-style);border-left-width:2px}.border-none{--tw-border-style:none;border-style:none}.border-\(--theme-elevation-100\){border-color:var(--theme-elevation-100)}.border-transparent{border-color:#0000}.bg-\(--theme-bg\){background-color:var(--theme-bg)}.bg-\(--theme-elevation-0\){background-color:var(--theme-elevation-0)}.bg-\(--theme-elevation-100\){background-color:var(--theme-elevation-100)}.bg-\(--theme-elevation-150\){background-color:var(--theme-elevation-150)}.bg-\(--theme-elevation-1000\){background-color:var(--theme-elevation-1000)}.bg-\[\#36c5f021\]{background-color:#36c5f021}.bg-\[\#f0be3621\]{background-color:#f0be3621}.bg-black\/50{background-color:#00000080}@supports (color:color-mix(in lab, red, red)){.bg-black\/50{background-color:color-mix(in oklab, var(--color-black) 50%, transparent)}}.bg-current{background-color:currentColor}.bg-transparent{background-color:#0000}.p-0{padding:calc(var(--spacing) * 0)}.p-1{padding:calc(var(--spacing) * 1)}.px-0\.5{padding-inline:calc(var(--spacing) * .5)}.px-1{padding-inline:calc(var(--spacing) * 1)}.px-2\.5{padding-inline:calc(var(--spacing) * 2.5)}.px-3{padding-inline:calc(var(--spacing) * 3)}.py-1\.5{padding-block:calc(var(--spacing) * 1.5)}.py-2{padding-block:calc(var(--spacing) * 2)}.py-5{padding-block:calc(var(--spacing) * 5)}.py-6{padding-block:calc(var(--spacing) * 6)}.pt-2{padding-top:calc(var(--spacing) * 2)}.pb-1\.25{padding-bottom:calc(var(--spacing) * 1.25)}.pb-5{padding-bottom:calc(var(--spacing) * 5)}.pl-3{padding-left:calc(var(--spacing) * 3)}.text-center{text-align:center}.text-2xl{font-size:var(--text-2xl);line-height:var(--tw-leading,var(--text-2xl--line-height))}.text-\[11px\]{font-size:11px}.text-\[12px\]{font-size:12px}.text-\[13px\]{font-size:13px}.text-\[14px\]{font-size:14px}.leading-none{--tw-leading:1;line-height:1}.leading-normal{--tw-leading:var(--leading-normal);line-height:var(--leading-normal)}.font-bold{--tw-font-weight:var(--font-weight-bold);font-weight:var(--font-weight-bold)}.font-medium{--tw-font-weight:var(--font-weight-medium);font-weight:var(--font-weight-medium)}.font-semibold{--tw-font-weight:var(--font-weight-semibold);font-weight:var(--font-weight-semibold)}.wrap-break-word{overflow-wrap:break-word}.whitespace-pre-wrap{white-space:pre-wrap}.text-\(--theme-elevation-0\){color:var(--theme-elevation-0)}.text-\(--theme-elevation-450\){color:var(--theme-elevation-450)}.text-\(--theme-elevation-500\){color:var(--theme-elevation-500)}.text-\(--theme-elevation-600\){color:var(--theme-elevation-600)}.text-\(--theme-text\){color:var(--theme-text)}.text-\[\#1264a3\]{color:#1264a3}.text-\[\#a36e12\]{color:#a36e12}.text-green-500{color:var(--color-green-500)}.opacity-0{opacity:0}.opacity-60{opacity:.6}.shadow-\[0_-2px_16px_-2px_rgba\(0\,0\,0\,0\.2\)\]{--tw-shadow:0 -2px 16px -2px var(--tw-shadow-color,#0003);box-shadow:var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow)}.blur{--tw-blur:blur(8px);filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.filter{filter:var(--tw-blur,) var(--tw-brightness,) var(--tw-contrast,) var(--tw-grayscale,) var(--tw-hue-rotate,) var(--tw-invert,) var(--tw-saturate,) var(--tw-sepia,) var(--tw-drop-shadow,)}.transition-colors{transition-property:color,background-color,border-color,outline-color,text-decoration-color,fill,stroke,--tw-gradient-from,--tw-gradient-via,--tw-gradient-to;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-opacity{transition-property:opacity;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.transition-transform{transition-property:transform,translate,scale,rotate;transition-timing-function:var(--tw-ease,var(--default-transition-timing-function));transition-duration:var(--tw-duration,var(--default-transition-duration))}.duration-150{--tw-duration:.15s;transition-duration:.15s}.outline-none{--tw-outline-style:none;outline-style:none}.select-none{-webkit-user-select:none;user-select:none}.group-focus-within\:flex:is(:where(.group):focus-within *){display:flex}@media (hover:hover){.group-hover\:pointer-events-auto:is(:where(.group):hover *){pointer-events:auto}.group-hover\:opacity-100:is(:where(.group):hover *){opacity:1}}.focus-within\:border-\(--theme-elevation-150\):focus-within{border-color:var(--theme-elevation-150)}@media (hover:hover){.hover\:bg-\(--theme-elevation-50\):hover{background-color:var(--theme-elevation-50)}.hover\:bg-\(--theme-elevation-150\):hover{background-color:var(--theme-elevation-150)}.hover\:bg-\(--theme-elevation-800\):hover{background-color:var(--theme-elevation-800)}.hover\:text-\(--theme-text\):hover{color:var(--theme-text)}}@media (prefers-reduced-motion:reduce){.motion-reduce\:transition-none{transition-property:none}}.\[\&\.is-empty\]\:before\:pointer-events-none.is-empty:before{content:var(--tw-content);pointer-events:none}.\[\&\.is-empty\]\:before\:absolute.is-empty:before{content:var(--tw-content);position:absolute}.\[\&\.is-empty\]\:before\:text-\(--theme-elevation-450\).is-empty:before{content:var(--tw-content);color:var(--theme-elevation-450)}.\[\&\.is-empty\]\:before\:content-\[attr\(data-placeholder\)\].is-empty:before{--tw-content:attr(data-placeholder);content:var(--tw-content)}@media (hover:none){.\[\@media\(hover\:none\)\]\:opacity-100{opacity:1}}.comments-drawer .gutter{padding:0 20px!important}.comments-drawer .drawer__content{--gutter-h:1px}.comments-drawer .drawer__blur-bg{display:none}@property --tw-rotate-x{syntax:"*";inherits:false}@property --tw-rotate-y{syntax:"*";inherits:false}@property --tw-rotate-z{syntax:"*";inherits:false}@property --tw-skew-x{syntax:"*";inherits:false}@property --tw-skew-y{syntax:"*";inherits:false}@property --tw-border-style{syntax:"*";inherits:false;initial-value:solid}@property --tw-leading{syntax:"*";inherits:false}@property --tw-font-weight{syntax:"*";inherits:false}@property --tw-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-shadow-color{syntax:"*";inherits:false}@property --tw-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-inset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-shadow-color{syntax:"*";inherits:false}@property --tw-inset-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-ring-color{syntax:"*";inherits:false}@property --tw-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-inset-ring-color{syntax:"*";inherits:false}@property --tw-inset-ring-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-ring-inset{syntax:"*";inherits:false}@property --tw-ring-offset-width{syntax:"<length>";inherits:false;initial-value:0}@property --tw-ring-offset-color{syntax:"*";inherits:false;initial-value:#fff}@property --tw-ring-offset-shadow{syntax:"*";inherits:false;initial-value:0 0 #0000}@property --tw-blur{syntax:"*";inherits:false}@property --tw-brightness{syntax:"*";inherits:false}@property --tw-contrast{syntax:"*";inherits:false}@property --tw-grayscale{syntax:"*";inherits:false}@property --tw-hue-rotate{syntax:"*";inherits:false}@property --tw-invert{syntax:"*";inherits:false}@property --tw-opacity{syntax:"*";inherits:false}@property --tw-saturate{syntax:"*";inherits:false}@property --tw-sepia{syntax:"*";inherits:false}@property --tw-drop-shadow{syntax:"*";inherits:false}@property --tw-drop-shadow-color{syntax:"*";inherits:false}@property --tw-drop-shadow-alpha{syntax:"<percentage>";inherits:false;initial-value:100%}@property --tw-drop-shadow-size{syntax:"*";inherits:false}@property --tw-duration{syntax:"*";inherits:false}@property --tw-content{syntax:"*";inherits:false;initial-value:""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/translations/en.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,eAAO,MAAM,EAAE,EAAE;IAAE,QAAQ,EAAE,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"en.d.ts","sourceRoot":"","sources":["../../src/translations/en.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,eAAO,MAAM,EAAE,EAAE;IAAE,QAAQ,EAAE,oBAAoB,CAAA;CA2BhD,CAAC"}
|
package/dist/translations/en.js
CHANGED
|
@@ -10,6 +10,7 @@ const en = {
|
|
|
10
10
|
posting: "Posting\u2026",
|
|
11
11
|
resolve: "Resolve",
|
|
12
12
|
reopen: "Reopen",
|
|
13
|
+
resolved: "Resolved",
|
|
13
14
|
delete: "Delete",
|
|
14
15
|
general: "General",
|
|
15
16
|
close: "Close",
|
|
@@ -21,13 +22,8 @@ const en = {
|
|
|
21
22
|
failedToAdd: "Failed to add comment",
|
|
22
23
|
unknownAuthor: "Unknown",
|
|
23
24
|
deletedUser: "Deleted user",
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
noMentionedComments: "No comments mentioning you",
|
|
27
|
-
filterOpen: "Open",
|
|
28
|
-
filterResolved: "Resolved",
|
|
29
|
-
filterMentioned: "Mentioned me",
|
|
30
|
-
noMentionMatches: "No matches"
|
|
25
|
+
noMentionMatches: "No matches",
|
|
26
|
+
loadingComments: "Loading comments\u2026"
|
|
31
27
|
}
|
|
32
28
|
};
|
|
33
29
|
export {
|