@openrails/contentkit-ui 0.71.0 → 0.73.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 (134) hide show
  1. package/README.md +122 -10
  2. package/dist/client/content/bans.d.ts +2 -0
  3. package/dist/client/content/bans.js +24 -12
  4. package/dist/client/content/bans.js.map +1 -1
  5. package/dist/client/content/comments.d.ts +2 -0
  6. package/dist/client/content/comments.js.map +1 -1
  7. package/dist/client/content/polls.d.ts +9 -2
  8. package/dist/client/content/polls.js.map +1 -1
  9. package/dist/client/generated/routes.d.ts +28 -2
  10. package/dist/client/generated/routes.js +40 -0
  11. package/dist/client/generated/routes.js.map +1 -1
  12. package/dist/client/generated/wire.d.ts +4 -0
  13. package/dist/client/generated/wire.js.map +1 -1
  14. package/dist/client/index.d.ts +3 -3
  15. package/dist/client/media/queue.d.ts +1 -1
  16. package/dist/client/media/queue.js +1 -1
  17. package/dist/client/media/queue.js.map +1 -1
  18. package/dist/client/taxonomy.d.ts +5 -1
  19. package/dist/client/taxonomy.js +7 -0
  20. package/dist/client/taxonomy.js.map +1 -1
  21. package/dist/client.js +2 -2
  22. package/dist/components/admin/media-item-panel.d.ts +27 -0
  23. package/dist/components/admin/media-item-panel.js +397 -0
  24. package/dist/components/admin/media-item-panel.js.map +1 -0
  25. package/dist/components/admin/poll-manager.d.ts +28 -0
  26. package/dist/components/admin/poll-manager.js +297 -0
  27. package/dist/components/admin/poll-manager.js.map +1 -0
  28. package/dist/components/admin/post-manager.d.ts +45 -0
  29. package/dist/components/admin/post-manager.js +602 -0
  30. package/dist/components/admin/post-manager.js.map +1 -0
  31. package/dist/components/admin/shell.d.ts +73 -0
  32. package/dist/components/admin/shell.js +148 -0
  33. package/dist/components/admin/shell.js.map +1 -0
  34. package/dist/components/admin/taxonomy-manager.d.ts +54 -0
  35. package/dist/components/admin/taxonomy-manager.js +976 -0
  36. package/dist/components/admin/taxonomy-manager.js.map +1 -0
  37. package/dist/components/admin/upload-queue.d.ts +23 -0
  38. package/dist/components/admin/upload-queue.js +365 -0
  39. package/dist/components/admin/upload-queue.js.map +1 -0
  40. package/dist/components/admin/user-comment-standing.d.ts +25 -0
  41. package/dist/components/admin/user-comment-standing.js +229 -0
  42. package/dist/components/admin/user-comment-standing.js.map +1 -0
  43. package/dist/components/social/bans.d.ts +5 -2
  44. package/dist/components/social/bans.js +132 -134
  45. package/dist/components/social/bans.js.map +1 -1
  46. package/dist/components/social/index.d.ts +1 -1
  47. package/dist/components/social/moderation.d.ts +11 -13
  48. package/dist/components/social/moderation.js +299 -218
  49. package/dist/components/social/moderation.js.map +1 -1
  50. package/dist/components/social/parts.d.ts +3 -2
  51. package/dist/components/social/parts.js +74 -48
  52. package/dist/components/social/parts.js.map +1 -1
  53. package/dist/components/social/poll-editor.js +1 -0
  54. package/dist/components/social/poll-editor.js.map +1 -1
  55. package/dist/editor/index.d.ts +1 -0
  56. package/dist/editor/rich-text-editor.d.ts +13 -0
  57. package/dist/editor/rich-text-editor.js +228 -0
  58. package/dist/editor/rich-text-editor.js.map +1 -0
  59. package/dist/editor.js +2 -0
  60. package/dist/index.d.ts +8 -0
  61. package/dist/index.js +15 -8
  62. package/dist/locales/admin/de.d.ts +2 -0
  63. package/dist/locales/admin/de.js +227 -0
  64. package/dist/locales/admin/de.js.map +1 -0
  65. package/dist/locales/admin/en.d.ts +222 -0
  66. package/dist/locales/admin/en.js +227 -0
  67. package/dist/locales/admin/en.js.map +1 -0
  68. package/dist/locales/admin/es.d.ts +2 -0
  69. package/dist/locales/admin/es.js +227 -0
  70. package/dist/locales/admin/es.js.map +1 -0
  71. package/dist/locales/admin/ja.d.ts +2 -0
  72. package/dist/locales/admin/ja.js +227 -0
  73. package/dist/locales/admin/ja.js.map +1 -0
  74. package/dist/locales/admin/ko.d.ts +2 -0
  75. package/dist/locales/admin/ko.js +227 -0
  76. package/dist/locales/admin/ko.js.map +1 -0
  77. package/dist/locales/admin/zh.d.ts +2 -0
  78. package/dist/locales/admin/zh.js +227 -0
  79. package/dist/locales/admin/zh.js.map +1 -0
  80. package/dist/locales/de.js +5 -3
  81. package/dist/locales/de.js.map +1 -1
  82. package/dist/locales/en.d.ts +227 -0
  83. package/dist/locales/en.js +5 -3
  84. package/dist/locales/en.js.map +1 -1
  85. package/dist/locales/es.js +5 -3
  86. package/dist/locales/es.js.map +1 -1
  87. package/dist/locales/ja.js +5 -3
  88. package/dist/locales/ja.js.map +1 -1
  89. package/dist/locales/ko.js +5 -3
  90. package/dist/locales/ko.js.map +1 -1
  91. package/dist/locales/social/de.js +8 -1
  92. package/dist/locales/social/de.js.map +1 -1
  93. package/dist/locales/social/en.d.ts +7 -0
  94. package/dist/locales/social/en.js +8 -1
  95. package/dist/locales/social/en.js.map +1 -1
  96. package/dist/locales/social/es.js +8 -1
  97. package/dist/locales/social/es.js.map +1 -1
  98. package/dist/locales/social/ja.js +8 -1
  99. package/dist/locales/social/ja.js.map +1 -1
  100. package/dist/locales/social/ko.js +8 -1
  101. package/dist/locales/social/ko.js.map +1 -1
  102. package/dist/locales/social/zh.js +8 -1
  103. package/dist/locales/social/zh.js.map +1 -1
  104. package/dist/locales/zh.js +5 -3
  105. package/dist/locales/zh.js.map +1 -1
  106. package/dist/provider.d.ts +2 -0
  107. package/dist/provider.js +23 -19
  108. package/dist/provider.js.map +1 -1
  109. package/dist/react/admin.d.ts +55 -0
  110. package/dist/react/admin.js +97 -0
  111. package/dist/react/admin.js.map +1 -0
  112. package/dist/react/comments.d.ts +18 -2
  113. package/dist/react/comments.js +24 -8
  114. package/dist/react/comments.js.map +1 -1
  115. package/dist/react/context.d.ts +7 -1
  116. package/dist/react/context.js +6 -1
  117. package/dist/react/context.js.map +1 -1
  118. package/dist/react/folder.js.map +1 -1
  119. package/dist/react/index.d.ts +4 -3
  120. package/dist/react/polls.js +88 -87
  121. package/dist/react/polls.js.map +1 -1
  122. package/dist/react/posts.js +123 -122
  123. package/dist/react/posts.js.map +1 -1
  124. package/dist/react/resources.js +3 -0
  125. package/dist/react/resources.js.map +1 -1
  126. package/dist/react/upload.d.ts +10 -10
  127. package/dist/react/upload.js +1 -1
  128. package/dist/react/upload.js.map +1 -1
  129. package/dist/react/use-resource.d.ts +16 -0
  130. package/dist/react/use-resource.js +20 -1
  131. package/dist/react/use-resource.js.map +1 -1
  132. package/dist/react.js +21 -20
  133. package/dist/styles.css +1 -1
  134. package/package.json +37 -2
