@btst/stack 2.7.0 → 2.8.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 (181) hide show
  1. package/README.md +1 -0
  2. package/dist/packages/stack/src/plugins/blog/client/components/loading/post-navigation-skeleton.cjs +13 -0
  3. package/dist/packages/stack/src/plugins/blog/client/components/loading/post-navigation-skeleton.mjs +11 -0
  4. package/dist/packages/stack/src/plugins/blog/client/components/loading/recent-posts-carousel-skeleton.cjs +17 -0
  5. package/dist/packages/stack/src/plugins/blog/client/components/loading/recent-posts-carousel-skeleton.mjs +15 -0
  6. package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.internal.cjs +18 -7
  7. package/dist/packages/stack/src/plugins/blog/client/components/pages/post-page.internal.mjs +18 -7
  8. package/dist/packages/stack/src/plugins/blog/client/components/shared/post-navigation.cjs +48 -52
  9. package/dist/packages/stack/src/plugins/blog/client/components/shared/post-navigation.mjs +49 -53
  10. package/dist/packages/stack/src/plugins/blog/client/components/shared/recent-posts-carousel.cjs +34 -37
  11. package/dist/packages/stack/src/plugins/blog/client/components/shared/recent-posts-carousel.mjs +35 -38
  12. package/dist/packages/stack/src/plugins/blog/client/hooks/blog-hooks.cjs +4 -21
  13. package/dist/packages/stack/src/plugins/blog/client/hooks/blog-hooks.mjs +4 -21
  14. package/dist/packages/stack/src/plugins/comments/api/getters.cjs +284 -0
  15. package/dist/packages/stack/src/plugins/comments/api/getters.mjs +280 -0
  16. package/dist/packages/stack/src/plugins/comments/api/mutations.cjs +118 -0
  17. package/dist/packages/stack/src/plugins/comments/api/mutations.mjs +112 -0
  18. package/dist/packages/stack/src/plugins/comments/api/plugin.cjs +335 -0
  19. package/dist/packages/stack/src/plugins/comments/api/plugin.mjs +333 -0
  20. package/dist/packages/stack/src/plugins/comments/api/query-key-defs.cjs +60 -0
  21. package/dist/packages/stack/src/plugins/comments/api/query-key-defs.mjs +55 -0
  22. package/dist/packages/stack/src/plugins/comments/api/serializers.cjs +23 -0
  23. package/dist/packages/stack/src/plugins/comments/api/serializers.mjs +21 -0
  24. package/dist/packages/stack/src/plugins/comments/client/components/comment-count.cjs +46 -0
  25. package/dist/packages/stack/src/plugins/comments/client/components/comment-count.mjs +44 -0
  26. package/dist/packages/stack/src/plugins/comments/client/components/comment-form.cjs +86 -0
  27. package/dist/packages/stack/src/plugins/comments/client/components/comment-form.mjs +84 -0
  28. package/dist/packages/stack/src/plugins/comments/client/components/comment-thread.cjs +540 -0
  29. package/dist/packages/stack/src/plugins/comments/client/components/comment-thread.mjs +538 -0
  30. package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.cjs +64 -0
  31. package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.internal.cjs +426 -0
  32. package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.internal.mjs +424 -0
  33. package/dist/packages/stack/src/plugins/comments/client/components/pages/moderation-page.mjs +62 -0
  34. package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.cjs +66 -0
  35. package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.internal.cjs +256 -0
  36. package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.internal.mjs +254 -0
  37. package/dist/packages/stack/src/plugins/comments/client/components/pages/my-comments-page.mjs +64 -0
  38. package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.cjs +86 -0
  39. package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.internal.cjs +191 -0
  40. package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.internal.mjs +189 -0
  41. package/dist/packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.mjs +84 -0
  42. package/dist/packages/stack/src/plugins/comments/client/components/shared/page-wrapper.cjs +27 -0
  43. package/dist/packages/stack/src/plugins/comments/client/components/shared/page-wrapper.mjs +25 -0
  44. package/dist/packages/stack/src/plugins/comments/client/components/shared/pagination.cjs +37 -0
  45. package/dist/packages/stack/src/plugins/comments/client/components/shared/pagination.mjs +35 -0
  46. package/dist/packages/stack/src/plugins/comments/client/hooks/use-comments.cjs +476 -0
  47. package/dist/packages/stack/src/plugins/comments/client/hooks/use-comments.mjs +464 -0
  48. package/dist/packages/stack/src/plugins/comments/client/localization/comments-moderation.cjs +67 -0
  49. package/dist/packages/stack/src/plugins/comments/client/localization/comments-moderation.mjs +65 -0
  50. package/dist/packages/stack/src/plugins/comments/client/localization/comments-my.cjs +27 -0
  51. package/dist/packages/stack/src/plugins/comments/client/localization/comments-my.mjs +25 -0
  52. package/dist/packages/stack/src/plugins/comments/client/localization/comments-thread.cjs +30 -0
  53. package/dist/packages/stack/src/plugins/comments/client/localization/comments-thread.mjs +28 -0
  54. package/dist/packages/stack/src/plugins/comments/client/localization/index.cjs +13 -0
  55. package/dist/packages/stack/src/plugins/comments/client/localization/index.mjs +11 -0
  56. package/dist/packages/stack/src/plugins/comments/client/plugin.cjs +116 -0
  57. package/dist/packages/stack/src/plugins/comments/client/plugin.mjs +114 -0
  58. package/dist/packages/stack/src/plugins/comments/client/utils.cjs +41 -0
  59. package/dist/packages/stack/src/plugins/comments/client/utils.mjs +37 -0
  60. package/dist/packages/stack/src/plugins/comments/db.cjs +75 -0
  61. package/dist/packages/stack/src/plugins/comments/db.mjs +73 -0
  62. package/dist/packages/stack/src/plugins/comments/schemas.cjs +45 -0
  63. package/dist/packages/stack/src/plugins/comments/schemas.mjs +38 -0
  64. package/dist/packages/stack/src/plugins/kanban/client/components/forms/task-form.cjs +0 -1
  65. package/dist/packages/stack/src/plugins/kanban/client/components/forms/task-form.mjs +0 -1
  66. package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.internal.cjs +39 -22
  67. package/dist/packages/stack/src/plugins/kanban/client/components/pages/board-page.internal.mjs +40 -23
  68. package/dist/packages/ui/src/components/avatar.mjs +1 -1
  69. package/dist/packages/ui/src/components/pagination-controls.cjs +64 -0
  70. package/dist/packages/ui/src/components/pagination-controls.mjs +62 -0
  71. package/dist/packages/ui/src/components/when-visible.cjs +39 -0
  72. package/dist/packages/ui/src/components/when-visible.mjs +37 -0
  73. package/dist/plugins/blog/client/hooks/index.d.cts +1 -1
  74. package/dist/plugins/blog/client/hooks/index.d.mts +1 -1
  75. package/dist/plugins/blog/client/hooks/index.d.ts +1 -1
  76. package/dist/plugins/blog/client/index.d.cts +24 -2
  77. package/dist/plugins/blog/client/index.d.mts +24 -2
  78. package/dist/plugins/blog/client/index.d.ts +24 -2
  79. package/dist/plugins/comments/api/index.cjs +21 -0
  80. package/dist/plugins/comments/api/index.d.cts +126 -0
  81. package/dist/plugins/comments/api/index.d.mts +126 -0
  82. package/dist/plugins/comments/api/index.d.ts +126 -0
  83. package/dist/plugins/comments/api/index.mjs +5 -0
  84. package/dist/plugins/comments/client/components/index.cjs +15 -0
  85. package/dist/plugins/comments/client/components/index.d.cts +125 -0
  86. package/dist/plugins/comments/client/components/index.d.mts +125 -0
  87. package/dist/plugins/comments/client/components/index.d.ts +125 -0
  88. package/dist/plugins/comments/client/components/index.mjs +5 -0
  89. package/dist/plugins/comments/client/hooks/index.cjs +17 -0
  90. package/dist/plugins/comments/client/hooks/index.d.cts +200 -0
  91. package/dist/plugins/comments/client/hooks/index.d.mts +200 -0
  92. package/dist/plugins/comments/client/hooks/index.d.ts +200 -0
  93. package/dist/plugins/comments/client/hooks/index.mjs +1 -0
  94. package/dist/plugins/comments/client/index.cjs +9 -0
  95. package/dist/plugins/comments/client/index.d.cts +262 -0
  96. package/dist/plugins/comments/client/index.d.mts +262 -0
  97. package/dist/plugins/comments/client/index.d.ts +262 -0
  98. package/dist/plugins/comments/client/index.mjs +2 -0
  99. package/dist/plugins/comments/client.css +2 -0
  100. package/dist/plugins/comments/query-keys.cjs +113 -0
  101. package/dist/plugins/comments/query-keys.d.cts +71 -0
  102. package/dist/plugins/comments/query-keys.d.mts +71 -0
  103. package/dist/plugins/comments/query-keys.d.ts +71 -0
  104. package/dist/plugins/comments/query-keys.mjs +111 -0
  105. package/dist/plugins/comments/style.css +15 -0
  106. package/dist/plugins/kanban/api/index.d.cts +1 -1
  107. package/dist/plugins/kanban/api/index.d.mts +1 -1
  108. package/dist/plugins/kanban/api/index.d.ts +1 -1
  109. package/dist/plugins/kanban/client/hooks/index.d.cts +1 -1
  110. package/dist/plugins/kanban/client/hooks/index.d.mts +1 -1
  111. package/dist/plugins/kanban/client/hooks/index.d.ts +1 -1
  112. package/dist/plugins/kanban/client/index.d.cts +1 -1
  113. package/dist/plugins/kanban/client/index.d.mts +1 -1
  114. package/dist/plugins/kanban/client/index.d.ts +1 -1
  115. package/dist/plugins/kanban/query-keys.d.cts +1 -1
  116. package/dist/plugins/kanban/query-keys.d.mts +1 -1
  117. package/dist/plugins/kanban/query-keys.d.ts +1 -1
  118. package/dist/shared/{stack.FeaWkglm.d.ts → stack.BxFl46lB.d.cts} +24 -1
  119. package/dist/shared/stack.C-b3Sn8j.d.cts +142 -0
  120. package/dist/shared/stack.C-b3Sn8j.d.mts +142 -0
  121. package/dist/shared/stack.C-b3Sn8j.d.ts +142 -0
  122. package/dist/shared/stack.CJE9sAjV.d.ts +335 -0
  123. package/dist/shared/stack.CmHRdhl8.d.cts +335 -0
  124. package/dist/shared/{stack.CNLHlv7r.d.mts → stack.DOZ1EXjM.d.mts} +6 -12
  125. package/dist/shared/{stack.FeaWkglm.d.mts → stack.DRpeDS6X.d.ts} +24 -1
  126. package/dist/shared/{stack.CQAZwXhV.d.cts → stack.DX-tQ93o.d.cts} +6 -12
  127. package/dist/shared/stack.Dcz6636A.d.mts +335 -0
  128. package/dist/shared/{stack.FeaWkglm.d.cts → stack.Jb0kQDJC.d.mts} +24 -1
  129. package/dist/shared/stack.Ldfkr5b2.d.cts +112 -0
  130. package/dist/shared/stack.Ldfkr5b2.d.mts +112 -0
  131. package/dist/shared/stack.Ldfkr5b2.d.ts +112 -0
  132. package/dist/shared/{stack.D3BsrpAz.d.ts → stack.VF6FhyZw.d.ts} +6 -12
  133. package/package.json +67 -2
  134. package/src/plugins/blog/client/components/loading/post-navigation-skeleton.tsx +10 -0
  135. package/src/plugins/blog/client/components/loading/recent-posts-carousel-skeleton.tsx +18 -0
  136. package/src/plugins/blog/client/components/pages/post-page.internal.tsx +23 -8
  137. package/src/plugins/blog/client/components/shared/post-navigation.tsx +0 -5
  138. package/src/plugins/blog/client/components/shared/recent-posts-carousel.tsx +1 -5
  139. package/src/plugins/blog/client/hooks/blog-hooks.tsx +8 -33
  140. package/src/plugins/blog/client/overrides.ts +26 -1
  141. package/src/plugins/cms/client/components/shared/pagination.tsx +14 -42
  142. package/src/plugins/comments/api/getters.ts +444 -0
  143. package/src/plugins/comments/api/index.ts +21 -0
  144. package/src/plugins/comments/api/mutations.ts +206 -0
  145. package/src/plugins/comments/api/plugin.ts +628 -0
  146. package/src/plugins/comments/api/query-key-defs.ts +143 -0
  147. package/src/plugins/comments/api/serializers.ts +37 -0
  148. package/src/plugins/comments/client/components/comment-count.tsx +66 -0
  149. package/src/plugins/comments/client/components/comment-form.tsx +112 -0
  150. package/src/plugins/comments/client/components/comment-thread.tsx +799 -0
  151. package/src/plugins/comments/client/components/index.tsx +11 -0
  152. package/src/plugins/comments/client/components/pages/moderation-page.internal.tsx +550 -0
  153. package/src/plugins/comments/client/components/pages/moderation-page.tsx +70 -0
  154. package/src/plugins/comments/client/components/pages/my-comments-page.internal.tsx +367 -0
  155. package/src/plugins/comments/client/components/pages/my-comments-page.tsx +72 -0
  156. package/src/plugins/comments/client/components/pages/resource-comments-page.internal.tsx +225 -0
  157. package/src/plugins/comments/client/components/pages/resource-comments-page.tsx +97 -0
  158. package/src/plugins/comments/client/components/shared/page-wrapper.tsx +32 -0
  159. package/src/plugins/comments/client/components/shared/pagination.tsx +44 -0
  160. package/src/plugins/comments/client/hooks/index.tsx +13 -0
  161. package/src/plugins/comments/client/hooks/use-comments.tsx +717 -0
  162. package/src/plugins/comments/client/index.ts +14 -0
  163. package/src/plugins/comments/client/localization/comments-moderation.ts +75 -0
  164. package/src/plugins/comments/client/localization/comments-my.ts +32 -0
  165. package/src/plugins/comments/client/localization/comments-thread.ts +32 -0
  166. package/src/plugins/comments/client/localization/index.ts +11 -0
  167. package/src/plugins/comments/client/overrides.ts +164 -0
  168. package/src/plugins/comments/client/plugin.tsx +195 -0
  169. package/src/plugins/comments/client/utils.ts +67 -0
  170. package/src/plugins/comments/client.css +2 -0
  171. package/src/plugins/comments/db.ts +77 -0
  172. package/src/plugins/comments/query-keys.ts +189 -0
  173. package/src/plugins/comments/schemas.ts +72 -0
  174. package/src/plugins/comments/style.css +15 -0
  175. package/src/plugins/comments/types.ts +73 -0
  176. package/src/plugins/kanban/client/components/forms/task-form.tsx +0 -1
  177. package/src/plugins/kanban/client/components/pages/board-page.internal.tsx +46 -27
  178. package/src/plugins/kanban/client/overrides.ts +27 -1
  179. package/dist/shared/{stack.Rtcvl8sS.d.cts → stack.BOokfhZD.d.cts} +3 -3
  180. package/dist/shared/{stack.D4Cea8II.d.ts → stack.BvCR4-9H.d.ts} +3 -3
  181. package/dist/shared/{stack.HE_IvqV5.d.mts → stack.CWxAl9K3.d.mts} +3 -3
