@focus-reactive/payload-plugin-comments 1.1.0 → 1.2.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.
Files changed (169) hide show
  1. package/README.md +8 -6
  2. package/dist/api/mutations/useAddCommentMutation.d.ts +18 -0
  3. package/dist/api/mutations/useAddCommentMutation.d.ts.map +1 -0
  4. package/dist/api/mutations/useAddCommentMutation.js +52 -0
  5. package/dist/api/mutations/useAddCommentMutation.js.map +1 -0
  6. package/dist/api/mutations/useDeleteCommentMutation.d.ts +11 -0
  7. package/dist/api/mutations/useDeleteCommentMutation.d.ts.map +1 -0
  8. package/dist/api/mutations/useDeleteCommentMutation.js +31 -0
  9. package/dist/api/mutations/useDeleteCommentMutation.js.map +1 -0
  10. package/dist/api/mutations/useResolveCommentMutation.d.ts +13 -0
  11. package/dist/api/mutations/useResolveCommentMutation.d.ts.map +1 -0
  12. package/dist/api/mutations/useResolveCommentMutation.js +41 -0
  13. package/dist/api/mutations/useResolveCommentMutation.js.map +1 -0
  14. package/dist/api/queries/useCommentsQuery.d.ts +3 -0
  15. package/dist/api/queries/useCommentsQuery.d.ts.map +1 -0
  16. package/dist/api/queries/useCommentsQuery.js +40 -0
  17. package/dist/api/queries/useCommentsQuery.js.map +1 -0
  18. package/dist/api/queries/useDocumentTitlesQuery.d.ts +3 -0
  19. package/dist/api/queries/useDocumentTitlesQuery.d.ts.map +1 -0
  20. package/dist/api/queries/useDocumentTitlesQuery.js +32 -0
  21. package/dist/api/queries/useDocumentTitlesQuery.js.map +1 -0
  22. package/dist/api/queries/useFieldLabelsQuery.d.ts +3 -0
  23. package/dist/api/queries/useFieldLabelsQuery.d.ts.map +1 -0
  24. package/dist/api/queries/useFieldLabelsQuery.js +23 -0
  25. package/dist/api/queries/useFieldLabelsQuery.js.map +1 -0
  26. package/dist/api/queries/useMentionableUsersQuery.d.ts +2 -0
  27. package/dist/api/queries/useMentionableUsersQuery.d.ts.map +1 -0
  28. package/dist/api/queries/useMentionableUsersQuery.js +25 -0
  29. package/dist/api/queries/useMentionableUsersQuery.js.map +1 -0
  30. package/dist/api/queryKeys.d.ts +23 -0
  31. package/dist/api/queryKeys.d.ts.map +1 -0
  32. package/dist/api/queryKeys.js +40 -0
  33. package/dist/api/queryKeys.js.map +1 -0
  34. package/dist/components/CommentEditor/ActionPanel.d.ts +1 -1
  35. package/dist/components/CommentEditor/ActionPanel.d.ts.map +1 -1
  36. package/dist/components/CommentEditor/ActionPanel.js +18 -3
  37. package/dist/components/CommentEditor/ActionPanel.js.map +1 -1
  38. package/dist/components/CommentEditor/index.d.ts.map +1 -1
  39. package/dist/components/CommentEditor/index.js +5 -3
  40. package/dist/components/CommentEditor/index.js.map +1 -1
  41. package/dist/components/CommentItem/StrikethoroughOverlay/clamp.d.ts +2 -0
  42. package/dist/components/CommentItem/StrikethoroughOverlay/clamp.d.ts.map +1 -0
  43. package/dist/components/CommentItem/StrikethoroughOverlay/clamp.js +7 -0
  44. package/dist/components/CommentItem/StrikethoroughOverlay/clamp.js.map +1 -0
  45. package/dist/components/CommentItem/StrikethoroughOverlay/index.d.ts +8 -0
  46. package/dist/components/CommentItem/StrikethoroughOverlay/index.d.ts.map +1 -0
  47. package/dist/components/CommentItem/StrikethoroughOverlay/index.js +24 -0
  48. package/dist/components/CommentItem/StrikethoroughOverlay/index.js.map +1 -0
  49. package/dist/components/CommentItem/StrikethoroughOverlay/measureLineRects.d.ts +3 -0
  50. package/dist/components/CommentItem/StrikethoroughOverlay/measureLineRects.d.ts.map +1 -0
  51. package/dist/components/CommentItem/StrikethoroughOverlay/measureLineRects.js +29 -0
  52. package/dist/components/CommentItem/StrikethoroughOverlay/measureLineRects.js.map +1 -0
  53. package/dist/components/CommentItem/StrikethoroughOverlay/useStrikethroughAnimation.d.ts +7 -0
  54. package/dist/components/CommentItem/StrikethoroughOverlay/useStrikethroughAnimation.d.ts.map +1 -0
  55. package/dist/components/CommentItem/StrikethoroughOverlay/useStrikethroughAnimation.js +114 -0
  56. package/dist/components/CommentItem/StrikethoroughOverlay/useStrikethroughAnimation.js.map +1 -0
  57. package/dist/components/CommentItem/index.d.ts.map +1 -1
  58. package/dist/components/CommentItem/index.js +37 -18
  59. package/dist/components/CommentItem/index.js.map +1 -1
  60. package/dist/components/CommentsDrawer/components/Header.d.ts.map +1 -1
  61. package/dist/components/CommentsDrawer/components/Header.js +4 -33
  62. package/dist/components/CommentsDrawer/components/Header.js.map +1 -1
  63. package/dist/components/CommentsHeaderButton/index.js +2 -2
  64. package/dist/components/CommentsHeaderButton/index.js.map +1 -1
  65. package/dist/components/CommentsPanel/components/CollapsibleGroup.d.ts +7 -2
  66. package/dist/components/CommentsPanel/components/CollapsibleGroup.d.ts.map +1 -1
  67. package/dist/components/CommentsPanel/components/CollapsibleGroup.js +7 -2
  68. package/dist/components/CommentsPanel/components/CollapsibleGroup.js.map +1 -1
  69. package/dist/components/CommentsPanel/components/DocumentView.d.ts.map +1 -1
  70. package/dist/components/CommentsPanel/components/DocumentView.js +11 -9
  71. package/dist/components/CommentsPanel/components/DocumentView.js.map +1 -1
  72. package/dist/components/CommentsPanel/components/FieldGroupSection.d.ts.map +1 -1
  73. package/dist/components/CommentsPanel/components/FieldGroupSection.js +44 -22
  74. package/dist/components/CommentsPanel/components/FieldGroupSection.js.map +1 -1
  75. package/dist/components/CommentsPanel/components/GlobalDocumentView.d.ts.map +1 -1
  76. package/dist/components/CommentsPanel/components/GlobalDocumentView.js +3 -9
  77. package/dist/components/CommentsPanel/components/GlobalDocumentView.js.map +1 -1
  78. package/dist/components/CommentsPanel/components/GlobalView.d.ts.map +1 -1
  79. package/dist/components/CommentsPanel/components/GlobalView.js +38 -41
  80. package/dist/components/CommentsPanel/components/GlobalView.js.map +1 -1
  81. package/dist/components/CommentsPanel/hooks/useCollapseState.d.ts +1 -1
  82. package/dist/components/CommentsPanel/hooks/useCollapseState.d.ts.map +1 -1
  83. package/dist/components/CommentsPanel/hooks/useCollapseState.js +4 -1
  84. package/dist/components/CommentsPanel/hooks/useCollapseState.js.map +1 -1
  85. package/dist/components/CommentsPanel/index.d.ts.map +1 -1
  86. package/dist/components/CommentsPanel/index.js +14 -11
  87. package/dist/components/CommentsPanel/index.js.map +1 -1
  88. package/dist/components/FieldCommentLabel/hooks/useFieldBreadcrumb.d.ts +2 -0
  89. package/dist/components/FieldCommentLabel/hooks/useFieldBreadcrumb.d.ts.map +1 -0
  90. package/dist/components/FieldCommentLabel/hooks/useFieldBreadcrumb.js +52 -0
  91. package/dist/components/FieldCommentLabel/hooks/useFieldBreadcrumb.js.map +1 -0
  92. package/dist/components/FieldCommentLabel/index.d.ts +1 -1
  93. package/dist/components/FieldCommentLabel/index.d.ts.map +1 -1
  94. package/dist/components/FieldCommentLabel/index.js +54 -41
  95. package/dist/components/FieldCommentLabel/index.js.map +1 -1
  96. package/dist/components/FieldCommentLabel/types.d.ts +1 -1
  97. package/dist/components/FieldCommentLabel/types.d.ts.map +1 -1
  98. package/dist/components/FieldCommentLabel/utils/exludeComments.js +2 -2
  99. package/dist/components/FieldCommentLabel/utils/exludeComments.js.map +1 -1
  100. package/dist/components/IconButton/index.d.ts +2 -2
  101. package/dist/components/IconButton/index.d.ts.map +1 -1
  102. package/dist/components/IconButton/index.js +11 -1
  103. package/dist/components/IconButton/index.js.map +1 -1
  104. package/dist/constants.d.ts +1 -0
  105. package/dist/constants.d.ts.map +1 -1
  106. package/dist/constants.js +3 -4
  107. package/dist/constants.js.map +1 -1
  108. package/dist/plugin.d.ts.map +1 -1
  109. package/dist/plugin.js +6 -2
  110. package/dist/plugin.js.map +1 -1
  111. package/dist/providers/CommentsDrawerProvider/index.d.ts +8 -0
  112. package/dist/providers/CommentsDrawerProvider/index.d.ts.map +1 -1
  113. package/dist/providers/CommentsDrawerProvider/index.js +22 -6
  114. package/dist/providers/CommentsDrawerProvider/index.js.map +1 -1
  115. package/dist/providers/CommentsProvider/index.d.ts +7 -17
  116. package/dist/providers/CommentsProvider/index.d.ts.map +1 -1
  117. package/dist/providers/CommentsProvider/index.js +105 -196
  118. package/dist/providers/CommentsProvider/index.js.map +1 -1
  119. package/dist/providers/CommentsProviderWrapper/index.d.ts +1 -1
  120. package/dist/providers/CommentsProviderWrapper/index.d.ts.map +1 -1
  121. package/dist/providers/CommentsProviderWrapper/index.js +11 -1
  122. package/dist/providers/CommentsProviderWrapper/index.js.map +1 -1
  123. package/dist/services/findAllComments.d.ts +4 -1
  124. package/dist/services/findAllComments.d.ts.map +1 -1
  125. package/dist/services/findAllComments.js +36 -10
  126. package/dist/services/findAllComments.js.map +1 -1
  127. package/dist/styles.css +1 -1
  128. package/dist/translations/en.d.ts.map +1 -1
  129. package/dist/translations/en.js +3 -7
  130. package/dist/translations/en.js.map +1 -1
  131. package/dist/translations/types.d.ts +2 -6
  132. package/dist/translations/types.d.ts.map +1 -1
  133. package/dist/types/general.d.ts +0 -2
  134. package/dist/types/general.d.ts.map +1 -1
  135. package/dist/types/index.d.ts +3 -2
  136. package/dist/types/index.d.ts.map +1 -1
  137. package/dist/types/query.d.ts +11 -0
  138. package/dist/types/query.d.ts.map +1 -0
  139. package/dist/types/query.js +1 -0
  140. package/dist/types/query.js.map +1 -0
  141. package/dist/utils/query/toQueryContext.d.ts +3 -0
  142. package/dist/utils/query/toQueryContext.d.ts.map +1 -0
  143. package/dist/utils/query/toQueryContext.js +20 -0
  144. package/dist/utils/query/toQueryContext.js.map +1 -0
  145. package/package.json +3 -6
  146. package/dist/components/CommentsPanel/constants.d.ts +0 -3
  147. package/dist/components/CommentsPanel/constants.d.ts.map +0 -1
  148. package/dist/components/CommentsPanel/constants.js +0 -9
  149. package/dist/components/CommentsPanel/constants.js.map +0 -1
  150. package/dist/components/CommentsPanel/utils/filterComments.d.ts +0 -9
  151. package/dist/components/CommentsPanel/utils/filterComments.d.ts.map +0 -1
  152. package/dist/components/CommentsPanel/utils/filterComments.js +0 -17
  153. package/dist/components/CommentsPanel/utils/filterComments.js.map +0 -1
  154. package/dist/components/FieldCommentLabel/AddCommentPopup.d.ts +0 -8
  155. package/dist/components/FieldCommentLabel/AddCommentPopup.d.ts.map +0 -1
  156. package/dist/components/FieldCommentLabel/AddCommentPopup.js +0 -50
  157. package/dist/components/FieldCommentLabel/AddCommentPopup.js.map +0 -1
  158. package/dist/providers/GlobalCommentsLoader/GlobalCommentsHydrator.d.ts +0 -13
  159. package/dist/providers/GlobalCommentsLoader/GlobalCommentsHydrator.d.ts.map +0 -1
  160. package/dist/providers/GlobalCommentsLoader/GlobalCommentsHydrator.js +0 -22
  161. package/dist/providers/GlobalCommentsLoader/GlobalCommentsHydrator.js.map +0 -1
  162. package/dist/providers/GlobalCommentsLoader/index.d.ts +0 -10
  163. package/dist/providers/GlobalCommentsLoader/index.d.ts.map +0 -1
  164. package/dist/providers/GlobalCommentsLoader/index.js +0 -31
  165. package/dist/providers/GlobalCommentsLoader/index.js.map +0 -1
  166. package/dist/services/syncAllCommentsData.d.ts +0 -12
  167. package/dist/services/syncAllCommentsData.d.ts.map +0 -1
  168. package/dist/services/syncAllCommentsData.js +0 -48
  169. package/dist/services/syncAllCommentsData.js.map +0 -1