@@ -1,155 +1,224 @@
1
1
  import { toContentKitError as e } from "../../client/errors.js";
2
2
  import { useMessages as t } from "../../i18n/context.js";
3
- import { ContentKitUiRoot as n } from "../../scope.js";
4
- import { useErrorReporter as r } from "../../react/context.js";
3
+ import { useErrorReporter as n, useGuarded as r } from "../../react/context.js";
5
4
  import { Button as i } from "../../ui/button.js";
6
- import { useAdminComments as a, useModerationQueue as o } from "../../react/comments.js";
7
- import { Badge as s } from "../../ui/badge.js";
8
- import { Input as c } from "../../ui/input.js";
9
- import { Select as l, SelectContent as u, SelectItem as d, SelectTrigger as f, SelectValue as p } from "../../ui/select.js";
10
- import { Skeleton as m } from "../../ui/skeleton.js";
11
- import { ErrorLine as h, RelativeTime as g, UserAvatar as _, UserName as v, contentError as y } from "./parts.js";
12
- import { CommentBanDialog as b, CommentBans as x } from "./bans.js";
13
- import { Tabs as S, TabsContent as C, TabsList as w, TabsTrigger as T } from "../../ui/tabs.js";
14
- import { useMemo as E, useState as D } from "react";
15
- import { jsx as O, jsxs as k } from "react/jsx-runtime";
16
- import { cn as A } from "cn";
5
+ import { keyOf as a, useContentScope as o, usePaged as s } from "../../react/use-resource.js";
6
+ import { useModerationQueue as c } from "../../react/comments.js";
7
+ import { Badge as l } from "../../ui/badge.js";
8
+ import { Input as u } from "../../ui/input.js";
9
+ import { Label as d } from "../../ui/label.js";
10
+ import { Select as f, SelectContent as p, SelectItem as m, SelectTrigger as h, SelectValue as g } from "../../ui/select.js";
11
+ import { Skeleton as _ } from "../../ui/skeleton.js";
12
+ import { ErrorLine as v, RelativeTime as y, UserAvatar as b, UserName as x, contentError as S } from "./parts.js";
13
+ import { AdminRoot as C, NoAccess as w, Pager as T, Rows as E, pageOf as D } from "../admin/shell.js";
14
+ import { CommentBanDialog as ee, CommentBans as O } from "./bans.js";
15
+ import { useAdminLocation as k, useFlowClient as A, useStaffAccess as j } from "../../react/admin.js";
16
+ import { Tabs as M, TabsContent as N, TabsList as P, TabsTrigger as F } from "../../ui/tabs.js";
17
+ import { useEffect as I, useId as L, useMemo as R, useState as z } from "react";
18
+ import { Fragment as B, jsx as V, jsxs as H } from "react/jsx-runtime";
19
+ import { cn as te } from "cn";
17
20
  //#region src/components/social/moderation.tsx