@@ -0,0 +1,125 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ComponentType } from 'react';
3
+ import { C as CommentsLocalization } from '../../../../shared/stack.Ldfkr5b2.js';
4
+
5
+ /** Custom input component props */
6
+ interface CommentInputProps {
7
+ value: string;
8
+ onChange: (value: string) => void;
9
+ disabled?: boolean;
10
+ placeholder?: string;
11
+ }
12
+ /** Custom renderer component props */
13
+ interface CommentRendererProps {
14
+ body: string;
15
+ }
16
+ /** Override slot for custom input + renderer */
17
+ interface CommentComponents {
18
+ Input?: ComponentType<CommentInputProps>;
19
+ Renderer?: ComponentType<CommentRendererProps>;
20
+ }
21
+ interface CommentThreadProps {
22
+ /** The resource this thread is attached to (e.g. post slug, task ID) */
23
+ resourceId: string;
24
+ /** Discriminates resources across plugins (e.g. "blog-post", "kanban-task") */
25
+ resourceType: string;
26
+ /** Base URL for API calls */
27
+ apiBaseURL: string;
28
+ /** Path where the API is mounted */
29
+ apiBasePath: string;
30
+ /** Currently authenticated user ID. Omit for read-only / unauthenticated. */
31
+ currentUserId?: string;
32
+ /**
33
+ * URL to redirect unauthenticated users to.
34
+ * When provided and currentUserId is absent, shows a "Please login to comment" prompt.
35
+ */
36
+ loginHref?: string;
37
+ /** Optional HTTP headers for API calls (e.g. forwarding cookies) */
38
+ headers?: HeadersInit;
39
+ /** Swap in custom Input / Renderer components */
40
+ components?: CommentComponents;
41
+ /** Optional className applied to the root wrapper */
42
+ className?: string;
43
+ /** Localization strings — defaults to English */
44
+ localization?: Partial<CommentsLocalization>;
45
+ /**
46
+ * Number of top-level comments to load per page.
47
+ * Clicking "Load more" fetches the next page. Default: 10.
48
+ */
49
+ pageSize?: number;
50
+ /**
51
+ * When false, the comment form and reply buttons are hidden.
52
+ * Overrides the global `allowPosting` from `CommentsPluginOverrides`.
53
+ * Defaults to true.
54
+ */
55
+ allowPosting?: boolean;
56
+ /**
57
+ * When false, the edit button is hidden on comment cards.
58
+ * Overrides the global `allowEditing` from `CommentsPluginOverrides`.
59
+ * Defaults to true.
60
+ */
61
+ allowEditing?: boolean;
62
+ }
63
+ declare function CommentThread(props: CommentThreadProps): react_jsx_runtime.JSX.Element;
64
+
65
+ interface CommentCountProps {
66
+ resourceId: string;
67
+ resourceType: string;
68
+ /** Only count approved comments (default) */
69
+ status?: "pending" | "approved" | "spam";
70
+ apiBaseURL: string;
71
+ apiBasePath: string;
72
+ headers?: HeadersInit;
73
+ /** Optional className for the wrapper span */
74
+ className?: string;
75
+ }
76
+ /**
77
+ * Lightweight badge showing the comment count for a resource.
78
+ * Does not mount a full comment thread — suitable for post list cards.
79
+ *
80
+ * @example
81
+ * ```tsx
82
+ * <CommentCount
83
+ * resourceId={post.slug}
84
+ * resourceType="blog-post"
85
+ * apiBaseURL="https://example.com"
86
+ * apiBasePath="/api/data"
87
+ * />
88
+ * ```
89
+ */
90
+ declare function CommentCount({ resourceId, resourceType, status, apiBaseURL, apiBasePath, headers, className, }: CommentCountProps): react_jsx_runtime.JSX.Element;
91
+
92
+ interface CommentFormProps {
93
+ /** Current user's ID — required to post */
94
+ authorId: string;
95
+ /** Optional parent comment ID for replies */
96
+ parentId?: string | null;
97
+ /** Initial body value (for editing) */
98
+ initialBody?: string;
99
+ /** Label for the submit button */
100
+ submitLabel?: string;
101
+ /** Called when form is submitted */
102
+ onSubmit: (body: string) => Promise<void>;
103
+ /** Called when cancel is clicked (shows Cancel button when provided) */
104
+ onCancel?: () => void;
105
+ /** Custom input component — defaults to a plain Textarea */
106
+ InputComponent?: ComponentType<{
107
+ value: string;
108
+ onChange: (value: string) => void;
109
+ disabled?: boolean;
110
+ placeholder?: string;
111
+ }>;
112
+ /** Localization strings */
113
+ localization?: Partial<CommentsLocalization>;
114
+ }
115
+ declare function CommentForm({ authorId: _authorId, initialBody, submitLabel, onSubmit, onCancel, InputComponent, localization: localizationProp, }: CommentFormProps): react_jsx_runtime.JSX.Element;
116
+
117
+ declare function ModerationPageComponent(): react_jsx_runtime.JSX.Element;
118
+
119
+ declare function ResourceCommentsPageComponent({ resourceId, resourceType, }: {
120
+ resourceId: string;
121
+ resourceType: string;
122
+ }): react_jsx_runtime.JSX.Element;
123
+
124
+ export { CommentCount, CommentForm, CommentThread, ModerationPageComponent, ResourceCommentsPageComponent };
125
+ export type { CommentComponents, CommentCountProps, CommentFormProps, CommentInputProps, CommentRendererProps, CommentThreadProps };
@@ -0,0 +1,5 @@
1
+ export { CommentThread } from '../../../../packages/stack/src/plugins/comments/client/components/comment-thread.mjs';
2
+ export { CommentCount } from '../../../../packages/stack/src/plugins/comments/client/components/comment-count.mjs';
3
+ export { CommentForm } from '../../../../packages/stack/src/plugins/comments/client/components/comment-form.mjs';
4
+ export { ModerationPageComponent } from '../../../../packages/stack/src/plugins/comments/client/components/pages/moderation-page.mjs';
5
+ export { ResourceCommentsPageComponent } from '../../../../packages/stack/src/plugins/comments/client/components/pages/resource-comments-page.mjs';
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+
3
+ const useComments = require('../../../../packages/stack/src/plugins/comments/client/hooks/use-comments.cjs');
4
+
5
+
6
+
7
+ exports.useApproveComment = useComments.useApproveComment;
8
+ exports.useCommentCount = useComments.useCommentCount;
9
+ exports.useComments = useComments.useComments;
10
+ exports.useDeleteComment = useComments.useDeleteComment;
11
+ exports.useInfiniteComments = useComments.useInfiniteComments;
12
+ exports.usePostComment = useComments.usePostComment;
13
+ exports.useSuspenseComments = useComments.useSuspenseComments;
14
+ exports.useSuspenseModerationComments = useComments.useSuspenseModerationComments;
15
+ exports.useToggleLike = useComments.useToggleLike;
16
+ exports.useUpdateComment = useComments.useUpdateComment;
17
+ exports.useUpdateCommentStatus = useComments.useUpdateCommentStatus;
@@ -0,0 +1,200 @@
1
+ import { C as CommentListResult, S as SerializedComment, a as CommentsThreadDiscriminator } from '../../../../shared/stack.C-b3Sn8j.cjs';
2
+ import * as _tanstack_react_query from '@tanstack/react-query';
3
+ import { InfiniteData } from '@tanstack/react-query';
4
+
5
+ interface CommentsClientConfig {
6
+ apiBaseURL: string;
7
+ apiBasePath: string;
8
+ headers?: HeadersInit;
9
+ }
10
+ /**
11
+ * Fetch a paginated list of comments for a resource.
12
+ * Returns approved comments by default.
13
+ */
14
+ declare function useComments(config: CommentsClientConfig, params: {
15
+ resourceId?: string;
16
+ resourceType?: string;
17
+ parentId?: string | null;
18
+ status?: "pending" | "approved" | "spam";
19
+ currentUserId?: string;
20
+ authorId?: string;
21
+ sort?: "asc" | "desc";
22
+ limit?: number;
23
+ offset?: number;
24
+ }, options?: {
25
+ enabled?: boolean;
26
+ }): {
27
+ data: CommentListResult | undefined;
28
+ comments: SerializedComment[];
29
+ total: number;
30
+ isLoading: boolean;
31
+ isFetching: boolean;
32
+ error: Error | null;
33
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<CommentListResult, Error>>;
34
+ };
35
+ /**
36
+ * useSuspenseQuery version — for use in .internal.tsx files.
37
+ */
38
+ declare function useSuspenseComments(config: CommentsClientConfig, params: {
39
+ resourceId?: string;
40
+ resourceType?: string;
41
+ parentId?: string | null;
42
+ status?: "pending" | "approved" | "spam";
43
+ currentUserId?: string;
44
+ authorId?: string;
45
+ sort?: "asc" | "desc";
46
+ limit?: number;
47
+ offset?: number;
48
+ }): {
49
+ comments: SerializedComment[];
50
+ total: number;
51
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<CommentListResult, Error>>;
52
+ };
53
+ /**
54
+ * Page-based variant for the moderation dashboard.
55
+ * Uses useSuspenseQuery with explicit offset so the table always shows exactly
56
+ * one page of results and navigation is handled by Prev / Next controls.
57
+ */
58
+ declare function useSuspenseModerationComments(config: CommentsClientConfig, params: {
59
+ status?: "pending" | "approved" | "spam";
60
+ limit?: number;
61
+ page?: number;
62
+ }): {
63
+ comments: SerializedComment[];
64
+ total: number;
65
+ limit: number;
66
+ offset: number;
67
+ totalPages: number;
68
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<CommentListResult, Error>>;
69
+ };
70
+ /**
71
+ * Infinite-scroll variant for the CommentThread component.
72
+ * Uses the "commentsThread" factory namespace (separate from the plain
73
+ * useComments / useSuspenseComments queries) to avoid InfiniteData shape conflicts.
74
+ *
75
+ * Mirrors the blog's usePosts pattern: spread the factory base query into
76
+ * useInfiniteQuery, drive pages via pageParam, and derive hasMore from server total.
77
+ */
78
+ declare function useInfiniteComments(config: CommentsClientConfig, params: {
79
+ resourceId: string;
80
+ resourceType: string;
81
+ parentId?: string | null;
82
+ status?: "pending" | "approved" | "spam";
83
+ currentUserId?: string;
84
+ pageSize?: number;
85
+ }, options?: {
86
+ enabled?: boolean;
87
+ }): {
88
+ comments: SerializedComment[];
89
+ total: number;
90
+ queryKey: readonly ["commentsThread", "list", CommentsThreadDiscriminator];
91
+ isLoading: boolean;
92
+ isFetching: boolean;
93
+ loadMore: (options?: _tanstack_react_query.FetchNextPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<InfiniteData<CommentListResult, unknown>, Error>>;
94
+ hasMore: boolean;
95
+ isLoadingMore: boolean;
96
+ error: Error | null;
97
+ };
98
+ /**
99
+ * Fetch the approved comment count for a resource.
100
+ */
101
+ declare function useCommentCount(config: CommentsClientConfig, params: {
102
+ resourceId: string;
103
+ resourceType: string;
104
+ status?: "pending" | "approved" | "spam";
105
+ }): {
106
+ count: number;
107
+ isLoading: boolean;
108
+ error: Error | null;
109
+ };
110
+ /**
111
+ * Post a new comment with optimistic update.
112
+ * When autoApprove is false the optimistic entry shows as "pending" — visible
113
+ * only to the comment's own author via the `currentUserId` match in the UI.
114
+ *
115
+ * Pass `infiniteKey` (from `useInfiniteComments`) when the thread uses an
116
+ * infinite query so the optimistic update targets InfiniteData<CommentListResult>
117
+ * instead of a plain CommentListResult cache entry.
118
+ */
119
+ declare function usePostComment(config: CommentsClientConfig, params: {
120
+ resourceId: string;
121
+ resourceType: string;
122
+ currentUserId?: string;
123
+ /** When provided, optimistic updates target this infinite-query cache key. */
124
+ infiniteKey?: readonly unknown[];
125
+ /**
126
+ * Page size used by the corresponding `useInfiniteComments` call.
127
+ * Used only when the infinite-query cache is empty at the time of the
128
+ * optimistic update — ensures `getNextPageParam` computes the correct
129
+ * `nextOffset` from `lastPage.limit` instead of a hardcoded fallback.
130
+ */
131
+ pageSize?: number;
132
+ }): _tanstack_react_query.UseMutationResult<SerializedComment, Error, {
133
+ body: string;
134
+ parentId?: string | null;
135
+ limit?: number;
136
+ offset?: number;
137
+ }, {
138
+ previous: InfiniteData<CommentListResult, unknown> | undefined;
139
+ isInfinite: true;
140
+ listKey: readonly unknown[];
141
+ optimisticId: string;
142
+ } | {
143
+ previous: CommentListResult | undefined;
144
+ isInfinite: false;
145
+ listKey: readonly unknown[];
146
+ optimisticId: string;
147
+ }>;
148
+ /**
149
+ * Edit the body of an existing comment.
150
+ */
151
+ declare function useUpdateComment(config: CommentsClientConfig): _tanstack_react_query.UseMutationResult<SerializedComment, Error, {
152
+ id: string;
153
+ body: string;
154
+ }, unknown>;
155
+ /**
156
+ * Approve a comment (set status to "approved"). Admin use.
157
+ */
158
+ declare function useApproveComment(config: CommentsClientConfig): _tanstack_react_query.UseMutationResult<SerializedComment, Error, string, unknown>;
159
+ /**
160
+ * Update comment status (pending / approved / spam). Admin use.
161
+ */
162
+ declare function useUpdateCommentStatus(config: CommentsClientConfig): _tanstack_react_query.UseMutationResult<SerializedComment, Error, {
163
+ id: string;
164
+ status: "pending" | "approved" | "spam";
165
+ }, unknown>;
166
+ /**
167
+ * Delete a comment. Admin use.
168
+ */
169
+ declare function useDeleteComment(config: CommentsClientConfig): _tanstack_react_query.UseMutationResult<{
170
+ success: boolean;
171
+ }, Error, string, unknown>;
172
+ /**
173
+ * Toggle a like on a comment with optimistic update.
174
+ *
175
+ * Pass `infiniteKey` (from `useInfiniteComments`) for top-level thread comments
176
+ * so the optimistic update targets InfiniteData<CommentListResult> instead of
177
+ * a plain CommentListResult cache entry.
178
+ */
179
+ declare function useToggleLike(config: CommentsClientConfig, params: {
180
+ resourceId: string;
181
+ resourceType: string;
182
+ /** parentId of the comment being liked — must match the parentId used by
183
+ * useComments so the optimistic setQueryData hits the correct cache entry.
184
+ * Pass `null` for top-level comments, or the parent comment ID for replies. */
185
+ parentId?: string | null;
186
+ currentUserId?: string;
187
+ /** When the comment lives in an infinite thread, pass the thread's query key
188
+ * so the optimistic update targets the correct InfiniteData cache entry. */
189
+ infiniteKey?: readonly unknown[];
190
+ }): _tanstack_react_query.UseMutationResult<{
191
+ likes: number;
192
+ isLiked: boolean;
193
+ }, Error, {
194
+ commentId: string;
195
+ authorId: string;
196
+ }, {
197
+ previous: CommentListResult | InfiniteData<CommentListResult, unknown> | undefined;
198
+ }>;
199
+
200
+ export { useApproveComment, useCommentCount, useComments, useDeleteComment, useInfiniteComments, usePostComment, useSuspenseComments, useSuspenseModerationComments, useToggleLike, useUpdateComment, useUpdateCommentStatus };
@@ -0,0 +1,200 @@
1
+ import { C as CommentListResult, S as SerializedComment, a as CommentsThreadDiscriminator } from '../../../../shared/stack.C-b3Sn8j.mjs';
2
+ import * as _tanstack_react_query from '@tanstack/react-query';
3
+ import { InfiniteData } from '@tanstack/react-query';
4
+
5
+ interface CommentsClientConfig {
6
+ apiBaseURL: string;
7
+ apiBasePath: string;
8
+ headers?: HeadersInit;
9
+ }
10
+ /**
11
+ * Fetch a paginated list of comments for a resource.
12
+ * Returns approved comments by default.
13
+ */
14
+ declare function useComments(config: CommentsClientConfig, params: {
15
+ resourceId?: string;
16
+ resourceType?: string;
17
+ parentId?: string | null;
18
+ status?: "pending" | "approved" | "spam";
19
+ currentUserId?: string;
20
+ authorId?: string;
21
+ sort?: "asc" | "desc";
22
+ limit?: number;
23
+ offset?: number;
24
+ }, options?: {
25
+ enabled?: boolean;
26
+ }): {
27
+ data: CommentListResult | undefined;
28
+ comments: SerializedComment[];
29
+ total: number;
30
+ isLoading: boolean;
31
+ isFetching: boolean;
32
+ error: Error | null;
33
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<CommentListResult, Error>>;
34
+ };
35
+ /**
36
+ * useSuspenseQuery version — for use in .internal.tsx files.
37
+ */
38
+ declare function useSuspenseComments(config: CommentsClientConfig, params: {
39
+ resourceId?: string;
40
+ resourceType?: string;
41
+ parentId?: string | null;
42
+ status?: "pending" | "approved" | "spam";
43
+ currentUserId?: string;
44
+ authorId?: string;
45
+ sort?: "asc" | "desc";
46
+ limit?: number;
47
+ offset?: number;
48
+ }): {
49
+ comments: SerializedComment[];
50
+ total: number;
51
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<CommentListResult, Error>>;
52
+ };
53
+ /**
54
+ * Page-based variant for the moderation dashboard.
55
+ * Uses useSuspenseQuery with explicit offset so the table always shows exactly
56
+ * one page of results and navigation is handled by Prev / Next controls.
57
+ */
58
+ declare function useSuspenseModerationComments(config: CommentsClientConfig, params: {
59
+ status?: "pending" | "approved" | "spam";
60
+ limit?: number;
61
+ page?: number;
62
+ }): {
63
+ comments: SerializedComment[];
64
+ total: number;
65
+ limit: number;
66
+ offset: number;
67
+ totalPages: number;
68
+ refetch: (options?: _tanstack_react_query.RefetchOptions) => Promise<_tanstack_react_query.QueryObserverResult<CommentListResult, Error>>;
69
+ };
70
+ /**
71
+ * Infinite-scroll variant for the CommentThread component.
72
+ * Uses the "commentsThread" factory namespace (separate from the plain
73
+ * useComments / useSuspenseComments queries) to avoid InfiniteData shape conflicts.
74
+ *
75
+ * Mirrors the blog's usePosts pattern: spread the factory base query into
76
+ * useInfiniteQuery, drive pages via pageParam, and derive hasMore from server total.
77
+ */
78
+ declare function useInfiniteComments(config: CommentsClientConfig, params: {
79
+ resourceId: string;
80
+ resourceType: string;
81
+ parentId?: string | null;
82
+ status?: "pending" | "approved" | "spam";
83
+ currentUserId?: string;
84
+ pageSize?: number;
85
+ }, options?: {
86
+ enabled?: boolean;
87
+ }): {
88
+ comments: SerializedComment[];
89
+ total: number;
90
+ queryKey: readonly ["commentsThread", "list", CommentsThreadDiscriminator];
91
+ isLoading: boolean;
92
+ isFetching: boolean;
93
+ loadMore: (options?: _tanstack_react_query.FetchNextPageOptions) => Promise<_tanstack_react_query.InfiniteQueryObserverResult<InfiniteData<CommentListResult, unknown>, Error>>;
94
+ hasMore: boolean;
95
+ isLoadingMore: boolean;
96
+ error: Error | null;
97
+ };
98
+ /**
99
+ * Fetch the approved comment count for a resource.
100
+ */
101
+ declare function useCommentCount(config: CommentsClientConfig, params: {
102
+ resourceId: string;
103
+ resourceType: string;
104
+ status?: "pending" | "approved" | "spam";
105
+ }): {
106
+ count: number;
107
+ isLoading: boolean;
108
+ error: Error | null;
109
+ };
110
+ /**
111
+ * Post a new comment with optimistic update.
112
+ * When autoApprove is false the optimistic entry shows as "pending" — visible
113
+ * only to the comment's own author via the `currentUserId` match in the UI.
114
+ *
115
+ * Pass `infiniteKey` (from `useInfiniteComments`) when the thread uses an
116
+ * infinite query so the optimistic update targets InfiniteData<CommentListResult>
117
+ * instead of a plain CommentListResult cache entry.
118
+ */
119
+ declare function usePostComment(config: CommentsClientConfig, params: {
120
+ resourceId: string;
121
+ resourceType: string;
122
+ currentUserId?: string;
123
+ /** When provided, optimistic updates target this infinite-query cache key. */
124
+ infiniteKey?: readonly unknown[];
125
+ /**
126
+ * Page size used by the corresponding `useInfiniteComments` call.
127
+ * Used only when the infinite-query cache is empty at the time of the
128
+ * optimistic update — ensures `getNextPageParam` computes the correct
129
+ * `nextOffset` from `lastPage.limit` instead of a hardcoded fallback.
130
+ */
131
+ pageSize?: number;
132
+ }): _tanstack_react_query.UseMutationResult<SerializedComment, Error, {
133
+ body: string;
134
+ parentId?: string | null;
135
+ limit?: number;
136
+ offset?: number;
137
+ }, {
138
+ previous: InfiniteData<CommentListResult, unknown> | undefined;
139
+ isInfinite: true;
140
+ listKey: readonly unknown[];
141
+ optimisticId: string;
142
+ } | {
143
+ previous: CommentListResult | undefined;
144
+ isInfinite: false;
145
+ listKey: readonly unknown[];
146
+ optimisticId: string;
147
+ }>;
148
+ /**
149
+ * Edit the body of an existing comment.
150
+ */
151
+ declare function useUpdateComment(config: CommentsClientConfig): _tanstack_react_query.UseMutationResult<SerializedComment, Error, {
152
+ id: string;
153
+ body: string;
154
+ }, unknown>;
155
+ /**
156
+ * Approve a comment (set status to "approved"). Admin use.
157
+ */
158
+ declare function useApproveComment(config: CommentsClientConfig): _tanstack_react_query.UseMutationResult<SerializedComment, Error, string, unknown>;
159
+ /**
160
+ * Update comment status (pending / approved / spam). Admin use.
161
+ */
162
+ declare function useUpdateCommentStatus(config: CommentsClientConfig): _tanstack_react_query.UseMutationResult<SerializedComment, Error, {
163
+ id: string;
164
+ status: "pending" | "approved" | "spam";
165
+ }, unknown>;
166
+ /**
167
+ * Delete a comment. Admin use.
168
+ */
169
+ declare function useDeleteComment(config: CommentsClientConfig): _tanstack_react_query.UseMutationResult<{
170
+ success: boolean;
171
+ }, Error, string, unknown>;
172
+ /**
173
+ * Toggle a like on a comment with optimistic update.
174
+ *
175
+ * Pass `infiniteKey` (from `useInfiniteComments`) for top-level thread comments
176
+ * so the optimistic update targets InfiniteData<CommentListResult> instead of
177
+ * a plain CommentListResult cache entry.
178
+ */
179
+ declare function useToggleLike(config: CommentsClientConfig, params: {
180
+ resourceId: string;
181
+ resourceType: string;
182
+ /** parentId of the comment being liked — must match the parentId used by
183
+ * useComments so the optimistic setQueryData hits the correct cache entry.
184
+ * Pass `null` for top-level comments, or the parent comment ID for replies. */
185
+ parentId?: string | null;
186
+ currentUserId?: string;
187
+ /** When the comment lives in an infinite thread, pass the thread's query key
188
+ * so the optimistic update targets the correct InfiniteData cache entry. */
189
+ infiniteKey?: readonly unknown[];
190
+ }): _tanstack_react_query.UseMutationResult<{
191
+ likes: number;
192
+ isLiked: boolean;
193
+ }, Error, {
194
+ commentId: string;
195
+ authorId: string;
196
+ }, {
197
+ previous: CommentListResult | InfiniteData<CommentListResult, unknown> | undefined;
198
+ }>;
199
+
200
+ export { useApproveComment, useCommentCount, useComments, useDeleteComment, useInfiniteComments, usePostComment, useSuspenseComments, useSuspenseModerationComments, useToggleLike, useUpdateComment, useUpdateCommentStatus };