package/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # @focus-reactive/payload-plugin-comments
2
2
 
3
+
3
4
  [![npm](https://img.shields.io/npm/v/@focus-reactive/payload-plugin-comments)](https://www.npmjs.com/package/@focus-reactive/payload-plugin-comments)
4
5
 
5
6
  A collaborative commenting plugin for [Payload CMS](https://payloadcms.com/) v3. Adds a full-featured comments system to the Payload admin panel — supporting document-level and field-level comments on both collections and globals, @mentions with email notifications, comment resolution, multi-tenancy, and locale-aware filtering.
@@ -145,27 +146,28 @@ RESEND_FROM_EMAIL=comments@yourdomain.com
145
146
 
146
147
  A header button in the Payload admin opens a drawer listing all comments across every document and collection.
147
148
 
148
- ![Global comments panel](docs/screenshots/global-comments-panel.png)
149
+ ![Global comments panel](https://github.com/user-attachments/assets/ff1dd13c-42a8-4434-825f-8903e75d840c)
149
150
 
150
151
  ### Document Comments Panel
151
152
 
152
153
  When viewing a document, a side panel shows all comments scoped to that document with filter tabs (Open / Resolved / Mentioned me).
153
154
 
154
- ![Document comments panel](docs/screenshots/document-comments-panel.png)
155
+ ![Document comments panel](https://github.com/user-attachments/assets/3525ff5e-eb80-48dc-936e-0da3b317ffbb)
155
156
 
156
157
  ### Field Comment Popup
157
158
 
158
159
  Clicking the comment badge on a field label opens a popup where you can write and post a new comment for that specific field.
159
160
 
160
- ![Field comment popup](docs/screenshots/field-comment-popup.png)
161
+ ![Field comment popup](https://github.com/user-attachments/assets/259c7dc6-5b0e-4bcd-9d49-b7e520682f01)
161
162
 
162
163
  ### Field Label Button — Two States
163
164
 
164
165
  The comment button embedded in the field label has two visual states: no comments (inactive, appears on hover) and one or more open comments (active, showing the count badge).
165
166
 
166
- | Inactive (no comments) | Active (has comments) |
167
- | ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
168
- | ![Field label button — inactive](docs/screenshots/field-label-button-inactive.png) | ![Field label button — active](docs/screenshots/field-label-button-active.png) |
167
+ | Inactive (no comments) | Active (has comments) |
168
+ | ----------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- |
169
+ | ![Field label button — inactive](https://github.com/user-attachments/assets/f540d6a4-c4e9-473f-883c-c34803da4d2f) | ![Field label button — active](https://github.com/user-attachments/assets/dcfbe20e-7b6e-4fa4-9d30-a0e8bd44b7c0) |
170
+ | |
169
171
 
170
172
  ---
171
173
 
@@ -0,0 +1,18 @@
1
+ import type { Comment, QueryContext } from "../../types";
2
+ interface AddCommentVariables {
3
+ ctx: QueryContext;
4
+ text: string;
5
+ fieldPath?: string | null;
6
+ documentId?: number | null;
7
+ collectionSlug?: string | null;
8
+ globalSlug?: string | null;
9
+ locale?: string | null;
10
+ mentionIds: number[];
11
+ currentUser: Comment["author"];
12
+ }
13
+ export declare function useAddCommentMutation(): import("@tanstack/react-query").UseMutationResult<import("../../types").Response<Comment>, Error, AddCommentVariables, {
14
+ snapshot: Comment[] | undefined;
15
+ ctx: QueryContext;
16
+ }>;
17
+ export {};
18
+ //# sourceMappingURL=useAddCommentMutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useAddCommentMutation.d.ts","sourceRoot":"","sources":["../../../src/api/mutations/useAddCommentMutation.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAQ,YAAY,EAAE,MAAM,aAAa,CAAC;AAE/D,UAAU,mBAAmB;IAC3B,GAAG,EAAE,YAAY,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,WAAW,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;CAChC;AAED,wBAAgB,qBAAqB;;;GAqDpC"}
@@ -0,0 +1,52 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { getCommentsKey, getFieldLabelsKey, getDocumentTitlesKey, QUERY_KEYS } from "../queryKeys";
4
+ import { createComment } from "../../services/createComment";
5
+ function useAddCommentMutation() {
6
+ const queryClient = useQueryClient();
7
+ return useMutation({
8
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
9
+ mutationFn: ({ ctx: _ctx, currentUser: _user, ...data }) => createComment(data),
10
+ onMutate: async (variables) => {
11
+ const { ctx, text, fieldPath, documentId, collectionSlug, globalSlug, locale, mentionIds, currentUser } = variables;
12
+ const key = getCommentsKey(ctx);
13
+ await queryClient.cancelQueries({ queryKey: key });
14
+ const snapshot = queryClient.getQueryData(key);
15
+ const cachedUsers = queryClient.getQueryData(QUERY_KEYS.mentionableUsers()) ?? [];
16
+ const selectedUsers = cachedUsers.filter(({ id }) => mentionIds.includes(id));
17
+ const mentions = selectedUsers.map((user) => ({ id: null, user }));
18
+ const optimisticComment = {
19
+ id: -Date.now(),
20
+ text,
21
+ fieldPath: fieldPath ?? null,
22
+ locale,
23
+ documentId: documentId ?? null,
24
+ collectionSlug: collectionSlug ?? null,
25
+ globalSlug: globalSlug ?? null,
26
+ isResolved: false,
27
+ mentions,
28
+ author: currentUser,
29
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
30
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
31
+ };
32
+ queryClient.setQueryData(key, (prev = []) => [optimisticComment, ...prev]);
33
+ return { snapshot, ctx };
34
+ },
35
+ onError: (_err, _vars, context) => {
36
+ if (context?.snapshot !== void 0) {
37
+ queryClient.setQueryData(getCommentsKey(context.ctx), context.snapshot);
38
+ }
39
+ },
40
+ onSettled: (_data, _err, _vars, context) => {
41
+ if (!context?.ctx) return;
42
+ const ctx = context.ctx;
43
+ queryClient.invalidateQueries({ queryKey: getCommentsKey(ctx) });
44
+ queryClient.invalidateQueries({ queryKey: getFieldLabelsKey(ctx) });
45
+ queryClient.invalidateQueries({ queryKey: getDocumentTitlesKey(ctx) });
46
+ }
47
+ });
48
+ }
49
+ export {
50
+ useAddCommentMutation
51
+ };
52
+ //# sourceMappingURL=useAddCommentMutation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/api/mutations/useAddCommentMutation.ts"],"sourcesContent":["\"use client\";\n\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { getCommentsKey, getFieldLabelsKey, getDocumentTitlesKey, QUERY_KEYS } from \"../queryKeys\";\nimport { createComment } from \"../../services/createComment\";\nimport type { Comment, User, QueryContext } from \"../../types\";\n\ninterface AddCommentVariables {\n ctx: QueryContext;\n text: string;\n fieldPath?: string | null;\n documentId?: number | null;\n collectionSlug?: string | null;\n globalSlug?: string | null;\n locale?: string | null;\n mentionIds: number[];\n currentUser: Comment[\"author\"];\n}\n\nexport function useAddCommentMutation() {\n const queryClient = useQueryClient();\n\n return useMutation({\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n mutationFn: ({ ctx: _ctx, currentUser: _user, ...data }: AddCommentVariables) => createComment(data),\n onMutate: async (variables) => {\n const { ctx, text, fieldPath, documentId, collectionSlug, globalSlug, locale, mentionIds, currentUser } =\n variables;\n\n const key = getCommentsKey(ctx);\n\n await queryClient.cancelQueries({ queryKey: key });\n const snapshot = queryClient.getQueryData<Comment[]>(key);\n\n const cachedUsers = queryClient.getQueryData<User[]>(QUERY_KEYS.mentionableUsers()) ?? [];\n const selectedUsers = cachedUsers.filter(({ id }) => mentionIds.includes(id));\n const mentions = selectedUsers.map((user) => ({ id: null, user }));\n\n const optimisticComment: Comment = {\n id: -Date.now(),\n text,\n fieldPath: fieldPath ?? null,\n locale,\n documentId: documentId ?? null,\n collectionSlug: collectionSlug ?? null,\n globalSlug: globalSlug ?? null,\n isResolved: false,\n mentions,\n author: currentUser,\n createdAt: new Date().toISOString(),\n updatedAt: new Date().toISOString(),\n };\n\n queryClient.setQueryData<Comment[]>(key, (prev = []) => [optimisticComment, ...prev]);\n\n return { snapshot, ctx };\n },\n onError: (_err, _vars, context) => {\n if (context?.snapshot !== undefined) {\n queryClient.setQueryData(getCommentsKey(context.ctx), context.snapshot);\n }\n },\n onSettled: (_data, _err, _vars, context) => {\n if (!context?.ctx) return;\n\n const ctx = context.ctx;\n\n queryClient.invalidateQueries({ queryKey: getCommentsKey(ctx) });\n queryClient.invalidateQueries({ queryKey: getFieldLabelsKey(ctx) });\n queryClient.invalidateQueries({ queryKey: getDocumentTitlesKey(ctx) });\n },\n });\n}\n"],"mappings":";AAEA,SAAS,aAAa,sBAAsB;AAC5C,SAAS,gBAAgB,mBAAmB,sBAAsB,kBAAkB;AACpF,SAAS,qBAAqB;AAevB,SAAS,wBAAwB;AACtC,QAAM,cAAc,eAAe;AAEnC,SAAO,YAAY;AAAA;AAAA,IAEjB,YAAY,CAAC,EAAE,KAAK,MAAM,aAAa,OAAO,GAAG,KAAK,MAA2B,cAAc,IAAI;AAAA,IACnG,UAAU,OAAO,cAAc;AAC7B,YAAM,EAAE,KAAK,MAAM,WAAW,YAAY,gBAAgB,YAAY,QAAQ,YAAY,YAAY,IACpG;AAEF,YAAM,MAAM,eAAe,GAAG;AAE9B,YAAM,YAAY,cAAc,EAAE,UAAU,IAAI,CAAC;AACjD,YAAM,WAAW,YAAY,aAAwB,GAAG;AAExD,YAAM,cAAc,YAAY,aAAqB,WAAW,iBAAiB,CAAC,KAAK,CAAC;AACxF,YAAM,gBAAgB,YAAY,OAAO,CAAC,EAAE,GAAG,MAAM,WAAW,SAAS,EAAE,CAAC;AAC5E,YAAM,WAAW,cAAc,IAAI,CAAC,UAAU,EAAE,IAAI,MAAM,KAAK,EAAE;AAEjE,YAAM,oBAA6B;AAAA,QACjC,IAAI,CAAC,KAAK,IAAI;AAAA,QACd;AAAA,QACA,WAAW,aAAa;AAAA,QACxB;AAAA,QACA,YAAY,cAAc;AAAA,QAC1B,gBAAgB,kBAAkB;AAAA,QAClC,YAAY,cAAc;AAAA,QAC1B,YAAY;AAAA,QACZ;AAAA,QACA,QAAQ;AAAA,QACR,YAAW,oBAAI,KAAK,GAAE,YAAY;AAAA,QAClC,YAAW,oBAAI,KAAK,GAAE,YAAY;AAAA,MACpC;AAEA,kBAAY,aAAwB,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,mBAAmB,GAAG,IAAI,CAAC;AAEpF,aAAO,EAAE,UAAU,IAAI;AAAA,IACzB;AAAA,IACA,SAAS,CAAC,MAAM,OAAO,YAAY;AACjC,UAAI,SAAS,aAAa,QAAW;AACnC,oBAAY,aAAa,eAAe,QAAQ,GAAG,GAAG,QAAQ,QAAQ;AAAA,MACxE;AAAA,IACF;AAAA,IACA,WAAW,CAAC,OAAO,MAAM,OAAO,YAAY;AAC1C,UAAI,CAAC,SAAS,IAAK;AAEnB,YAAM,MAAM,QAAQ;AAEpB,kBAAY,kBAAkB,EAAE,UAAU,eAAe,GAAG,EAAE,CAAC;AAC/D,kBAAY,kBAAkB,EAAE,UAAU,kBAAkB,GAAG,EAAE,CAAC;AAClE,kBAAY,kBAAkB,EAAE,UAAU,qBAAqB,GAAG,EAAE,CAAC;AAAA,IACvE;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -0,0 +1,11 @@
1
+ import type { Comment, QueryContext } from "../../types";
2
+ interface DeleteCommentVariables {
3
+ ctx: QueryContext;
4
+ commentId: string | number;
5
+ }
6
+ export declare function useDeleteCommentMutation(): import("@tanstack/react-query").UseMutationResult<import("../../types").Response<Comment>, Error, DeleteCommentVariables, {
7
+ snapshot: Comment[] | undefined;
8
+ ctx: QueryContext;
9
+ }>;
10
+ export {};
11
+ //# sourceMappingURL=useDeleteCommentMutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDeleteCommentMutation.d.ts","sourceRoot":"","sources":["../../../src/api/mutations/useDeleteCommentMutation.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEzD,UAAU,sBAAsB;IAC9B,GAAG,EAAE,YAAY,CAAC;IAClB,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;CAC5B;AAED,wBAAgB,wBAAwB;;;GA2BvC"}
@@ -0,0 +1,31 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { getCommentsKey } from "../queryKeys";
4
+ import { deleteComment } from "../../services/deleteComment";
5
+ function useDeleteCommentMutation() {
6
+ const queryClient = useQueryClient();
7
+ return useMutation({
8
+ mutationFn: ({ commentId }) => deleteComment(commentId),
9
+ onMutate: async (variables) => {
10
+ const { ctx, commentId } = variables;
11
+ const key = getCommentsKey(ctx);
12
+ await queryClient.cancelQueries({ queryKey: key });
13
+ const snapshot = queryClient.getQueryData(key);
14
+ queryClient.setQueryData(key, (prev = []) => prev.filter((c) => c.id !== commentId));
15
+ return { snapshot, ctx };
16
+ },
17
+ onError: (_err, _vars, context) => {
18
+ if (context?.snapshot !== void 0) {
19
+ queryClient.setQueryData(getCommentsKey(context.ctx), context.snapshot);
20
+ }
21
+ },
22
+ onSettled: (_data, _err, _vars, context) => {
23
+ if (!context?.ctx) return;
24
+ queryClient.invalidateQueries({ queryKey: getCommentsKey(context.ctx) });
25
+ }
26
+ });
27
+ }
28
+ export {
29
+ useDeleteCommentMutation
30
+ };
31
+ //# sourceMappingURL=useDeleteCommentMutation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/api/mutations/useDeleteCommentMutation.ts"],"sourcesContent":["\"use client\";\n\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { getCommentsKey } from \"../queryKeys\";\nimport { deleteComment } from \"../../services/deleteComment\";\nimport type { Comment, QueryContext } from \"../../types\";\n\ninterface DeleteCommentVariables {\n ctx: QueryContext;\n commentId: string | number;\n}\n\nexport function useDeleteCommentMutation() {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: ({ commentId }: DeleteCommentVariables) => deleteComment(commentId),\n onMutate: async (variables) => {\n const { ctx, commentId } = variables;\n const key = getCommentsKey(ctx);\n\n await queryClient.cancelQueries({ queryKey: key });\n const snapshot = queryClient.getQueryData<Comment[]>(key);\n\n queryClient.setQueryData<Comment[]>(key, (prev = []) => prev.filter((c) => c.id !== commentId));\n\n return { snapshot, ctx };\n },\n onError: (_err, _vars, context) => {\n if (context?.snapshot !== undefined) {\n queryClient.setQueryData(getCommentsKey(context.ctx), context.snapshot);\n }\n },\n onSettled: (_data, _err, _vars, context) => {\n if (!context?.ctx) return;\n\n queryClient.invalidateQueries({ queryKey: getCommentsKey(context.ctx) });\n },\n });\n}\n"],"mappings":";AAEA,SAAS,aAAa,sBAAsB;AAC5C,SAAS,sBAAsB;AAC/B,SAAS,qBAAqB;AAQvB,SAAS,2BAA2B;AACzC,QAAM,cAAc,eAAe;AAEnC,SAAO,YAAY;AAAA,IACjB,YAAY,CAAC,EAAE,UAAU,MAA8B,cAAc,SAAS;AAAA,IAC9E,UAAU,OAAO,cAAc;AAC7B,YAAM,EAAE,KAAK,UAAU,IAAI;AAC3B,YAAM,MAAM,eAAe,GAAG;AAE9B,YAAM,YAAY,cAAc,EAAE,UAAU,IAAI,CAAC;AACjD,YAAM,WAAW,YAAY,aAAwB,GAAG;AAExD,kBAAY,aAAwB,KAAK,CAAC,OAAO,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,OAAO,SAAS,CAAC;AAE9F,aAAO,EAAE,UAAU,IAAI;AAAA,IACzB;AAAA,IACA,SAAS,CAAC,MAAM,OAAO,YAAY;AACjC,UAAI,SAAS,aAAa,QAAW;AACnC,oBAAY,aAAa,eAAe,QAAQ,GAAG,GAAG,QAAQ,QAAQ;AAAA,MACxE;AAAA,IACF;AAAA,IACA,WAAW,CAAC,OAAO,MAAM,OAAO,YAAY;AAC1C,UAAI,CAAC,SAAS,IAAK;AAEnB,kBAAY,kBAAkB,EAAE,UAAU,eAAe,QAAQ,GAAG,EAAE,CAAC;AAAA,IACzE;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -0,0 +1,13 @@
1
+ import type { Comment, QueryContext } from "../../types";
2
+ interface ResolveCommentVariables {
3
+ ctx: QueryContext;
4
+ commentId: string | number;
5
+ resolved: boolean;
6
+ currentUser: Comment["author"];
7
+ }
8
+ export declare function useResolveCommentMutation(): import("@tanstack/react-query").UseMutationResult<import("../../types").Response<Comment>, Error, ResolveCommentVariables, {
9
+ snapshot: Comment[] | undefined;
10
+ ctx: QueryContext;
11
+ }>;
12
+ export {};
13
+ //# sourceMappingURL=useResolveCommentMutation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useResolveCommentMutation.d.ts","sourceRoot":"","sources":["../../../src/api/mutations/useResolveCommentMutation.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEzD,UAAU,uBAAuB;IAC/B,GAAG,EAAE,YAAY,CAAC;IAClB,SAAS,EAAE,MAAM,GAAG,MAAM,CAAC;IAC3B,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;CAChC;AAED,wBAAgB,yBAAyB;;;GAsCxC"}
@@ -0,0 +1,41 @@
1
+ "use client";
2
+ import { useMutation, useQueryClient } from "@tanstack/react-query";
3
+ import { getCommentsKey } from "../queryKeys";
4
+ import { resolveComment } from "../../services/resolveComment";
5
+ function useResolveCommentMutation() {
6
+ const queryClient = useQueryClient();
7
+ return useMutation({
8
+ mutationFn: ({ commentId, resolved }) => resolveComment(commentId, resolved),
9
+ onMutate: async (variables) => {
10
+ const { ctx, commentId, resolved, currentUser } = variables;
11
+ const key = getCommentsKey(ctx);
12
+ await queryClient.cancelQueries({ queryKey: key });
13
+ const snapshot = queryClient.getQueryData(key);
14
+ queryClient.setQueryData(
15
+ key,
16
+ (prev = []) => prev.map(
17
+ (c) => c.id === commentId ? {
18
+ ...c,
19
+ isResolved: resolved,
20
+ resolvedAt: resolved ? (/* @__PURE__ */ new Date()).toISOString() : null,
21
+ resolvedBy: resolved ? currentUser : null
22
+ } : c
23
+ )
24
+ );
25
+ return { snapshot, ctx };
26
+ },
27
+ onError: (_err, _vars, context) => {
28
+ if (context?.snapshot !== void 0) {
29
+ queryClient.setQueryData(getCommentsKey(context.ctx), context.snapshot);
30
+ }
31
+ },
32
+ onSettled: (_data, _err, _vars, context) => {
33
+ if (!context?.ctx) return;
34
+ void queryClient.invalidateQueries({ queryKey: getCommentsKey(context.ctx) });
35
+ }
36
+ });
37
+ }
38
+ export {
39
+ useResolveCommentMutation
40
+ };
41
+ //# sourceMappingURL=useResolveCommentMutation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/api/mutations/useResolveCommentMutation.ts"],"sourcesContent":["\"use client\";\n\nimport { useMutation, useQueryClient } from \"@tanstack/react-query\";\nimport { getCommentsKey } from \"../queryKeys\";\nimport { resolveComment } from \"../../services/resolveComment\";\nimport type { Comment, QueryContext } from \"../../types\";\n\ninterface ResolveCommentVariables {\n ctx: QueryContext;\n commentId: string | number;\n resolved: boolean;\n currentUser: Comment[\"author\"];\n}\n\nexport function useResolveCommentMutation() {\n const queryClient = useQueryClient();\n\n return useMutation({\n mutationFn: ({ commentId, resolved }: ResolveCommentVariables) => resolveComment(commentId, resolved),\n onMutate: async (variables) => {\n const { ctx, commentId, resolved, currentUser } = variables;\n const key = getCommentsKey(ctx);\n\n await queryClient.cancelQueries({ queryKey: key });\n const snapshot = queryClient.getQueryData<Comment[]>(key);\n\n queryClient.setQueryData<Comment[]>(key, (prev = []) =>\n prev.map((c) =>\n c.id === commentId ?\n {\n ...c,\n isResolved: resolved,\n resolvedAt: resolved ? new Date().toISOString() : null,\n resolvedBy: resolved ? currentUser : null,\n }\n : c,\n ),\n );\n\n return { snapshot, ctx };\n },\n onError: (_err, _vars, context) => {\n if (context?.snapshot !== undefined) {\n queryClient.setQueryData(getCommentsKey(context.ctx), context.snapshot);\n }\n },\n onSettled: (_data, _err, _vars, context) => {\n if (!context?.ctx) return;\n\n void queryClient.invalidateQueries({ queryKey: getCommentsKey(context.ctx) });\n },\n });\n}\n"],"mappings":";AAEA,SAAS,aAAa,sBAAsB;AAC5C,SAAS,sBAAsB;AAC/B,SAAS,sBAAsB;AAUxB,SAAS,4BAA4B;AAC1C,QAAM,cAAc,eAAe;AAEnC,SAAO,YAAY;AAAA,IACjB,YAAY,CAAC,EAAE,WAAW,SAAS,MAA+B,eAAe,WAAW,QAAQ;AAAA,IACpG,UAAU,OAAO,cAAc;AAC7B,YAAM,EAAE,KAAK,WAAW,UAAU,YAAY,IAAI;AAClD,YAAM,MAAM,eAAe,GAAG;AAE9B,YAAM,YAAY,cAAc,EAAE,UAAU,IAAI,CAAC;AACjD,YAAM,WAAW,YAAY,aAAwB,GAAG;AAExD,kBAAY;AAAA,QAAwB;AAAA,QAAK,CAAC,OAAO,CAAC,MAChD,KAAK;AAAA,UAAI,CAAC,MACR,EAAE,OAAO,YACP;AAAA,YACE,GAAG;AAAA,YACH,YAAY;AAAA,YACZ,YAAY,YAAW,oBAAI,KAAK,GAAE,YAAY,IAAI;AAAA,YAClD,YAAY,WAAW,cAAc;AAAA,UACvC,IACA;AAAA,QACJ;AAAA,MACF;AAEA,aAAO,EAAE,UAAU,IAAI;AAAA,IACzB;AAAA,IACA,SAAS,CAAC,MAAM,OAAO,YAAY;AACjC,UAAI,SAAS,aAAa,QAAW;AACnC,oBAAY,aAAa,eAAe,QAAQ,GAAG,GAAG,QAAQ,QAAQ;AAAA,MACxE;AAAA,IACF;AAAA,IACA,WAAW,CAAC,OAAO,MAAM,OAAO,YAAY;AAC1C,UAAI,CAAC,SAAS,IAAK;AAEnB,WAAK,YAAY,kBAAkB,EAAE,UAAU,eAAe,QAAQ,GAAG,EAAE,CAAC;AAAA,IAC9E;AAAA,EACF,CAAC;AACH;","names":[]}
@@ -0,0 +1,3 @@
1
+ import type { QueryContext } from "../../types";
2
+ export declare function useCommentsQuery(ctx: QueryContext): import("@tanstack/react-query").UseQueryResult<import("../../types").Comment[], Error>;
3
+ //# sourceMappingURL=useCommentsQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCommentsQuery.d.ts","sourceRoot":"","sources":["../../../src/api/queries/useCommentsQuery.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,YAAY,0FAqCjD"}
@@ -0,0 +1,40 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useConfig } from "@payloadcms/ui";
4
+ import { getCommentsKey } from "../queryKeys";
5
+ import { findAllComments } from "../../services/findAllComments";
6
+ import { useCommentsDrawer } from "../../providers/CommentsDrawerProvider";
7
+ import { REFETCH_INTERVAL } from "../../constants";
8
+ function useCommentsQuery(ctx) {
9
+ const { isOpen } = useCommentsDrawer();
10
+ const { config } = useConfig();
11
+ const pluginConfig = config.admin?.custom?.commentsPlugin;
12
+ return useQuery({
13
+ queryKey: getCommentsKey(ctx),
14
+ queryFn: async () => {
15
+ const params = ctx.mode === "doc" ? {
16
+ enabledCollections: pluginConfig?.collections,
17
+ enabledGlobals: pluginConfig?.globals,
18
+ docId: ctx.docId,
19
+ filterCollectionSlug: ctx.collectionSlug
20
+ } : ctx.mode === "global-doc" ? {
21
+ enabledCollections: pluginConfig?.collections,
22
+ enabledGlobals: pluginConfig?.globals,
23
+ filterGlobalSlug: ctx.globalSlug
24
+ } : {
25
+ enabledCollections: pluginConfig?.collections,
26
+ enabledGlobals: pluginConfig?.globals
27
+ };
28
+ const res = await findAllComments(params);
29
+ if (!res.success) throw new Error(res.error);
30
+ return res.data;
31
+ },
32
+ staleTime: 0,
33
+ refetchInterval: isOpen ? REFETCH_INTERVAL : false,
34
+ refetchIntervalInBackground: false
35
+ });
36
+ }
37
+ export {
38
+ useCommentsQuery
39
+ };
40
+ //# sourceMappingURL=useCommentsQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/api/queries/useCommentsQuery.ts"],"sourcesContent":["\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useConfig } from \"@payloadcms/ui\";\nimport { getCommentsKey } from \"../queryKeys\";\nimport { findAllComments } from \"../../services/findAllComments\";\nimport { useCommentsDrawer } from \"../../providers/CommentsDrawerProvider\";\nimport type { QueryContext } from \"../../types\";\nimport type { CommentsPluginConfigStorage } from \"../../types\";\nimport { REFETCH_INTERVAL } from \"../../constants\";\n\nexport function useCommentsQuery(ctx: QueryContext) {\n const { isOpen } = useCommentsDrawer();\n const { config } = useConfig();\n const pluginConfig = config.admin?.custom?.commentsPlugin as CommentsPluginConfigStorage | undefined;\n\n return useQuery({\n queryKey: getCommentsKey(ctx),\n queryFn: async () => {\n const params =\n ctx.mode === \"doc\" ?\n {\n enabledCollections: pluginConfig?.collections,\n enabledGlobals: pluginConfig?.globals,\n docId: ctx.docId,\n filterCollectionSlug: ctx.collectionSlug,\n }\n : ctx.mode === \"global-doc\" ?\n {\n enabledCollections: pluginConfig?.collections,\n enabledGlobals: pluginConfig?.globals,\n filterGlobalSlug: ctx.globalSlug,\n }\n : {\n enabledCollections: pluginConfig?.collections,\n enabledGlobals: pluginConfig?.globals,\n };\n\n const res = await findAllComments(params);\n\n if (!res.success) throw new Error(res.error);\n \n return res.data;\n },\n staleTime: 0,\n refetchInterval: isOpen ? REFETCH_INTERVAL : false,\n refetchIntervalInBackground: false,\n });\n}\n"],"mappings":";AAEA,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,sBAAsB;AAC/B,SAAS,uBAAuB;AAChC,SAAS,yBAAyB;AAGlC,SAAS,wBAAwB;AAE1B,SAAS,iBAAiB,KAAmB;AAClD,QAAM,EAAE,OAAO,IAAI,kBAAkB;AACrC,QAAM,EAAE,OAAO,IAAI,UAAU;AAC7B,QAAM,eAAe,OAAO,OAAO,QAAQ;AAE3C,SAAO,SAAS;AAAA,IACd,UAAU,eAAe,GAAG;AAAA,IAC5B,SAAS,YAAY;AACnB,YAAM,SACJ,IAAI,SAAS,QACX;AAAA,QACE,oBAAoB,cAAc;AAAA,QAClC,gBAAgB,cAAc;AAAA,QAC9B,OAAO,IAAI;AAAA,QACX,sBAAsB,IAAI;AAAA,MAC5B,IACA,IAAI,SAAS,eACb;AAAA,QACE,oBAAoB,cAAc;AAAA,QAClC,gBAAgB,cAAc;AAAA,QAC9B,kBAAkB,IAAI;AAAA,MACxB,IACA;AAAA,QACE,oBAAoB,cAAc;AAAA,QAClC,gBAAgB,cAAc;AAAA,MAChC;AAEJ,YAAM,MAAM,MAAM,gBAAgB,MAAM;AAExC,UAAI,CAAC,IAAI,QAAS,OAAM,IAAI,MAAM,IAAI,KAAK;AAE3C,aAAO,IAAI;AAAA,IACb;AAAA,IACA,WAAW;AAAA,IACX,iBAAiB,SAAS,mBAAmB;AAAA,IAC7C,6BAA6B;AAAA,EAC/B,CAAC;AACH;","names":[]}
@@ -0,0 +1,3 @@
1
+ import type { QueryContext } from "../../types";
2
+ export declare function useDocumentTitlesQuery(ctx: QueryContext): import("@tanstack/react-query").UseQueryResult<import("../../types").DocumentTitles, Error>;
3
+ //# sourceMappingURL=useDocumentTitlesQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDocumentTitlesQuery.d.ts","sourceRoot":"","sources":["../../../src/api/queries/useDocumentTitlesQuery.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAIhD,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,YAAY,+FAsBvD"}
@@ -0,0 +1,32 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { useConfig } from "@payloadcms/ui";
4
+ import { useLocale } from "@payloadcms/ui";
5
+ import { getDocumentTitlesKey } from "../queryKeys";
6
+ import { getDocumentTitles } from "../../services/getDocumentTitles";
7
+ import { useCommentsDrawer } from "../../providers/CommentsDrawerProvider";
8
+ import { useCommentsQuery } from "./useCommentsQuery";
9
+ import { REFETCH_INTERVAL } from "../../constants";
10
+ function useDocumentTitlesQuery(ctx) {
11
+ const { isOpen } = useCommentsDrawer();
12
+ const { data: comments } = useCommentsQuery(ctx);
13
+ const { code: locale } = useLocale();
14
+ const { config } = useConfig();
15
+ const pluginConfig = config.admin?.custom?.commentsPlugin;
16
+ return useQuery({
17
+ queryKey: getDocumentTitlesKey(ctx),
18
+ queryFn: async () => {
19
+ const res = await getDocumentTitles(comments ?? [], pluginConfig?.documentTitleFields ?? {}, { locale });
20
+ if (!res.success) throw new Error(res.error);
21
+ return res.data;
22
+ },
23
+ enabled: isOpen && !!comments,
24
+ staleTime: 0,
25
+ refetchInterval: isOpen ? REFETCH_INTERVAL : false,
26
+ refetchIntervalInBackground: false
27
+ });
28
+ }
29
+ export {
30
+ useDocumentTitlesQuery
31
+ };
32
+ //# sourceMappingURL=useDocumentTitlesQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/api/queries/useDocumentTitlesQuery.ts"],"sourcesContent":["\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { useConfig } from \"@payloadcms/ui\";\nimport { useLocale } from \"@payloadcms/ui\";\nimport { getDocumentTitlesKey } from \"../queryKeys\";\nimport { getDocumentTitles } from \"../../services/getDocumentTitles\";\nimport { useCommentsDrawer } from \"../../providers/CommentsDrawerProvider\";\nimport { useCommentsQuery } from \"./useCommentsQuery\";\nimport type { QueryContext } from \"../../types\";\nimport type { CommentsPluginConfigStorage } from \"../../types\";\nimport { REFETCH_INTERVAL } from \"../../constants\";\n\nexport function useDocumentTitlesQuery(ctx: QueryContext) {\n const { isOpen } = useCommentsDrawer();\n const { data: comments } = useCommentsQuery(ctx);\n const { code: locale } = useLocale();\n const { config } = useConfig();\n\n const pluginConfig = config.admin?.custom?.commentsPlugin as CommentsPluginConfigStorage | undefined;\n\n return useQuery({\n queryKey: getDocumentTitlesKey(ctx),\n queryFn: async () => {\n const res = await getDocumentTitles(comments ?? [], pluginConfig?.documentTitleFields ?? {}, { locale });\n\n if (!res.success) throw new Error(res.error);\n\n return res.data;\n },\n enabled: isOpen && !!comments,\n staleTime: 0,\n refetchInterval: isOpen ? REFETCH_INTERVAL : false,\n refetchIntervalInBackground: false,\n });\n}\n"],"mappings":";AAEA,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,4BAA4B;AACrC,SAAS,yBAAyB;AAClC,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AAGjC,SAAS,wBAAwB;AAE1B,SAAS,uBAAuB,KAAmB;AACxD,QAAM,EAAE,OAAO,IAAI,kBAAkB;AACrC,QAAM,EAAE,MAAM,SAAS,IAAI,iBAAiB,GAAG;AAC/C,QAAM,EAAE,MAAM,OAAO,IAAI,UAAU;AACnC,QAAM,EAAE,OAAO,IAAI,UAAU;AAE7B,QAAM,eAAe,OAAO,OAAO,QAAQ;AAE3C,SAAO,SAAS;AAAA,IACd,UAAU,qBAAqB,GAAG;AAAA,IAClC,SAAS,YAAY;AACnB,YAAM,MAAM,MAAM,kBAAkB,YAAY,CAAC,GAAG,cAAc,uBAAuB,CAAC,GAAG,EAAE,OAAO,CAAC;AAEvG,UAAI,CAAC,IAAI,QAAS,OAAM,IAAI,MAAM,IAAI,KAAK;AAE3C,aAAO,IAAI;AAAA,IACb;AAAA,IACA,SAAS,UAAU,CAAC,CAAC;AAAA,IACrB,WAAW;AAAA,IACX,iBAAiB,SAAS,mBAAmB;AAAA,IAC7C,6BAA6B;AAAA,EAC/B,CAAC;AACH;","names":[]}
@@ -0,0 +1,3 @@
1
+ import type { QueryContext } from "../../types";
2
+ export declare function useFieldLabelsQuery(ctx: QueryContext): import("@tanstack/react-query").UseQueryResult<import("../../types").GlobalFieldLabelRegistry, Error>;
3
+ //# sourceMappingURL=useFieldLabelsQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFieldLabelsQuery.d.ts","sourceRoot":"","sources":["../../../src/api/queries/useFieldLabelsQuery.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGhD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,YAAY,yGAYpD"}
@@ -0,0 +1,23 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { getFieldLabelsKey } from "../queryKeys";
4
+ import { fetchFieldLabels } from "../../services/fieldLabels/fetchFieldLabels";
5
+ import { useCommentsDrawer } from "../../providers/CommentsDrawerProvider";
6
+ import { useCommentsQuery } from "./useCommentsQuery";
7
+ import { REFETCH_INTERVAL } from "../../constants";
8
+ function useFieldLabelsQuery(ctx) {
9
+ const { isOpen } = useCommentsDrawer();
10
+ const { data: comments } = useCommentsQuery(ctx);
11
+ return useQuery({
12
+ queryKey: getFieldLabelsKey(ctx),
13
+ queryFn: () => fetchFieldLabels(comments ?? []),
14
+ enabled: isOpen && !!comments,
15
+ staleTime: 0,
16
+ refetchInterval: isOpen ? REFETCH_INTERVAL : false,
17
+ refetchIntervalInBackground: false
18
+ });
19
+ }
20
+ export {
21
+ useFieldLabelsQuery
22
+ };
23
+ //# sourceMappingURL=useFieldLabelsQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/api/queries/useFieldLabelsQuery.ts"],"sourcesContent":["\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { getFieldLabelsKey } from \"../queryKeys\";\nimport { fetchFieldLabels } from \"../../services/fieldLabels/fetchFieldLabels\";\nimport { useCommentsDrawer } from \"../../providers/CommentsDrawerProvider\";\nimport { useCommentsQuery } from \"./useCommentsQuery\";\nimport type { QueryContext } from \"../../types\";\nimport { REFETCH_INTERVAL } from \"../../constants\";\n\nexport function useFieldLabelsQuery(ctx: QueryContext) {\n const { isOpen } = useCommentsDrawer();\n const { data: comments } = useCommentsQuery(ctx);\n\n return useQuery({\n queryKey: getFieldLabelsKey(ctx),\n queryFn: () => fetchFieldLabels(comments ?? []),\n enabled: isOpen && !!comments,\n staleTime: 0,\n refetchInterval: isOpen ? REFETCH_INTERVAL : false,\n refetchIntervalInBackground: false,\n });\n}\n"],"mappings":";AAEA,SAAS,gBAAgB;AACzB,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AACjC,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AAEjC,SAAS,wBAAwB;AAE1B,SAAS,oBAAoB,KAAmB;AACrD,QAAM,EAAE,OAAO,IAAI,kBAAkB;AACrC,QAAM,EAAE,MAAM,SAAS,IAAI,iBAAiB,GAAG;AAE/C,SAAO,SAAS;AAAA,IACd,UAAU,kBAAkB,GAAG;AAAA,IAC/B,SAAS,MAAM,iBAAiB,YAAY,CAAC,CAAC;AAAA,IAC9C,SAAS,UAAU,CAAC,CAAC;AAAA,IACrB,WAAW;AAAA,IACX,iBAAiB,SAAS,mBAAmB;AAAA,IAC7C,6BAA6B;AAAA,EAC/B,CAAC;AACH;","names":[]}
@@ -0,0 +1,2 @@
1
+ export declare function useMentionableUsersQuery(): import("@tanstack/react-query").UseQueryResult<import("../../types").User[], Error>;
2
+ //# sourceMappingURL=useMentionableUsersQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useMentionableUsersQuery.d.ts","sourceRoot":"","sources":["../../../src/api/queries/useMentionableUsersQuery.ts"],"names":[],"mappings":"AAQA,wBAAgB,wBAAwB,wFAiBvC"}
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { useQuery } from "@tanstack/react-query";
3
+ import { QUERY_KEYS } from "../queryKeys";
4
+ import { fetchMentionableUsers } from "../../services/fetchMentionableUsers";
5
+ import { useCommentsDrawer } from "../../providers/CommentsDrawerProvider";
6
+ import { REFETCH_INTERVAL } from "../../constants";
7
+ function useMentionableUsersQuery() {
8
+ const { isOpen } = useCommentsDrawer();
9
+ return useQuery({
10
+ queryKey: QUERY_KEYS.mentionableUsers(),
11
+ queryFn: async () => {
12
+ const res = await fetchMentionableUsers();
13
+ if (!res.success) throw new Error(res.error);
14
+ return res.data;
15
+ },
16
+ enabled: isOpen,
17
+ staleTime: 0,
18
+ refetchInterval: isOpen ? REFETCH_INTERVAL : false,
19
+ refetchIntervalInBackground: false
20
+ });
21
+ }
22
+ export {
23
+ useMentionableUsersQuery
24
+ };
25
+ //# sourceMappingURL=useMentionableUsersQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/api/queries/useMentionableUsersQuery.ts"],"sourcesContent":["\"use client\";\n\nimport { useQuery } from \"@tanstack/react-query\";\nimport { QUERY_KEYS } from \"../queryKeys\";\nimport { fetchMentionableUsers } from \"../../services/fetchMentionableUsers\";\nimport { useCommentsDrawer } from \"../../providers/CommentsDrawerProvider\";\nimport { REFETCH_INTERVAL } from \"../../constants\";\n\nexport function useMentionableUsersQuery() {\n const { isOpen } = useCommentsDrawer();\n\n return useQuery({\n queryKey: QUERY_KEYS.mentionableUsers(),\n queryFn: async () => {\n const res = await fetchMentionableUsers();\n\n if (!res.success) throw new Error(res.error);\n\n return res.data;\n },\n enabled: isOpen,\n staleTime: 0,\n refetchInterval: isOpen ? REFETCH_INTERVAL : false,\n refetchIntervalInBackground: false,\n });\n}\n"],"mappings":";AAEA,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,6BAA6B;AACtC,SAAS,yBAAyB;AAClC,SAAS,wBAAwB;AAE1B,SAAS,2BAA2B;AACzC,QAAM,EAAE,OAAO,IAAI,kBAAkB;AAErC,SAAO,SAAS;AAAA,IACd,UAAU,WAAW,iBAAiB;AAAA,IACtC,SAAS,YAAY;AACnB,YAAM,MAAM,MAAM,sBAAsB;AAExC,UAAI,CAAC,IAAI,QAAS,OAAM,IAAI,MAAM,IAAI,KAAK;AAE3C,aAAO,IAAI;AAAA,IACb;AAAA,IACA,SAAS;AAAA,IACT,WAAW;AAAA,IACX,iBAAiB,SAAS,mBAAmB;AAAA,IAC7C,6BAA6B;AAAA,EAC/B,CAAC;AACH;","names":[]}
@@ -0,0 +1,23 @@
1
+ import type { QueryContext } from "../types";
2
+ export declare const QUERY_KEYS: {
3
+ comments: {
4
+ doc: (collectionSlug: string, docId: string) => readonly ["comments", "doc", string, string];
5
+ globalDoc: (globalSlug: string) => readonly ["comments", "global-doc", string];
6
+ global: () => readonly ["comments", "global"];
7
+ };
8
+ fieldLabels: {
9
+ doc: (collectionSlug: string, docId: string) => readonly ["field-labels", "doc", string, string];
10
+ globalDoc: (globalSlug: string) => readonly ["field-labels", "global-doc", string];
11
+ global: () => readonly ["field-labels", "global"];
12
+ };
13
+ documentTitles: {
14
+ doc: (collectionSlug: string, docId: string) => readonly ["document-titles", "doc", string, string];
15
+ globalDoc: (globalSlug: string) => readonly ["document-titles", "global-doc", string];
16
+ global: () => readonly ["document-titles", "global"];
17
+ };
18
+ mentionableUsers: () => readonly ["mentionable-users"];
19
+ };
20
+ export declare function getCommentsKey(ctx: QueryContext): readonly ["comments", "doc", string, string] | readonly ["comments", "global-doc", string] | readonly ["comments", "global"];
21
+ export declare function getFieldLabelsKey(ctx: QueryContext): readonly ["field-labels", "doc", string, string] | readonly ["field-labels", "global-doc", string] | readonly ["field-labels", "global"];
22
+ export declare function getDocumentTitlesKey(ctx: QueryContext): readonly ["document-titles", "doc", string, string] | readonly ["document-titles", "global-doc", string] | readonly ["document-titles", "global"];
23
+ //# sourceMappingURL=queryKeys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"queryKeys.d.ts","sourceRoot":"","sources":["../../src/api/queryKeys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7C,eAAO,MAAM,UAAU;;8BAEG,MAAM,SAAS,MAAM;gCACnB,MAAM;;;;8BAIR,MAAM,SAAS,MAAM;gCACnB,MAAM;;;;8BAIR,MAAM,SAAS,MAAM;gCACnB,MAAM;;;;CAIjC,CAAC;AAEF,wBAAgB,cAAc,CAAC,GAAG,EAAE,YAAY,gIAM/C;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,YAAY,4IAMlD;AAED,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,YAAY,qJAMrD"}
@@ -0,0 +1,40 @@
1
+ const QUERY_KEYS = {
2
+ comments: {
3
+ doc: (collectionSlug, docId) => ["comments", "doc", collectionSlug, docId],
4
+ globalDoc: (globalSlug) => ["comments", "global-doc", globalSlug],
5
+ global: () => ["comments", "global"]
6
+ },
7
+ fieldLabels: {
8
+ doc: (collectionSlug, docId) => ["field-labels", "doc", collectionSlug, docId],
9
+ globalDoc: (globalSlug) => ["field-labels", "global-doc", globalSlug],
10
+ global: () => ["field-labels", "global"]
11
+ },
12
+ documentTitles: {
13
+ doc: (collectionSlug, docId) => ["document-titles", "doc", collectionSlug, docId],
14
+ globalDoc: (globalSlug) => ["document-titles", "global-doc", globalSlug],
15
+ global: () => ["document-titles", "global"]
16
+ },
17
+ mentionableUsers: () => ["mentionable-users"]
18
+ };
19
+ function getCommentsKey(ctx) {
20
+ if (ctx.mode === "doc") return QUERY_KEYS.comments.doc(ctx.collectionSlug, ctx.docId);
21
+ if (ctx.mode === "global-doc") return QUERY_KEYS.comments.globalDoc(ctx.globalSlug);
22
+ return QUERY_KEYS.comments.global();
23
+ }
24
+ function getFieldLabelsKey(ctx) {
25
+ if (ctx.mode === "doc") return QUERY_KEYS.fieldLabels.doc(ctx.collectionSlug, ctx.docId);
26
+ if (ctx.mode === "global-doc") return QUERY_KEYS.fieldLabels.globalDoc(ctx.globalSlug);
27
+ return QUERY_KEYS.fieldLabels.global();
28
+ }
29
+ function getDocumentTitlesKey(ctx) {
30
+ if (ctx.mode === "doc") return QUERY_KEYS.documentTitles.doc(ctx.collectionSlug, ctx.docId);
31
+ if (ctx.mode === "global-doc") return QUERY_KEYS.documentTitles.globalDoc(ctx.globalSlug);
32
+ return QUERY_KEYS.documentTitles.global();
33
+ }
34
+ export {
35
+ QUERY_KEYS,
36
+ getCommentsKey,
37
+ getDocumentTitlesKey,
38
+ getFieldLabelsKey
39
+ };
40
+ //# sourceMappingURL=queryKeys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/api/queryKeys.ts"],"sourcesContent":["import type { QueryContext } from \"../types\";\n\nexport const QUERY_KEYS = {\n comments: {\n doc: (collectionSlug: string, docId: string) => [\"comments\", \"doc\", collectionSlug, docId] as const,\n globalDoc: (globalSlug: string) => [\"comments\", \"global-doc\", globalSlug] as const,\n global: () => [\"comments\", \"global\"] as const,\n },\n fieldLabels: {\n doc: (collectionSlug: string, docId: string) => [\"field-labels\", \"doc\", collectionSlug, docId] as const,\n globalDoc: (globalSlug: string) => [\"field-labels\", \"global-doc\", globalSlug] as const,\n global: () => [\"field-labels\", \"global\"] as const,\n },\n documentTitles: {\n doc: (collectionSlug: string, docId: string) => [\"document-titles\", \"doc\", collectionSlug, docId] as const,\n globalDoc: (globalSlug: string) => [\"document-titles\", \"global-doc\", globalSlug] as const,\n global: () => [\"document-titles\", \"global\"] as const,\n },\n mentionableUsers: () => [\"mentionable-users\"] as const,\n};\n\nexport function getCommentsKey(ctx: QueryContext) {\n if (ctx.mode === \"doc\") return QUERY_KEYS.comments.doc(ctx.collectionSlug, ctx.docId);\n\n if (ctx.mode === \"global-doc\") return QUERY_KEYS.comments.globalDoc(ctx.globalSlug);\n\n return QUERY_KEYS.comments.global();\n}\n\nexport function getFieldLabelsKey(ctx: QueryContext) {\n if (ctx.mode === \"doc\") return QUERY_KEYS.fieldLabels.doc(ctx.collectionSlug, ctx.docId);\n\n if (ctx.mode === \"global-doc\") return QUERY_KEYS.fieldLabels.globalDoc(ctx.globalSlug);\n\n return QUERY_KEYS.fieldLabels.global();\n}\n\nexport function getDocumentTitlesKey(ctx: QueryContext) {\n if (ctx.mode === \"doc\") return QUERY_KEYS.documentTitles.doc(ctx.collectionSlug, ctx.docId);\n\n if (ctx.mode === \"global-doc\") return QUERY_KEYS.documentTitles.globalDoc(ctx.globalSlug);\n\n return QUERY_KEYS.documentTitles.global();\n}\n"],"mappings":"AAEO,MAAM,aAAa;AAAA,EACxB,UAAU;AAAA,IACR,KAAK,CAAC,gBAAwB,UAAkB,CAAC,YAAY,OAAO,gBAAgB,KAAK;AAAA,IACzF,WAAW,CAAC,eAAuB,CAAC,YAAY,cAAc,UAAU;AAAA,IACxE,QAAQ,MAAM,CAAC,YAAY,QAAQ;AAAA,EACrC;AAAA,EACA,aAAa;AAAA,IACX,KAAK,CAAC,gBAAwB,UAAkB,CAAC,gBAAgB,OAAO,gBAAgB,KAAK;AAAA,IAC7F,WAAW,CAAC,eAAuB,CAAC,gBAAgB,cAAc,UAAU;AAAA,IAC5E,QAAQ,MAAM,CAAC,gBAAgB,QAAQ;AAAA,EACzC;AAAA,EACA,gBAAgB;AAAA,IACd,KAAK,CAAC,gBAAwB,UAAkB,CAAC,mBAAmB,OAAO,gBAAgB,KAAK;AAAA,IAChG,WAAW,CAAC,eAAuB,CAAC,mBAAmB,cAAc,UAAU;AAAA,IAC/E,QAAQ,MAAM,CAAC,mBAAmB,QAAQ;AAAA,EAC5C;AAAA,EACA,kBAAkB,MAAM,CAAC,mBAAmB;AAC9C;AAEO,SAAS,eAAe,KAAmB;AAChD,MAAI,IAAI,SAAS,MAAO,QAAO,WAAW,SAAS,IAAI,IAAI,gBAAgB,IAAI,KAAK;AAEpF,MAAI,IAAI,SAAS,aAAc,QAAO,WAAW,SAAS,UAAU,IAAI,UAAU;AAElF,SAAO,WAAW,SAAS,OAAO;AACpC;AAEO,SAAS,kBAAkB,KAAmB;AACnD,MAAI,IAAI,SAAS,MAAO,QAAO,WAAW,YAAY,IAAI,IAAI,gBAAgB,IAAI,KAAK;AAEvF,MAAI,IAAI,SAAS,aAAc,QAAO,WAAW,YAAY,UAAU,IAAI,UAAU;AAErF,SAAO,WAAW,YAAY,OAAO;AACvC;AAEO,SAAS,qBAAqB,KAAmB;AACtD,MAAI,IAAI,SAAS,MAAO,QAAO,WAAW,eAAe,IAAI,IAAI,gBAAgB,IAAI,KAAK;AAE1F,MAAI,IAAI,SAAS,aAAc,QAAO,WAAW,eAAe,UAAU,IAAI,UAAU;AAExF,SAAO,WAAW,eAAe,OAAO;AAC1C;","names":[]}
@@ -1,6 +1,6 @@
1
1
  interface Props {
2
2
  className?: string;
3
- onMention: (e: React.MouseEvent) => void;
3
+ onMention: () => void;
4
4
  onAddComment: () => void;
5
5
  }
6
6
  export declare function ActionPanel({ className, onMention, onAddComment }: Props): import("react/jsx-runtime").JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"ActionPanel.d.ts","sourceRoot":"","sources":["../../../src/components/CommentEditor/ActionPanel.tsx"],"names":[],"mappings":"AAKA,UAAU,KAAK;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IACzC,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED,wBAAgB,WAAW,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,KAAK,2CAgBxE"}
1
+ {"version":3,"file":"ActionPanel.d.ts","sourceRoot":"","sources":["../../../src/components/CommentEditor/ActionPanel.tsx"],"names":[],"mappings":"AAMA,UAAU,KAAK;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,YAAY,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED,wBAAgB,WAAW,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,EAAE,EAAE,KAAK,2CAqCxE"}
@@ -1,14 +1,29 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { AtSign, SendHorizontal } from "lucide-react";
3
+ import { useRef, useEffect } from "react";
3
4
  import { IconButton } from "../IconButton";
4
5
  import { useTranslation } from "@payloadcms/ui";
5
6
  import { cn } from "../../utils/general/cn";
6
7
  function ActionPanel({ className, onMention, onAddComment }) {
7
8
  const { t } = useTranslation();
8
- return /* @__PURE__ */ jsxs("div", { className: cn("flex justify-end items-center gap-1 pt-2", className), "data-popup-prevent-close": true, children: [
9
- /* @__PURE__ */ jsx(IconButton, { title: "Mention user", onClick: onMention, children: /* @__PURE__ */ jsx(AtSign, { size: 16 }) }),
9
+ const wrapperRef = useRef(null);
10
+ useEffect(() => {
11
+ const wrapper = wrapperRef.current;
12
+ if (!wrapper) return;
13
+ const handleClick = (e) => {
14
+ e.stopPropagation();
15
+ const target = e.target;
16
+ const action = target.closest("[data-action]")?.getAttribute("data-action");
17
+ if (action === "mention") onMention();
18
+ if (action === "add-comment") onAddComment();
19
+ };
20
+ wrapper.addEventListener("click", handleClick);
21
+ return () => wrapper.removeEventListener("click", handleClick);
22
+ }, [onMention, onAddComment]);
23
+ return /* @__PURE__ */ jsxs("div", { ref: wrapperRef, className: cn("flex justify-end items-center gap-1 pt-2", className), children: [
24
+ /* @__PURE__ */ jsx(IconButton, { title: "Mention user", "data-action": "mention", children: /* @__PURE__ */ jsx(AtSign, { size: 16 }) }),
10
25
  /* @__PURE__ */ jsx("hr", { className: "w-px h-[20px] bg-(--theme-elevation-150) m-0" }),
11
- /* @__PURE__ */ jsx(IconButton, { variant: "primary", title: t("comments:comment"), onClick: onAddComment, children: /* @__PURE__ */ jsx(SendHorizontal, { size: 16 }) })
26
+ /* @__PURE__ */ jsx(IconButton, { variant: "primary", title: t("comments:comment"), "data-action": "add-comment", children: /* @__PURE__ */ jsx(SendHorizontal, { size: 16 }) })
12
27
  ] });
13
28
  }
14
29
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/components/CommentEditor/ActionPanel.tsx"],"sourcesContent":["import { AtSign, SendHorizontal } from \"lucide-react\";\nimport { IconButton } from \"../IconButton\";\nimport { useTranslation } from \"@payloadcms/ui\";\nimport { cn } from \"../../utils/general/cn\";\n\ninterface Props {\n className?: string;\n onMention: (e: React.MouseEvent) => void;\n onAddComment: () => void;\n}\n\nexport function ActionPanel({ className, onMention, onAddComment }: Props) {\n const { t } = useTranslation();\n\n return (\n <div className={cn(\"flex justify-end items-center gap-1 pt-2\", className)} data-popup-prevent-close>\n <IconButton title=\"Mention user\" onClick={onMention}>\n <AtSign size={16} />\n </IconButton>\n\n <hr className=\"w-px h-[20px] bg-(--theme-elevation-150) m-0\" />\n\n <IconButton variant=\"primary\" title={t(\"comments:comment\" as never)} onClick={onAddComment}>\n <SendHorizontal size={16} />\n </IconButton>\n </div>\n );\n}\n"],"mappings":"AAeI,SAEI,KAFJ;AAfJ,SAAS,QAAQ,sBAAsB;AACvC,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B,SAAS,UAAU;AAQZ,SAAS,YAAY,EAAE,WAAW,WAAW,aAAa,GAAU;AACzE,QAAM,EAAE,EAAE,IAAI,eAAe;AAE7B,SACE,qBAAC,SAAI,WAAW,GAAG,4CAA4C,SAAS,GAAG,4BAAwB,MACjG;AAAA,wBAAC,cAAW,OAAM,gBAAe,SAAS,WACxC,8BAAC,UAAO,MAAM,IAAI,GACpB;AAAA,IAEA,oBAAC,QAAG,WAAU,gDAA+C;AAAA,IAE7D,oBAAC,cAAW,SAAQ,WAAU,OAAO,EAAE,kBAA2B,GAAG,SAAS,cAC5E,8BAAC,kBAAe,MAAM,IAAI,GAC5B;AAAA,KACF;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../../src/components/CommentEditor/ActionPanel.tsx"],"sourcesContent":["import { AtSign, SendHorizontal } from \"lucide-react\";\nimport { useRef, useEffect } from \"react\";\nimport { IconButton } from \"../IconButton\";\nimport { useTranslation } from \"@payloadcms/ui\";\nimport { cn } from \"../../utils/general/cn\";\n\ninterface Props {\n className?: string;\n onMention: () => void;\n onAddComment: () => void;\n}\n\nexport function ActionPanel({ className, onMention, onAddComment }: Props) {\n const { t } = useTranslation();\n const wrapperRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const wrapper = wrapperRef.current;\n if (!wrapper) return;\n\n const handleClick = (e: MouseEvent) => {\n e.stopPropagation();\n\n const target = e.target as HTMLElement;\n\n const action = target.closest(\"[data-action]\")?.getAttribute(\"data-action\");\n\n if (action === \"mention\") onMention();\n if (action === \"add-comment\") onAddComment();\n };\n\n wrapper.addEventListener(\"click\", handleClick);\n\n return () => wrapper.removeEventListener(\"click\", handleClick);\n }, [onMention, onAddComment]);\n\n return (\n <div ref={wrapperRef} className={cn(\"flex justify-end items-center gap-1 pt-2\", className)}>\n <IconButton title=\"Mention user\" data-action=\"mention\">\n <AtSign size={16} />\n </IconButton>\n\n <hr className=\"w-px h-[20px] bg-(--theme-elevation-150) m-0\" />\n\n <IconButton variant=\"primary\" title={t(\"comments:comment\" as never)} data-action=\"add-comment\">\n <SendHorizontal size={16} />\n </IconButton>\n </div>\n );\n}\n"],"mappings":"AAqCI,SAEI,KAFJ;AArCJ,SAAS,QAAQ,sBAAsB;AACvC,SAAS,QAAQ,iBAAiB;AAClC,SAAS,kBAAkB;AAC3B,SAAS,sBAAsB;AAC/B,SAAS,UAAU;AAQZ,SAAS,YAAY,EAAE,WAAW,WAAW,aAAa,GAAU;AACzE,QAAM,EAAE,EAAE,IAAI,eAAe;AAC7B,QAAM,aAAa,OAAuB,IAAI;AAE9C,YAAU,MAAM;AACd,UAAM,UAAU,WAAW;AAC3B,QAAI,CAAC,QAAS;AAEd,UAAM,cAAc,CAAC,MAAkB;AACrC,QAAE,gBAAgB;AAElB,YAAM,SAAS,EAAE;AAEjB,YAAM,SAAS,OAAO,QAAQ,eAAe,GAAG,aAAa,aAAa;AAE1E,UAAI,WAAW,UAAW,WAAU;AACpC,UAAI,WAAW,cAAe,cAAa;AAAA,IAC7C;AAEA,YAAQ,iBAAiB,SAAS,WAAW;AAE7C,WAAO,MAAM,QAAQ,oBAAoB,SAAS,WAAW;AAAA,EAC/D,GAAG,CAAC,WAAW,YAAY,CAAC;AAE5B,SACE,qBAAC,SAAI,KAAK,YAAY,WAAW,GAAG,4CAA4C,SAAS,GACvF;AAAA,wBAAC,cAAW,OAAM,gBAAe,eAAY,WAC3C,8BAAC,UAAO,MAAM,IAAI,GACpB;AAAA,IAEA,oBAAC,QAAG,WAAU,gDAA+C;AAAA,IAE7D,oBAAC,cAAW,SAAQ,WAAU,OAAO,EAAE,kBAA2B,GAAG,eAAY,eAC/E,8BAAC,kBAAe,MAAM,IAAI,GAC5B;AAAA,KACF;AAEJ;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/CommentEditor/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAyC,KAAK,SAAS,EAAmB,MAAM,OAAO,CAAC;AAc/F,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,UAAU,kBAAkB;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;IAC5C,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,SAAS,EACT,WAAW,EAAE,eAAe,EAC5B,GAAG,EACH,SAAS,EACT,UAAU,EACV,cAAc,EACd,UAAU,EACV,mBAAmB,EACnB,YAAY,EACZ,aAAa,GACd,EAAE,kBAAkB,2CAwRpB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/CommentEditor/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAyC,KAAK,SAAS,EAAmB,MAAM,OAAO,CAAC;AAe/F,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED,UAAU,kBAAkB;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,SAAS,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;IAC5C,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mBAAmB,CAAC,EAAE,MAAM,IAAI,CAAC;IACjC,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;CAC5B;AAED,wBAAgB,aAAa,CAAC,EAC5B,QAAQ,EACR,SAAS,EACT,WAAW,EAAE,eAAe,EAC5B,GAAG,EACH,SAAS,EACT,UAAU,EACV,cAAc,EACd,UAAU,EACV,mBAAmB,EACnB,YAAY,EACZ,aAAa,GACd,EAAE,kBAAkB,2CAyRpB"}