18
- function j({ sections: e = [
21
+ var U = [
19
22
  "comments",
20
23
  "queue",
21
24
  "bans"
22
- ], className: r, appearance: i, ...a }) {
23
- let { t: o } = t(), [s, c] = D(e[0] ?? "comments"), l = {
24
- comments: o("moderation.all"),
25
- queue: o("moderation.queue"),
26
- bans: o("moderation.bans")
27
- };
28
- return /* @__PURE__ */ k(n, {
25
+ ];
26
+ function W(e = {}) {
27
+ return j(U, e);
28
+ }
29
+ function G({ client: e, baseUrl: t, auth: n, guard: r, appearance: i, className: a, language: o, messages: s, sections: c = U, ...l }) {
30
+ let u = A({
31
+ client: e,
32
+ baseUrl: t,
33
+ auth: n
34
+ });
35
+ return /* @__PURE__ */ V(C, {
36
+ flow: "comment-moderation",
29
37
  appearance: i,
30
- className: A("grid gap-4 text-sm", r),
31
- "data-ckui": "comment-moderation",
32
- children: [/* @__PURE__ */ O("h2", {
33
- className: "text-base font-semibold",
34
- children: o("moderation.title")
35
- }), /* @__PURE__ */ k(S, {
36
- value: s,
37
- onValueChange: (e) => c(e),
38
+ className: a,
39
+ language: o,
40
+ messages: s,
41
+ guard: r,
42
+ children: /* @__PURE__ */ V(K, {
43
+ ...l,
44
+ client: u,
45
+ sections: c
46
+ })
47
+ });
48
+ }
49
+ function K({ sections: e, basePath: n, navigation: r, ...i }) {
50
+ let { t: a } = t(), o = k(n, r), s = W({ client: i.client }), c = e.filter((e) => s.allowed[e]), l = {
51
+ comments: a("moderation.all"),
52
+ queue: a("moderation.queue"),
53
+ bans: a("moderation.bans")
54
+ }, u = /* @__PURE__ */ V("h2", {
55
+ className: "text-base font-semibold",
56
+ children: a("moderation.title")
57
+ });
58
+ if (s.loading) return /* @__PURE__ */ H(B, { children: [u, /* @__PURE__ */ V(E, {})] });
59
+ if (!c.length) return /* @__PURE__ */ H(B, { children: [u, /* @__PURE__ */ V(w, { children: a("moderation.noAccess") })] });
60
+ let d = (t) => t === e[0] ? "" : t, f = o.view || e[0], p = c.includes(f) ? f : c[0], m = d(p);
61
+ return /* @__PURE__ */ H(B, { children: [u, /* @__PURE__ */ H(M, {
62
+ value: p,
63
+ onValueChange: (e) => o.go(d(e)),
64
+ children: [c.length > 1 && /* @__PURE__ */ V(P, { children: c.map((e) => /* @__PURE__ */ V(F, {
65
+ value: e,
66
+ children: l[e]
67
+ }, e)) }), /* @__PURE__ */ H(N, {
68
+ value: p,
69
+ className: "pt-3",
38
70
  children: [
39
- e.length > 1 && /* @__PURE__ */ O(w, { children: e.map((e) => /* @__PURE__ */ O(T, {
40
- value: e,
41
- children: l[e]
42
- }, e)) }),
43
- e.includes("comments") && /* @__PURE__ */ O(C, {
44
- value: "comments",
45
- className: "pt-3",
46
- children: /* @__PURE__ */ O(N, { ...a })
71
+ p === "comments" && /* @__PURE__ */ V(J, {
72
+ ...i,
73
+ loc: o,
74
+ view: m
47
75
  }),
48
- e.includes("queue") && /* @__PURE__ */ O(C, {
49
- value: "queue",
50
- className: "pt-3",
51
- children: /* @__PURE__ */ O(P, { ...a })
76
+ p === "queue" && /* @__PURE__ */ V(Y, {
77
+ ...i,
78
+ loc: o,
79
+ view: m
52
80
  }),
53
- e.includes("bans") && /* @__PURE__ */ O(C, {
54
- value: "bans",
55
- className: "pt-3",
56
- children: /* @__PURE__ */ O(x, {
57
- scope: "global",
58
- pageSize: a.pageSize,
59
- userHref: a.userHref,
60
- client: a.client,
61
- onError: a.onError
62
- })
81
+ p === "bans" && /* @__PURE__ */ V(O, {
82
+ scope: "global",
83
+ pageSize: i.pageSize,
84
+ page: D(o.query),
85
+ onPageChange: (e) => o.go(m, { page: e > 1 ? e : void 0 }),
86
+ userHref: i.userHref,
87
+ client: i.client,
88
+ onError: i.onError
63
89
  })
64
90
  ]
65
91
  })]
66
- });
92
+ })] });
67
93
  }
68
- function M(e) {
94
+ function q(e) {
69
95
  return e.deleted ? "deleted" : e.moderation === "held" ? "held" : e.moderation === "rejected" ? "rejected" : "published";
70
96
  }
71
- function N(n) {
72
- let { t: o } = t(), c = E(() => (n.contentKinds ?? []).map((e) => typeof e == "string" ? {
97
+ function J({ loc: c, view: _, client: S, ...C }) {
98
+ let { t: w } = t(), E = L(), O = R(() => (C.contentKinds ?? []).map((e) => typeof e == "string" ? {
73
99
  value: e,
74
100
  label: e
75
- } : e), [n.contentKinds]), [m, y] = D(""), x = a({
76
- contentKind: m,
77
- pageSize: n.pageSize,
78
- client: n.client
79
- }), S = r(n.onError), [C, w] = D(null), [T, j] = D(null), N = (t, n) => {
80
- w(null), n().catch((n) => {
101
+ } : e), [C.contentKinds]), k = c.query.get("kind") ?? "", A = c.query.get("author") ?? "", j = D(c.query), M = C.pageSize ?? 25, N = (e) => c.go(_, {
102
+ kind: k,
103
+ author: A,
104
+ ...e
105
+ }), [P, F] = z(A);
106
+ I(() => F(A), [A]);
107
+ let { store: B, scope: U } = o(S), W = s(B, a("admin-comments-page", U, k, A, M), { type: "admin-comments" }, j, M, (e, t) => S.comments.adminList({
108
+ ...e,
109
+ contentKind: k || void 0,
110
+ author: A || void 0
111
+ }, t)), G = n(C.onError), K = r(), [J, Y] = z(null), [X, Q] = z(null), $ = (t, n) => {
112
+ Y(null), K(n).catch((n) => {
81
113
  let r = e(n);
82
- w(r), S(r, t);
114
+ Y(r), G(r, t);
83
115
  });
84
- };
85
- return /* @__PURE__ */ k("div", {
116
+ }, ne = A ? W.items.find((e) => e.user_id === A)?.author?.username ?? A : "";
117
+ return /* @__PURE__ */ H("div", {
86
118
  className: "grid gap-3",
87
119
  children: [
88
- c.length > 0 && /* @__PURE__ */ k(l, {
89
- value: m,
90
- onValueChange: (e) => y(String(e ?? "")),
91
- children: [/* @__PURE__ */ O(f, {
120
+ /* @__PURE__ */ H("div", {
121
+ className: "flex flex-wrap items-end gap-2",
122
+ children: [O.length > 0 && /* @__PURE__ */ H(f, {
123
+ value: k,
124
+ onValueChange: (e) => N({ kind: String(e ?? "") }),
125
+ children: [/* @__PURE__ */ V(h, {
126
+ size: "sm",
127
+ "aria-label": w("moderation.kind"),
128
+ children: /* @__PURE__ */ V(g, { children: (e) => e ? O.find((t) => t.value === e)?.label ?? e : w("moderation.allKinds") })
129
+ }), /* @__PURE__ */ H(p, { children: [/* @__PURE__ */ V(m, {
130
+ value: "",
131
+ children: w("moderation.allKinds")
132
+ }), O.map((e) => /* @__PURE__ */ V(m, {
133
+ value: e.value,
134
+ children: e.label
135
+ }, e.value))] })]
136
+ }), /* @__PURE__ */ H("form", {
137
+ className: "flex min-w-56 flex-1 items-end gap-2",
138
+ onSubmit: (e) => {
139
+ e.preventDefault(), N({ author: P.trim() });
140
+ },
141
+ children: [/* @__PURE__ */ H("div", {
142
+ className: "grid flex-1 gap-1",
143
+ children: [/* @__PURE__ */ V(d, {
144
+ htmlFor: `${E}-author`,
145
+ className: "sr-only",
146
+ children: w("moderation.author")
147
+ }), /* @__PURE__ */ V(u, {
148
+ id: `${E}-author`,
149
+ className: "h-8",
150
+ value: P,
151
+ placeholder: w("moderation.authorPlaceholder"),
152
+ onChange: (e) => F(e.target.value)
153
+ })]
154
+ }), /* @__PURE__ */ V(i, {
155
+ type: "submit",
156
+ size: "sm",
157
+ variant: "outline",
158
+ children: w("moderation.filter")
159
+ })]
160
+ })]
161
+ }),
162
+ A && /* @__PURE__ */ H("div", {
163
+ className: "flex flex-wrap items-center gap-2",
164
+ "data-ckui": "author-filter",
165
+ children: [/* @__PURE__ */ V("span", { children: w("moderation.byAuthor", { name: ne }) }), /* @__PURE__ */ V(i, {
92
166
  size: "sm",
93
- "aria-label": o("moderation.kind"),
94
- children: /* @__PURE__ */ O(p, { children: (e) => e ? c.find((t) => t.value === e)?.label ?? e : o("moderation.allKinds") })
95
- }), /* @__PURE__ */ k(u, { children: [/* @__PURE__ */ O(d, {
96
- value: "",
97
- children: o("moderation.allKinds")
98
- }), c.map((e) => /* @__PURE__ */ O(d, {
99
- value: e.value,
100
- children: e.label
101
- }, e.value))] })]
167
+ variant: "ghost",
168
+ onClick: () => N({ author: "" }),
169
+ children: w("moderation.clearAuthor")
170
+ })]
102
171
  }),
103
- /* @__PURE__ */ O(h, { error: C }),
104
- /* @__PURE__ */ O(I, {
105
- loading: x.loading,
106
- error: x.error,
107
- empty: o("moderation.empty"),
108
- count: x.items.length,
109
- reload: x.reload,
110
- children: x.items.map((e) => {
111
- let t = e.author?.username ?? e.anon_name ?? e.user_id ?? o("comments.anonymous"), r = M(e), a = n.itemHref?.({
172
+ /* @__PURE__ */ V(v, { error: J }),
173
+ /* @__PURE__ */ V(Z, {
174
+ loading: W.loading,
175
+ error: W.error,
176
+ empty: w("moderation.empty"),
177
+ count: W.items.length,
178
+ reload: W.reload,
179
+ children: W.items.map((e) => {
180
+ let t = e.author?.username ?? e.anon_name ?? e.user_id ?? w("comments.anonymous"), n = q(e), r = C.itemHref?.({
112
181
  kind: e.content_kind,
113
182
  id: e.content_id
114
183
  });
115
- return /* @__PURE__ */ k("li", {
184
+ return /* @__PURE__ */ H("li", {
116
185
  className: "grid gap-2 p-3",
117
186
  "data-ckui": "admin-comment",
118
- "data-status": r,
187
+ "data-status": n,
119
188
  children: [
120
- /* @__PURE__ */ k("div", {
189
+ /* @__PURE__ */ H("div", {
121
190
  className: "flex flex-wrap items-center gap-x-2 gap-y-1",
122
191
  children: [
123
- /* @__PURE__ */ O(_, {
192
+ /* @__PURE__ */ V(b, {
124
193
  user: e.author,
125
194
  name: t,
126
195
  size: "sm"
127
196
  }),
128
- /* @__PURE__ */ O(v, {
197
+ /* @__PURE__ */ V(x, {
129
198
  user: e.author,
130
199
  name: t,
131
- href: n.userHref
200
+ href: C.userHref
132
201
  }),
133
- /* @__PURE__ */ O(g, {
202
+ /* @__PURE__ */ V(y, {
134
203
  at: e.created_at,
135
204
  className: "text-xs text-muted-foreground"
136
205
  }),
137
- /* @__PURE__ */ O(s, {
138
- variant: r === "published" ? "outline" : r === "held" ? "secondary" : "destructive",
139
- children: o(`moderation.${r}`)
206
+ /* @__PURE__ */ V(l, {
207
+ variant: n === "published" ? "outline" : n === "held" ? "secondary" : "destructive",
208
+ children: w(`moderation.${n}`)
140
209
  }),
141
- e.reply_to_id && /* @__PURE__ */ O(s, {
210
+ e.reply_to_id && /* @__PURE__ */ V(l, {
142
211
  variant: "outline",
143
- children: o("moderation.reply")
212
+ children: w("moderation.reply")
144
213
  }),
145
- /* @__PURE__ */ k("span", {
214
+ /* @__PURE__ */ H("span", {
146
215
  className: "text-xs text-muted-foreground",
147
216
  children: [
148
- o("moderation.on"),
217
+ w("moderation.on"),
149
218
  " ",
150
- a ? /* @__PURE__ */ k("a", {
219
+ r ? /* @__PURE__ */ H("a", {
151
220
  className: "hover:underline",
152
- href: a,
221
+ href: r,
153
222
  children: [
154
223
  e.content_kind,
155
224
  "/",
@@ -160,224 +229,236 @@ function N(n) {
160
229
  })
161
230
  ]
162
231
  }),
163
- /* @__PURE__ */ O("p", {
164
- className: A("line-clamp-4 break-words whitespace-pre-wrap", e.deleted && "text-muted-foreground line-through"),
232
+ /* @__PURE__ */ V("p", {
233
+ className: te("line-clamp-4 break-words whitespace-pre-wrap", e.deleted && "text-muted-foreground line-through"),
165
234
  children: e.body
166
235
  }),
167
- e.moderation_reason && /* @__PURE__ */ O("p", {
236
+ e.moderation_reason && /* @__PURE__ */ V("p", {
168
237
  className: "text-xs text-muted-foreground",
169
- children: o("moderation.heldBecause", { reason: e.moderation_reason })
238
+ children: w("moderation.heldBecause", { reason: e.moderation_reason })
170
239
  }),
171
- /* @__PURE__ */ k("div", {
240
+ /* @__PURE__ */ H("div", {
172
241
  className: "flex flex-wrap gap-2",
173
- children: [e.deleted ? /* @__PURE__ */ O(i, {
174
- size: "sm",
175
- variant: "outline",
176
- onClick: () => N("comment.restore", () => x.restore(e.id)),
177
- children: o("moderation.restore")
178
- }) : /* @__PURE__ */ O(i, {
179
- size: "sm",
180
- variant: "destructive",
181
- onClick: () => N("comment.delete", () => x.remove(e.id)),
182
- children: o("moderation.delete")
183
- }), e.user_id && /* @__PURE__ */ O(i, {
184
- size: "sm",
185
- variant: "ghost",
186
- onClick: () => j({
187
- id: e.user_id,
188
- name: t
242
+ children: [
243
+ e.deleted ? /* @__PURE__ */ V(i, {
244
+ size: "sm",
245
+ variant: "outline",
246
+ onClick: () => $("comment.restore", () => S.comments.restore(e.id)),
247
+ children: w("moderation.restore")
248
+ }) : /* @__PURE__ */ V(i, {
249
+ size: "sm",
250
+ variant: "destructive",
251
+ onClick: () => $("comment.delete", () => S.comments.delete(e.id)),
252
+ children: w("moderation.delete")
253
+ }),
254
+ e.user_id && e.user_id !== A && /* @__PURE__ */ V(i, {
255
+ size: "sm",
256
+ variant: "ghost",
257
+ onClick: () => N({ author: e.user_id }),
258
+ children: w("moderation.theirComments")
189
259
  }),
190
- children: o("comments.ban")
191
- })]
260
+ e.user_id && /* @__PURE__ */ V(i, {
261
+ size: "sm",
262
+ variant: "ghost",
263
+ onClick: () => Q({
264
+ id: e.user_id,
265
+ name: t
266
+ }),
267
+ children: w("comments.ban")
268
+ })
269
+ ]
192
270
  })
193
271
  ]
194
272
  }, e.id);
195
273
  })
196
274
  }),
197
- x.hasMore && /* @__PURE__ */ O(i, {
198
- variant: "outline",
199
- className: "justify-self-center",
200
- disabled: x.loadingMore,
201
- onClick: () => void x.loadMore(),
202
- children: o("moderation.loadMore")
275
+ /* @__PURE__ */ V(T, {
276
+ page: j,
277
+ hasNext: W.hasNext,
278
+ disabled: W.loading,
279
+ onPage: (e) => c.go(_, {
280
+ kind: k,
281
+ author: A,
282
+ page: e > 1 ? e : void 0
283
+ })
203
284
  }),
204
- T && /* @__PURE__ */ O(b, {
285
+ X && /* @__PURE__ */ V(ee, {
205
286
  open: !0,
206
- onOpenChange: (e) => !e && j(null),
207
- user: T,
287
+ onOpenChange: (e) => !e && Q(null),
288
+ user: X,
208
289
  scopes: ["global"],
209
- client: n.client,
210
- onError: n.onError
290
+ client: S,
291
+ onError: C.onError
211
292
  })
212
293
  ]
213
294
  });
214
295
  }
215
- function P(e) {
216
- let { t: n } = t(), [r, a] = D("comment"), s = o({
217
- kind: r,
218
- pageSize: e.pageSize,
219
- client: e.client
296
+ function Y({ loc: e, view: n, ...r }) {
297
+ let { t: a } = t(), o = e.query.get("kind") === "post" ? "post" : "comment", s = c({
298
+ kind: o,
299
+ pageSize: r.pageSize,
300
+ client: r.client
220
301
  });
221
- return /* @__PURE__ */ k("div", {
302
+ return /* @__PURE__ */ H("div", {
222
303
  className: "grid gap-3",
223
304
  children: [
224
- /* @__PURE__ */ O("div", {
305
+ /* @__PURE__ */ V("div", {
225
306
  className: "flex gap-2",
226
307
  role: "group",
227
- "aria-label": n("moderation.queue"),
228
- children: ["comment", "post"].map((e) => /* @__PURE__ */ O(i, {
308
+ "aria-label": a("moderation.queue"),
309
+ children: ["comment", "post"].map((t) => /* @__PURE__ */ V(i, {
229
310
  size: "sm",
230
- variant: r === e ? "default" : "outline",
231
- "aria-pressed": r === e,
232
- onClick: () => a(e),
233
- children: n(e === "post" ? "moderation.queuePosts" : "moderation.queueComments")
234
- }, e))
311
+ variant: o === t ? "default" : "outline",
312
+ "aria-pressed": o === t,
313
+ onClick: () => e.go(n, { kind: t === "comment" ? void 0 : t }),
314
+ children: a(t === "post" ? "moderation.queuePosts" : "moderation.queueComments")
315
+ }, t))
235
316
  }),
236
- /* @__PURE__ */ O(I, {
317
+ /* @__PURE__ */ V(Z, {
237
318
  loading: s.loading,
238
319
  error: s.error,
239
- empty: n("moderation.queueEmpty"),
320
+ empty: a("moderation.queueEmpty"),
240
321
  count: s.items.length,
241
322
  reload: s.reload,
242
- children: s.items.map((t) => /* @__PURE__ */ O(F, {
243
- item: t,
244
- itemHref: e.itemHref,
245
- userHref: e.userHref,
323
+ children: s.items.map((e) => /* @__PURE__ */ V(X, {
324
+ item: e,
325
+ itemHref: r.itemHref,
326
+ userHref: r.userHref,
246
327
  onResolve: s.resolve,
247
328
  reload: s.reload,
248
- onError: e.onError
249
- }, t.id))
329
+ onError: r.onError
330
+ }, e.id))
250
331
  }),
251
- s.hasMore && /* @__PURE__ */ O(i, {
332
+ s.hasMore && /* @__PURE__ */ V(i, {
252
333
  variant: "outline",
253
334
  className: "justify-self-center",
254
335
  disabled: s.loadingMore,
255
336
  onClick: () => void s.loadMore(),
256
- children: n("moderation.loadMore")
337
+ children: a("moderation.loadMore")
257
338
  })
258
339
  ]
259
340
  });
260
341
  }
261
- function F(n) {
262
- let a = t(), { t: o } = a, s = r(n.onError), { item: l } = n, [u, d] = D(!1), [f, p] = D(""), [m, b] = D(!1), [x, S] = D(null), C = l.author?.username ?? l.anon_name ?? l.author_id ?? o("comments.anonymous"), w = n.itemHref?.({
263
- kind: l.ref.content_kind,
264
- id: l.ref.content_id
265
- }), T = async (t) => {
266
- b(!0), S(null);
342
+ function X(a) {
343
+ let o = t(), { t: s } = o, c = n(a.onError), l = r(), { item: d } = a, [f, p] = z(!1), [m, h] = z(""), [g, _] = z(!1), [C, w] = z(null), T = d.author?.username ?? d.anon_name ?? d.author_id ?? s("comments.anonymous"), E = a.itemHref?.({
344
+ kind: d.ref.content_kind,
345
+ id: d.ref.content_id
346
+ }), D = async (t) => {
347
+ _(!0), w(null);
267
348
  try {
268
- await n.onResolve(l, t, t === "reject" && f.trim() || void 0);
349
+ await l(() => a.onResolve(d, t, t === "reject" && m.trim() || void 0));
269
350
  } catch (t) {
270
- let r = e(t);
271
- s(r, "moderation.resolve"), r.code === "not_found" || r.code === "conflict" ? (S(o("moderation.stale")), n.reload()) : S(y(a, r));
351
+ let n = e(t);
352
+ c(n, "moderation.resolve"), n.code === "not_found" || n.code === "conflict" ? (w(s("moderation.stale")), a.reload()) : w(S(o, n));
272
353
  } finally {
273
- b(!1);
354
+ _(!1);
274
355
  }
275
356
  };
276
- return /* @__PURE__ */ k("li", {
357
+ return /* @__PURE__ */ H("li", {
277
358
  className: "grid gap-2 p-3",
278
359
  "data-ckui": "held-item",
279
360
  children: [
280
- /* @__PURE__ */ k("div", {
361
+ /* @__PURE__ */ H("div", {
281
362
  className: "flex flex-wrap items-center gap-x-2 gap-y-1",
282
363
  children: [
283
- /* @__PURE__ */ O(_, {
284
- user: l.author,
285
- name: C,
364
+ /* @__PURE__ */ V(b, {
365
+ user: d.author,
366
+ name: T,
286
367
  size: "sm"
287
368
  }),
288
- /* @__PURE__ */ O(v, {
289
- user: l.author,
290
- name: C,
291
- href: n.userHref
369
+ /* @__PURE__ */ V(x, {
370
+ user: d.author,
371
+ name: T,
372
+ href: a.userHref
292
373
  }),
293
- /* @__PURE__ */ O(g, {
294
- at: l.held_at,
374
+ /* @__PURE__ */ V(y, {
375
+ at: d.held_at,
295
376
  className: "text-xs text-muted-foreground"
296
377
  }),
297
- w && /* @__PURE__ */ k("a", {
378
+ E && /* @__PURE__ */ H("a", {
298
379
  className: "text-xs text-muted-foreground hover:underline",
299
- href: w,
380
+ href: E,
300
381
  children: [
301
- o("moderation.on"),
382
+ s("moderation.on"),
302
383
  " ",
303
- l.ref.content_kind,
384
+ d.ref.content_kind,
304
385
  "/",
305
- l.ref.content_id
386
+ d.ref.content_id
306
387
  ]
307
388
  })
308
389
  ]
309
390
  }),
310
- l.title && /* @__PURE__ */ O("p", {
391
+ d.title && /* @__PURE__ */ V("p", {
311
392
  className: "font-medium",
312
- children: l.title
393
+ children: d.title
313
394
  }),
314
- /* @__PURE__ */ O("p", {
395
+ /* @__PURE__ */ V("p", {
315
396
  className: "line-clamp-6 break-words whitespace-pre-wrap",
316
- children: l.body
397
+ children: d.body
317
398
  }),
318
- (l.reason || l.error) && /* @__PURE__ */ O("p", {
399
+ (d.reason || d.error) && /* @__PURE__ */ V("p", {
319
400
  className: "text-xs text-muted-foreground",
320
- children: o("moderation.heldBecause", { reason: l.reason || l.error || "" })
401
+ children: s("moderation.heldBecause", { reason: d.reason || d.error || "" })
321
402
  }),
322
- u && /* @__PURE__ */ O(c, {
323
- value: f,
403
+ f && /* @__PURE__ */ V(u, {
404
+ value: m,
324
405
  maxLength: 500,
325
- placeholder: o("moderation.rejectReason"),
326
- "aria-label": o("moderation.rejectReason"),
327
- onChange: (e) => p(e.target.value),
406
+ placeholder: s("moderation.rejectReason"),
407
+ "aria-label": s("moderation.rejectReason"),
408
+ onChange: (e) => h(e.target.value),
328
409
  autoFocus: !0
329
410
  }),
330
- /* @__PURE__ */ k("div", {
411
+ /* @__PURE__ */ H("div", {
331
412
  className: "flex flex-wrap gap-2",
332
413
  children: [
333
- /* @__PURE__ */ O(i, {
414
+ /* @__PURE__ */ V(i, {
334
415
  size: "sm",
335
- disabled: m,
336
- onClick: () => void T("approve"),
337
- children: o("moderation.approve")
416
+ disabled: g,
417
+ onClick: () => void D("approve"),
418
+ children: s("moderation.approve")
338
419
  }),
339
- /* @__PURE__ */ O(i, {
420
+ /* @__PURE__ */ V(i, {
340
421
  size: "sm",
341
422
  variant: "destructive",
342
- disabled: m,
343
- onClick: () => u ? void T("reject") : d(!0),
344
- children: o("moderation.reject")
423
+ disabled: g,
424
+ onClick: () => f ? void D("reject") : p(!0),
425
+ children: s("moderation.reject")
345
426
  }),
346
- u && /* @__PURE__ */ O(i, {
427
+ f && /* @__PURE__ */ V(i, {
347
428
  size: "sm",
348
429
  variant: "ghost",
349
- onClick: () => d(!1),
350
- children: o("common.cancel")
430
+ onClick: () => p(!1),
431
+ children: s("common.cancel")
351
432
  })
352
433
  ]
353
434
  }),
354
- x && /* @__PURE__ */ O(h, { children: x })
435
+ C && /* @__PURE__ */ V(v, { children: C })
355
436
  ]
356
437
  });
357
438
  }
358
- function I(e) {
439
+ function Z(e) {
359
440
  let n = t(), { t: r } = n;
360
- return e.loading && !e.count ? /* @__PURE__ */ k("div", {
441
+ return e.loading && !e.count ? /* @__PURE__ */ H("div", {
361
442
  className: "grid gap-3",
362
443
  "aria-busy": !0,
363
- children: [/* @__PURE__ */ O(m, { className: "h-16 w-full" }), /* @__PURE__ */ O(m, { className: "h-16 w-full" })]
364
- }) : e.error && !e.count ? /* @__PURE__ */ k("div", {
444
+ children: [/* @__PURE__ */ V(_, { className: "h-16 w-full" }), /* @__PURE__ */ V(_, { className: "h-16 w-full" })]
445
+ }) : e.error && !e.count ? /* @__PURE__ */ H("div", {
365
446
  className: "grid justify-items-start gap-2",
366
- children: [/* @__PURE__ */ O(h, { children: e.error.code === "forbidden" || e.error.code === "unauthorized" ? y(n, e.error) : r("moderation.loadFailed") }), /* @__PURE__ */ O(i, {
447
+ children: [/* @__PURE__ */ V(v, { children: e.error.code === "forbidden" || e.error.code === "unauthorized" ? S(n, e.error) : r("moderation.loadFailed") }), /* @__PURE__ */ V(i, {
367
448
  size: "sm",
368
449
  variant: "outline",
369
450
  onClick: e.reload,
370
451
  children: r("common.retry")
371
452
  })]
372
- }) : e.count ? /* @__PURE__ */ O("ul", {
453
+ }) : e.count ? /* @__PURE__ */ V("ul", {
373
454
  className: "grid divide-y divide-border rounded-lg border border-border",
374
455
  children: e.children
375
- }) : /* @__PURE__ */ O("p", {
456
+ }) : /* @__PURE__ */ V("p", {
376
457
  className: "text-muted-foreground",
377
458
  children: e.empty
378
459
  });
379
460
  }
380
461
  //#endregion
381
- export { j as CommentModeration };
462
+ export { G as CommentModeration, W as useCommentModerationAccess };
382
463
 
383
464
  //# sourceMappingURL=moderation.js.map