@openrails/contentkit-ui 0.79.0 → 0.81.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 (295) hide show
  1. package/README.md +82 -54
  2. package/dist/client/beacons.d.ts +53 -0
  3. package/dist/client/beacons.js +72 -0
  4. package/dist/client/beacons.js.map +1 -0
  5. package/dist/client/catalog.d.ts +2 -2
  6. package/dist/client/catalog.js +1 -1
  7. package/dist/client/catalog.js.map +1 -1
  8. package/dist/client/client.d.ts +24 -11
  9. package/dist/client/client.js +37 -29
  10. package/dist/client/client.js.map +1 -1
  11. package/dist/client/content/comments.d.ts +12 -8
  12. package/dist/client/content/comments.js +33 -20
  13. package/dist/client/content/comments.js.map +1 -1
  14. package/dist/client/content/favorites.d.ts +24 -9
  15. package/dist/client/content/favorites.js +21 -22
  16. package/dist/client/content/favorites.js.map +1 -1
  17. package/dist/client/content/moderation.d.ts +1 -1
  18. package/dist/client/content/moderation.js.map +1 -1
  19. package/dist/client/content/reactions.d.ts +11 -6
  20. package/dist/client/content/reactions.js +23 -18
  21. package/dist/client/content/reactions.js.map +1 -1
  22. package/dist/client/content/types.d.ts +40 -21
  23. package/dist/client/content/types.js +5 -2
  24. package/dist/client/content/types.js.map +1 -1
  25. package/dist/client/contents.d.ts +55 -0
  26. package/dist/client/contents.js +144 -0
  27. package/dist/client/contents.js.map +1 -0
  28. package/dist/client/discovery.d.ts +126 -0
  29. package/dist/client/discovery.js +125 -0
  30. package/dist/client/discovery.js.map +1 -0
  31. package/dist/client/generated/error-codes.d.ts +1 -1
  32. package/dist/client/generated/error-codes.js +12 -0
  33. package/dist/client/generated/error-codes.js.map +1 -1
  34. package/dist/client/generated/routes.d.ts +1244 -370
  35. package/dist/client/generated/routes.js +1870 -554
  36. package/dist/client/generated/routes.js.map +1 -1
  37. package/dist/client/generated/wire.d.ts +960 -134
  38. package/dist/client/generated/wire.js.map +1 -1
  39. package/dist/client/group-fields.d.ts +25 -0
  40. package/dist/client/group-fields.js +63 -0
  41. package/dist/client/group-fields.js.map +1 -0
  42. package/dist/client/groups.d.ts +58 -0
  43. package/dist/client/groups.js +119 -0
  44. package/dist/client/groups.js.map +1 -0
  45. package/dist/client/http.d.ts +24 -12
  46. package/dist/client/http.js +20 -24
  47. package/dist/client/http.js.map +1 -1
  48. package/dist/client/index.d.ts +11 -6
  49. package/dist/client/media/api.d.ts +1 -1
  50. package/dist/client/media/api.js +4 -2
  51. package/dist/client/media/api.js.map +1 -1
  52. package/dist/client/media/client.d.ts +8 -9
  53. package/dist/client/media/client.js +58 -71
  54. package/dist/client/media/client.js.map +1 -1
  55. package/dist/client/media/ref.d.ts +30 -0
  56. package/dist/client/media/ref.js +10 -3
  57. package/dist/client/media/ref.js.map +1 -1
  58. package/dist/client/offers.d.ts +41 -0
  59. package/dist/client/offers.js +66 -0
  60. package/dist/client/offers.js.map +1 -0
  61. package/dist/client/route.d.ts +2 -0
  62. package/dist/client/route.js +2 -1
  63. package/dist/client/route.js.map +1 -1
  64. package/dist/client/versions.d.ts +20 -0
  65. package/dist/client/versions.js +53 -0
  66. package/dist/client/versions.js.map +1 -0
  67. package/dist/client.js +35 -30
  68. package/dist/components/admin/content-manager.d.ts +80 -0
  69. package/dist/components/admin/content-manager.js +591 -0
  70. package/dist/components/admin/content-manager.js.map +1 -0
  71. package/dist/components/admin/group-manager.d.ts +24 -0
  72. package/dist/components/admin/group-manager.js +244 -0
  73. package/dist/components/admin/group-manager.js.map +1 -0
  74. package/dist/components/admin/media-item-panel.js +1 -1
  75. package/dist/components/admin/media-item-panel.js.map +1 -1
  76. package/dist/components/content/card.d.ts +44 -0
  77. package/dist/components/content/card.js +285 -0
  78. package/dist/components/content/card.js.map +1 -0
  79. package/dist/components/content/editors.d.ts +40 -0
  80. package/dist/components/content/editors.js +764 -0
  81. package/dist/components/content/editors.js.map +1 -0
  82. package/dist/components/content/filters.d.ts +28 -0
  83. package/dist/components/content/filters.js +134 -0
  84. package/dist/components/content/filters.js.map +1 -0
  85. package/dist/components/content/grid.d.ts +62 -0
  86. package/dist/components/content/grid.js +233 -0
  87. package/dist/components/content/grid.js.map +1 -0
  88. package/dist/components/content/index.d.ts +8 -0
  89. package/dist/components/content/listing.d.ts +20 -0
  90. package/dist/components/content/listing.js +150 -0
  91. package/dist/components/content/listing.js.map +1 -0
  92. package/dist/components/content/offer-fields.d.ts +8 -0
  93. package/dist/components/content/offer-fields.js +127 -0
  94. package/dist/components/content/offer-fields.js.map +1 -0
  95. package/dist/components/content/paywall.d.ts +53 -0
  96. package/dist/components/content/paywall.js +221 -0
  97. package/dist/components/content/paywall.js.map +1 -0
  98. package/dist/components/content/search.d.ts +27 -0
  99. package/dist/components/content/search.js +164 -0
  100. package/dist/components/content/search.js.map +1 -0
  101. package/dist/components/groups/banner.d.ts +51 -0
  102. package/dist/components/groups/banner.js +194 -0
  103. package/dist/components/groups/banner.js.map +1 -0
  104. package/dist/components/groups/directory.d.ts +37 -0
  105. package/dist/components/groups/directory.js +117 -0
  106. package/dist/components/groups/directory.js.map +1 -0
  107. package/dist/components/groups/editor.d.ts +44 -0
  108. package/dist/components/groups/editor.js +860 -0
  109. package/dist/components/groups/editor.js.map +1 -0
  110. package/dist/components/groups/fields.d.ts +13 -0
  111. package/dist/components/groups/fields.js +68 -0
  112. package/dist/components/groups/fields.js.map +1 -0
  113. package/dist/components/groups/header.d.ts +25 -0
  114. package/dist/components/groups/header.js +131 -0
  115. package/dist/components/groups/header.js.map +1 -0
  116. package/dist/components/groups/index.d.ts +6 -0
  117. package/dist/components/groups/memberships.d.ts +55 -0
  118. package/dist/components/groups/memberships.js +527 -0
  119. package/dist/components/groups/memberships.js.map +1 -0
  120. package/dist/components/groups/parts.d.ts +49 -0
  121. package/dist/components/groups/parts.js +172 -0
  122. package/dist/components/groups/parts.js.map +1 -0
  123. package/dist/components/media-folder-editor.js +153 -152
  124. package/dist/components/media-folder-editor.js.map +1 -1
  125. package/dist/components/social/comments.d.ts +7 -5
  126. package/dist/components/social/comments.js +6 -2
  127. package/dist/components/social/comments.js.map +1 -1
  128. package/dist/components/social/engagement.d.ts +4 -3
  129. package/dist/components/social/engagement.js.map +1 -1
  130. package/dist/components/social/moderation.d.ts +1 -1
  131. package/dist/components/social/moderation.js +3 -3
  132. package/dist/components/social/moderation.js.map +1 -1
  133. package/dist/editor/rich-text-editor.d.ts +4 -4
  134. package/dist/editor/rich-text-editor.js.map +1 -1
  135. package/dist/index.d.ts +4 -2
  136. package/dist/index.js +23 -9
  137. package/dist/locales/admin/de.js +5 -66
  138. package/dist/locales/admin/de.js.map +1 -1
  139. package/dist/locales/admin/en.d.ts +5 -66
  140. package/dist/locales/admin/en.js +19 -80
  141. package/dist/locales/admin/en.js.map +1 -1
  142. package/dist/locales/admin/es.js +5 -66
  143. package/dist/locales/admin/es.js.map +1 -1
  144. package/dist/locales/admin/ja.js +5 -66
  145. package/dist/locales/admin/ja.js.map +1 -1
  146. package/dist/locales/admin/ko.js +5 -66
  147. package/dist/locales/admin/ko.js.map +1 -1
  148. package/dist/locales/admin/zh.js +5 -66
  149. package/dist/locales/admin/zh.js.map +1 -1
  150. package/dist/locales/content/de.d.ts +2 -0
  151. package/dist/locales/content/de.js +98 -0
  152. package/dist/locales/content/de.js.map +1 -0
  153. package/dist/locales/content/en.d.ts +93 -0
  154. package/dist/locales/content/en.js +98 -0
  155. package/dist/locales/content/en.js.map +1 -0
  156. package/dist/locales/content/es.d.ts +2 -0
  157. package/dist/locales/content/es.js +98 -0
  158. package/dist/locales/content/es.js.map +1 -0
  159. package/dist/locales/content/ja.d.ts +2 -0
  160. package/dist/locales/content/ja.js +98 -0
  161. package/dist/locales/content/ja.js.map +1 -0
  162. package/dist/locales/content/ko.d.ts +2 -0
  163. package/dist/locales/content/ko.js +98 -0
  164. package/dist/locales/content/ko.js.map +1 -0
  165. package/dist/locales/content/zh.d.ts +2 -0
  166. package/dist/locales/content/zh.js +98 -0
  167. package/dist/locales/content/zh.js.map +1 -0
  168. package/dist/locales/de.js +11 -2
  169. package/dist/locales/de.js.map +1 -1
  170. package/dist/locales/discovery/de.d.ts +2 -0
  171. package/dist/locales/discovery/de.js +68 -0
  172. package/dist/locales/discovery/de.js.map +1 -0
  173. package/dist/locales/discovery/en.d.ts +63 -0
  174. package/dist/locales/discovery/en.js +68 -0
  175. package/dist/locales/discovery/en.js.map +1 -0
  176. package/dist/locales/discovery/es.d.ts +2 -0
  177. package/dist/locales/discovery/es.js +68 -0
  178. package/dist/locales/discovery/es.js.map +1 -0
  179. package/dist/locales/discovery/ja.d.ts +2 -0
  180. package/dist/locales/discovery/ja.js +68 -0
  181. package/dist/locales/discovery/ja.js.map +1 -0
  182. package/dist/locales/discovery/ko.d.ts +2 -0
  183. package/dist/locales/discovery/ko.js +68 -0
  184. package/dist/locales/discovery/ko.js.map +1 -0
  185. package/dist/locales/discovery/zh.d.ts +2 -0
  186. package/dist/locales/discovery/zh.js +68 -0
  187. package/dist/locales/discovery/zh.js.map +1 -0
  188. package/dist/locales/en.d.ts +288 -67
  189. package/dist/locales/en.js +11 -2
  190. package/dist/locales/en.js.map +1 -1
  191. package/dist/locales/es.js +11 -2
  192. package/dist/locales/es.js.map +1 -1
  193. package/dist/locales/groups/de.d.ts +2 -0
  194. package/dist/locales/groups/de.js +133 -0
  195. package/dist/locales/groups/de.js.map +1 -0
  196. package/dist/locales/groups/en.d.ts +128 -0
  197. package/dist/locales/groups/en.js +133 -0
  198. package/dist/locales/groups/en.js.map +1 -0
  199. package/dist/locales/groups/es.d.ts +2 -0
  200. package/dist/locales/groups/es.js +133 -0
  201. package/dist/locales/groups/es.js.map +1 -0
  202. package/dist/locales/groups/ja.d.ts +2 -0
  203. package/dist/locales/groups/ja.js +133 -0
  204. package/dist/locales/groups/ja.js.map +1 -0
  205. package/dist/locales/groups/ko.d.ts +2 -0
  206. package/dist/locales/groups/ko.js +133 -0
  207. package/dist/locales/groups/ko.js.map +1 -0
  208. package/dist/locales/groups/zh.d.ts +2 -0
  209. package/dist/locales/groups/zh.js +133 -0
  210. package/dist/locales/groups/zh.js.map +1 -0
  211. package/dist/locales/ja.js +11 -2
  212. package/dist/locales/ja.js.map +1 -1
  213. package/dist/locales/ko.js +11 -2
  214. package/dist/locales/ko.js.map +1 -1
  215. package/dist/locales/social/de.js +2 -1
  216. package/dist/locales/social/de.js.map +1 -1
  217. package/dist/locales/social/en.d.ts +2 -1
  218. package/dist/locales/social/en.js +2 -1
  219. package/dist/locales/social/en.js.map +1 -1
  220. package/dist/locales/social/es.js +2 -1
  221. package/dist/locales/social/es.js.map +1 -1
  222. package/dist/locales/social/ja.js +2 -1
  223. package/dist/locales/social/ja.js.map +1 -1
  224. package/dist/locales/social/ko.js +2 -1
  225. package/dist/locales/social/ko.js.map +1 -1
  226. package/dist/locales/social/zh.js +2 -1
  227. package/dist/locales/social/zh.js.map +1 -1
  228. package/dist/locales/zh.js +11 -2
  229. package/dist/locales/zh.js.map +1 -1
  230. package/dist/react/admin.d.ts +1 -1
  231. package/dist/react/admin.js +8 -6
  232. package/dist/react/admin.js.map +1 -1
  233. package/dist/react/comments.d.ts +9 -7
  234. package/dist/react/comments.js +42 -27
  235. package/dist/react/comments.js.map +1 -1
  236. package/dist/react/contents.d.ts +57 -0
  237. package/dist/react/contents.js +214 -0
  238. package/dist/react/contents.js.map +1 -0
  239. package/dist/react/context.d.ts +1 -1
  240. package/dist/react/context.js.map +1 -1
  241. package/dist/react/crop.js +45 -44
  242. package/dist/react/crop.js.map +1 -1
  243. package/dist/react/detail.d.ts +30 -0
  244. package/dist/react/detail.js +42 -0
  245. package/dist/react/detail.js.map +1 -0
  246. package/dist/react/discovery.d.ts +138 -0
  247. package/dist/react/discovery.js +299 -0
  248. package/dist/react/discovery.js.map +1 -0
  249. package/dist/react/engagement.d.ts +5 -5
  250. package/dist/react/engagement.js +55 -41
  251. package/dist/react/engagement.js.map +1 -1
  252. package/dist/react/folder.js +54 -53
  253. package/dist/react/folder.js.map +1 -1
  254. package/dist/react/groups.d.ts +115 -0
  255. package/dist/react/groups.js +229 -0
  256. package/dist/react/groups.js.map +1 -0
  257. package/dist/react/index.d.ts +5 -1
  258. package/dist/react/public.d.ts +6 -5
  259. package/dist/react/public.js +19 -22
  260. package/dist/react/public.js.map +1 -1
  261. package/dist/react/read.js +105 -106
  262. package/dist/react/read.js.map +1 -1
  263. package/dist/react/resources.d.ts +2 -2
  264. package/dist/react/resources.js +69 -40
  265. package/dist/react/resources.js.map +1 -1
  266. package/dist/react/store.js +41 -39
  267. package/dist/react/store.js.map +1 -1
  268. package/dist/react/upload.js +54 -53
  269. package/dist/react/upload.js.map +1 -1
  270. package/dist/react/use-resource.d.ts +2 -1
  271. package/dist/react/use-resource.js +1 -0
  272. package/dist/react/use-resource.js.map +1 -1
  273. package/dist/react/versions.d.ts +57 -0
  274. package/dist/react/versions.js +94 -0
  275. package/dist/react/versions.js.map +1 -0
  276. package/dist/react/video.js +87 -86
  277. package/dist/react/video.js.map +1 -1
  278. package/dist/react.js +9 -5
  279. package/dist/styles.css +1 -1
  280. package/package.json +1 -1
  281. package/dist/client/content/posts.d.ts +0 -52
  282. package/dist/client/content/posts.js +0 -84
  283. package/dist/client/content/posts.js.map +0 -1
  284. package/dist/client/taxonomy.d.ts +0 -34
  285. package/dist/client/taxonomy.js +0 -84
  286. package/dist/client/taxonomy.js.map +0 -1
  287. package/dist/components/admin/post-manager.d.ts +0 -45
  288. package/dist/components/admin/post-manager.js +0 -602
  289. package/dist/components/admin/post-manager.js.map +0 -1
  290. package/dist/components/admin/taxonomy-manager.d.ts +0 -54
  291. package/dist/components/admin/taxonomy-manager.js +0 -976
  292. package/dist/components/admin/taxonomy-manager.js.map +0 -1
  293. package/dist/react/posts.d.ts +0 -61
  294. package/dist/react/posts.js +0 -183
  295. package/dist/react/posts.js.map +0 -1
@@ -1,602 +0,0 @@
1
- import { toContentKitError as e } from "../../client/errors.js";
2
- import { useMessages as t } from "../../i18n/context.js";
3
- import { useErrorReporter as n } from "../../react/context.js";
4
- import { Alert as r, AlertDescription as i } from "../../ui/alert.js";
5
- import { Button as a, buttonVariants as o } from "../../ui/button.js";
6
- import { keyOf as s, useContentScope as c, usePaged as l } from "../../react/use-resource.js";
7
- import { Badge as ee } 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 { Textarea as v } from "../../ui/textarea.js";
13
- import { ErrorLine as y, RelativeTime as b, contentError as x, formatDate as te, useAction as ne } from "../social/parts.js";
14
- import { AdminRoot as S, LoadFailed as re, NoAccess as C, Pager as w, Rows as T, pageOf as E, useConfirm as ie } from "./shell.js";
15
- import { localInput as D } from "../social/bans.js";
16
- import { imageRefs as O } from "../../client/content/posts.js";
17
- import { useAdminLocation as k, useFlowClient as A, useStaffAccess as j } from "../../react/admin.js";
18
- import { usePost as M } from "../../react/posts.js";
19
- import { useEffect as N, useId as P, useMemo as F, useRef as I, useState as L } from "react";
20
- import { Fragment as R, jsx as z, jsxs as B } from "react/jsx-runtime";
21
- //#region src/components/admin/post-manager.tsx
22
- function V(e = {}) {
23
- return j(["posts"], e);
24
- }
25
- function H(e, t = Date.now()) {
26
- return e.moderation === "rejected" ? "rejected" : e.moderation === "held" ? "held" : e.is_draft ? "draft" : e.live_at && Date.parse(e.live_at) > t ? "scheduled" : "published";
27
- }
28
- var ae = (e) => (e ?? []).map((e) => typeof e == "string" ? {
29
- value: e,
30
- label: e
31
- } : e), oe = {
32
- published: "default",
33
- scheduled: "secondary",
34
- draft: "outline",
35
- held: "secondary",
36
- rejected: "destructive"
37
- };
38
- function U({ client: e, baseUrl: t, auth: n, guard: r, appearance: i, className: a, language: o, messages: s, ...c }) {
39
- let l = A({
40
- client: e,
41
- baseUrl: t,
42
- auth: n
43
- });
44
- return /* @__PURE__ */ z(S, {
45
- flow: "post-manager",
46
- appearance: i,
47
- className: a,
48
- language: o,
49
- messages: s,
50
- guard: r,
51
- children: /* @__PURE__ */ z(W, {
52
- ...c,
53
- client: l
54
- })
55
- });
56
- }
57
- function W({ basePath: e, navigation: n, ...r }) {
58
- let { t: i } = t(), o = k(e, n), s = V({ client: r.client });
59
- return s.loading ? /* @__PURE__ */ z(T, {}) : s.allowed.posts ? o.view ? /* @__PURE__ */ B(R, { children: [/* @__PURE__ */ z(a, {
60
- variant: "ghost",
61
- size: "sm",
62
- className: "justify-self-start",
63
- onClick: () => o.go(""),
64
- children: i("postManager.back")
65
- }), /* @__PURE__ */ z(q, {
66
- ...r,
67
- loc: o,
68
- id: o.view === "new" ? null : o.view
69
- }, o.view)] }) : /* @__PURE__ */ z(G, {
70
- ...r,
71
- loc: o
72
- }) : /* @__PURE__ */ z(C, { children: i("postManager.noAccess") });
73
- }
74
- function G({ loc: e, client: n, languages: r, postHref: i, pageSize: _ = 20, onError: v }) {
75
- let x = t(), { t: S } = x, C = P(), D = ae(r), O = e.query.get("q") ?? "", k = e.query.get("language") ?? "", A = e.query.get("status") === "draft" ? "draft" : e.query.get("status") === "live" ? "live" : "", j = e.query.get("deleted") === "1", M = E(e.query), F = {
76
- q: O,
77
- language: k,
78
- status: A,
79
- deleted: j ? "1" : void 0
80
- }, I = (t) => e.go("", {
81
- ...F,
82
- ...t
83
- }), [V, U] = L(O);
84
- N(() => U(O), [O]);
85
- let { store: W, scope: G } = c(n), K = l(W, s("posts-page", G, O, k, A, j, _), {
86
- type: "posts",
87
- scope: j ? "deleted" : void 0
88
- }, M, _, (e, t) => n.posts.adminList({
89
- ...e,
90
- q: O || void 0,
91
- language: k || void 0,
92
- draft: j || !A ? void 0 : A === "draft",
93
- deleted: j || void 0
94
- }, t)), q = ne("post.save", v), { confirm: se, dialog: J } = ie(), Y = async (e) => {
95
- await se({
96
- title: S("postManager.deleteTitle", { title: e.title }),
97
- description: S("postManager.deleteBody"),
98
- confirm: S("postManager.delete")
99
- }) && await q.run(() => n.posts.delete(e.id));
100
- };
101
- return /* @__PURE__ */ B("div", {
102
- className: "grid gap-4",
103
- children: [
104
- /* @__PURE__ */ B("div", {
105
- className: "flex flex-wrap items-center justify-between gap-2",
106
- children: [/* @__PURE__ */ z("h2", {
107
- className: "text-base font-semibold",
108
- children: S("postManager.title")
109
- }), /* @__PURE__ */ z(a, {
110
- size: "sm",
111
- onClick: () => e.go("new"),
112
- children: S("postManager.new")
113
- })]
114
- }),
115
- /* @__PURE__ */ B("div", {
116
- className: "flex gap-2",
117
- role: "group",
118
- "aria-label": S("postManager.title"),
119
- children: [/* @__PURE__ */ z(a, {
120
- size: "sm",
121
- variant: j ? "outline" : "default",
122
- "aria-pressed": !j,
123
- onClick: () => e.go("", {
124
- q: O,
125
- language: k
126
- }),
127
- children: S("postManager.posts")
128
- }), /* @__PURE__ */ z(a, {
129
- size: "sm",
130
- variant: j ? "default" : "outline",
131
- "aria-pressed": j,
132
- onClick: () => e.go("", {
133
- q: O,
134
- language: k,
135
- deleted: "1"
136
- }),
137
- children: S("postManager.deleted")
138
- })]
139
- }),
140
- /* @__PURE__ */ B("div", {
141
- className: "grid gap-2 sm:grid-cols-[minmax(0,1fr)_auto]",
142
- children: [/* @__PURE__ */ B("form", {
143
- className: "flex gap-2",
144
- role: "search",
145
- onSubmit: (e) => {
146
- e.preventDefault(), I({ q: V.trim() });
147
- },
148
- children: [
149
- /* @__PURE__ */ z(d, {
150
- htmlFor: `${C}-q`,
151
- className: "sr-only",
152
- children: S("postManager.search")
153
- }),
154
- /* @__PURE__ */ z(u, {
155
- id: `${C}-q`,
156
- className: "h-8",
157
- type: "search",
158
- value: V,
159
- placeholder: S("postManager.search"),
160
- onChange: (e) => U(e.target.value)
161
- }),
162
- /* @__PURE__ */ z(a, {
163
- type: "submit",
164
- size: "sm",
165
- variant: "outline",
166
- children: S("moderation.filter")
167
- })
168
- ]
169
- }), /* @__PURE__ */ B("div", {
170
- className: "flex flex-wrap gap-2",
171
- children: [D.length > 0 && /* @__PURE__ */ B(f, {
172
- value: k,
173
- onValueChange: (e) => I({ language: String(e ?? "") }),
174
- children: [/* @__PURE__ */ z(h, {
175
- size: "sm",
176
- "aria-label": S("postManager.language"),
177
- children: /* @__PURE__ */ z(g, { children: (e) => e ? D.find((t) => t.value === e)?.label ?? e : S("pollManager.allLanguages") })
178
- }), /* @__PURE__ */ B(p, { children: [/* @__PURE__ */ z(m, {
179
- value: "",
180
- children: S("pollManager.allLanguages")
181
- }), D.map((e) => /* @__PURE__ */ z(m, {
182
- value: e.value,
183
- children: e.label
184
- }, e.value))] })]
185
- }), !j && /* @__PURE__ */ B(f, {
186
- value: A,
187
- onValueChange: (e) => I({ status: String(e ?? "") }),
188
- children: [/* @__PURE__ */ z(h, {
189
- size: "sm",
190
- "aria-label": S("postManager.status"),
191
- children: /* @__PURE__ */ z(g, { children: (e) => S(e === "draft" ? "postManager.drafts" : e === "live" ? "postManager.notDrafts" : "postManager.allStatuses") })
192
- }), /* @__PURE__ */ B(p, { children: [
193
- /* @__PURE__ */ z(m, {
194
- value: "",
195
- children: S("postManager.allStatuses")
196
- }),
197
- /* @__PURE__ */ z(m, {
198
- value: "draft",
199
- children: S("postManager.drafts")
200
- }),
201
- /* @__PURE__ */ z(m, {
202
- value: "live",
203
- children: S("postManager.notDrafts")
204
- })
205
- ] })]
206
- })]
207
- })]
208
- }),
209
- /* @__PURE__ */ z(y, { error: q.error }),
210
- K.loading && !K.items.length ? /* @__PURE__ */ z(T, {}) : K.error && !K.items.length ? /* @__PURE__ */ z(re, {
211
- error: K.error,
212
- message: S("postManager.loadFailed"),
213
- retry: K.reload
214
- }) : K.items.length ? /* @__PURE__ */ z("ul", {
215
- className: "grid divide-y divide-border rounded-lg border border-border",
216
- "aria-busy": K.loading,
217
- children: K.items.map((t) => {
218
- let r = H(t), s = r === "published" ? i?.(t) : void 0;
219
- return /* @__PURE__ */ B("li", {
220
- className: "flex flex-wrap items-start gap-3 p-3",
221
- "data-ckui": "post-row",
222
- "data-status": j ? "deleted" : r,
223
- children: [/* @__PURE__ */ B("div", {
224
- className: "grid min-w-0 flex-1 gap-1",
225
- children: [j ? /* @__PURE__ */ z("span", {
226
- className: "font-medium break-words",
227
- children: t.title
228
- }) : /* @__PURE__ */ z("button", {
229
- type: "button",
230
- className: "text-left font-medium break-words hover:underline",
231
- onClick: () => e.go(t.id),
232
- children: t.title
233
- }), /* @__PURE__ */ B("div", {
234
- className: "flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground",
235
- children: [
236
- !j && /* @__PURE__ */ z(ee, {
237
- variant: oe[r],
238
- children: S(`postManager.${r}`)
239
- }),
240
- /* @__PURE__ */ z("span", { children: t.language }),
241
- /* @__PURE__ */ z(b, { at: j && t.deleted_at ? t.deleted_at : t.updated_at }),
242
- r === "scheduled" && t.live_at && /* @__PURE__ */ z("span", { children: S("pollManager.goesLive", { date: te(x, t.live_at) }) })
243
- ]
244
- })]
245
- }), /* @__PURE__ */ z("div", {
246
- className: "flex flex-wrap gap-2",
247
- children: j ? /* @__PURE__ */ z(a, {
248
- size: "sm",
249
- variant: "outline",
250
- disabled: q.pending,
251
- onClick: () => void q.run(() => n.posts.restore(t.id)),
252
- children: S("moderation.restore")
253
- }) : /* @__PURE__ */ B(R, { children: [
254
- s && /* @__PURE__ */ z("a", {
255
- className: o({
256
- size: "sm",
257
- variant: "ghost"
258
- }),
259
- href: s,
260
- children: S("postManager.view")
261
- }),
262
- /* @__PURE__ */ z(a, {
263
- size: "sm",
264
- variant: "outline",
265
- onClick: () => e.go(t.id),
266
- children: S("comments.edit")
267
- }),
268
- /* @__PURE__ */ z(a, {
269
- size: "sm",
270
- variant: "destructive",
271
- disabled: q.pending,
272
- onClick: () => void Y(t),
273
- children: S("comments.delete")
274
- })
275
- ] })
276
- })]
277
- }, t.id);
278
- })
279
- }) : /* @__PURE__ */ z("p", {
280
- className: "text-muted-foreground",
281
- children: S(j ? "postManager.noDeleted" : "postManager.empty")
282
- }),
283
- /* @__PURE__ */ z(w, {
284
- page: M,
285
- hasNext: K.hasNext,
286
- disabled: K.loading,
287
- onPage: (t) => e.go("", {
288
- ...F,
289
- page: t > 1 ? t : void 0
290
- })
291
- }),
292
- J
293
- ]
294
- });
295
- }
296
- var K = (e) => ({
297
- title: e.title,
298
- slug: e.slug ?? "",
299
- language: e.language,
300
- excerpt: e.excerpt ?? "",
301
- liveAt: e.live_at ? D(new Date(e.live_at)) : "",
302
- body: e.body
303
- });
304
- function q({ id: o, loc: s, client: c, languages: l, renderEditor: b, postHref: te, onError: ne }) {
305
- let S = t(), { t: C } = S, w = P(), T = ae(l), E = M(o, { client: c }), D = n(ne), [k, A] = L(o ? null : {
306
- title: "",
307
- slug: "",
308
- language: T[0]?.value ?? "en",
309
- excerpt: "",
310
- liveAt: "",
311
- body: ""
312
- }), [j, I] = L(null), [R, V] = L(null), { confirm: U, dialog: W } = ie();
313
- N(() => {
314
- E.post && A((e) => e ?? K(E.post));
315
- }, [E.post]);
316
- let { imageSrc: G } = E, q = F(() => (k?.body ?? "").replace(O(), (e, t) => {
317
- let n = G(t);
318
- return n && n !== t ? n.replaceAll("&", "&") : e;
319
- }), [k?.body, G]);
320
- if (o && !k) return E.error ? /* @__PURE__ */ z(re, {
321
- error: E.error,
322
- message: C("postManager.loadFailed"),
323
- retry: () => s.go(o, void 0, { replace: !0 })
324
- }) : /* @__PURE__ */ B("div", {
325
- className: "grid gap-3",
326
- "aria-busy": !0,
327
- children: [/* @__PURE__ */ z(_, { className: "h-9 w-full" }), /* @__PURE__ */ z(_, { className: "h-48 w-full" })]
328
- });
329
- let J = k, Y = (e) => A((t) => ({
330
- ...t,
331
- ...e
332
- })), X = (t) => {
333
- let n = e(t);
334
- I(n), D(n, "post.save");
335
- }, ce = (e) => ({
336
- title: J.title.trim(),
337
- slug: J.slug.trim() || void 0,
338
- language: J.language,
339
- excerpt: J.excerpt.trim(),
340
- body: J.body,
341
- live_at: J.liveAt ? new Date(J.liveAt).toISOString() : void 0,
342
- ...e === void 0 ? {} : { is_draft: e }
343
- }), le = async (e) => {
344
- if (I(null), V(null), !J.title.trim()) return I(C("postManager.titleRequired"));
345
- try {
346
- if (!E.post) {
347
- let e = await E.create({
348
- ...ce(),
349
- is_draft: !0
350
- });
351
- s.go(e.id, void 0, { replace: !0 });
352
- return;
353
- }
354
- let t = await E.update(ce(e));
355
- V(C(e === !1 ? "postManager.publishedNotice" : e === !0 ? "postManager.unpublishedNotice" : "pollEditor.saved")), A((e) => ({
356
- ...e,
357
- slug: t.slug ?? ""
358
- }));
359
- } catch (e) {
360
- X(e);
361
- }
362
- }, ue = async () => {
363
- if (E.post && await U({
364
- title: C("postManager.deleteTitle", { title: E.post.title }),
365
- description: C("postManager.deleteBody"),
366
- confirm: C("postManager.delete")
367
- })) try {
368
- await E.remove(), s.go("", void 0, { replace: !0 });
369
- } catch (e) {
370
- X(e);
371
- }
372
- }, Z = E.post, Q = Z ? H(Z) : "draft", de = Z && Q === "published" ? te?.(Z) : void 0, $ = {
373
- value: q,
374
- onChange: (e) => Y({ body: E.storedBody(e) }),
375
- uploadImage: Z ? (e) => E.uploadImage(e) : void 0,
376
- disabled: E.saving,
377
- placeholder: C("postManager.bodyPlaceholder"),
378
- "aria-label": C("postManager.body")
379
- };
380
- return /* @__PURE__ */ B("form", {
381
- className: "grid gap-4",
382
- "data-ckui": "post-form",
383
- onSubmit: (e) => {
384
- e.preventDefault(), le();
385
- },
386
- children: [
387
- /* @__PURE__ */ B("div", {
388
- className: "flex flex-wrap items-center gap-2",
389
- children: [
390
- /* @__PURE__ */ z("h2", {
391
- className: "text-base font-semibold",
392
- children: C(Z ? "postManager.editTitle" : "postManager.newTitle")
393
- }),
394
- Z && /* @__PURE__ */ z(ee, {
395
- variant: oe[Q],
396
- children: C(`postManager.${Q}`)
397
- }),
398
- de && /* @__PURE__ */ z("a", {
399
- className: "text-xs text-muted-foreground hover:underline",
400
- href: de,
401
- children: C("postManager.view")
402
- })
403
- ]
404
- }),
405
- Z?.moderation && /* @__PURE__ */ z(r, {
406
- variant: Z.moderation === "rejected" ? "destructive" : "default",
407
- children: /* @__PURE__ */ z(i, { children: Z.moderation_reason ? C(`postManager.${Z.moderation === "rejected" ? "rejectedBecause" : "heldBecause"}`, { reason: Z.moderation_reason }) : C(`postManager.${Z.moderation === "rejected" ? "rejectedNote" : "heldNote"}`) })
408
- }),
409
- /* @__PURE__ */ B("div", {
410
- className: "grid gap-1.5",
411
- children: [/* @__PURE__ */ z(d, {
412
- htmlFor: `${w}-title`,
413
- children: C("postManager.postTitle")
414
- }), /* @__PURE__ */ z(u, {
415
- id: `${w}-title`,
416
- value: J.title,
417
- required: !0,
418
- maxLength: 300,
419
- onChange: (e) => Y({ title: e.target.value })
420
- })]
421
- }),
422
- /* @__PURE__ */ B("div", {
423
- className: "grid gap-4 sm:grid-cols-2",
424
- children: [
425
- /* @__PURE__ */ B("div", {
426
- className: "grid gap-1.5",
427
- children: [/* @__PURE__ */ z(d, {
428
- htmlFor: `${w}-slug`,
429
- children: C("postManager.slug")
430
- }), /* @__PURE__ */ z(u, {
431
- id: `${w}-slug`,
432
- value: J.slug,
433
- placeholder: C("postManager.slugAuto"),
434
- onChange: (e) => Y({ slug: e.target.value })
435
- })]
436
- }),
437
- /* @__PURE__ */ B("div", {
438
- className: "grid gap-1.5",
439
- children: [/* @__PURE__ */ z(d, {
440
- htmlFor: `${w}-lang`,
441
- children: C("postManager.language")
442
- }), T.length ? /* @__PURE__ */ B(f, {
443
- value: J.language,
444
- onValueChange: (e) => Y({ language: String(e ?? "") }),
445
- children: [/* @__PURE__ */ z(h, {
446
- id: `${w}-lang`,
447
- className: "w-full",
448
- children: /* @__PURE__ */ z(g, { children: (e) => T.find((t) => t.value === e)?.label ?? e })
449
- }), /* @__PURE__ */ z(p, { children: T.map((e) => /* @__PURE__ */ z(m, {
450
- value: e.value,
451
- children: e.label
452
- }, e.value)) })]
453
- }) : /* @__PURE__ */ z(u, {
454
- id: `${w}-lang`,
455
- value: J.language,
456
- onChange: (e) => Y({ language: e.target.value })
457
- })]
458
- }),
459
- /* @__PURE__ */ B("div", {
460
- className: "grid gap-1.5",
461
- children: [/* @__PURE__ */ z(d, {
462
- htmlFor: `${w}-live`,
463
- children: C("postManager.liveAt")
464
- }), /* @__PURE__ */ z(u, {
465
- id: `${w}-live`,
466
- type: "datetime-local",
467
- value: J.liveAt,
468
- onChange: (e) => Y({ liveAt: e.target.value })
469
- })]
470
- })
471
- ]
472
- }),
473
- /* @__PURE__ */ B("div", {
474
- className: "grid gap-1.5",
475
- children: [/* @__PURE__ */ z(d, {
476
- htmlFor: `${w}-excerpt`,
477
- children: C("postManager.excerpt")
478
- }), /* @__PURE__ */ z(v, {
479
- id: `${w}-excerpt`,
480
- rows: 2,
481
- value: J.excerpt,
482
- onChange: (e) => Y({ excerpt: e.target.value })
483
- })]
484
- }),
485
- /* @__PURE__ */ z(se, {
486
- post: Z,
487
- src: E.coverSrc,
488
- saving: E.saving,
489
- onFile: (e) => void E.setCover(e).catch(X)
490
- }),
491
- /* @__PURE__ */ B("div", {
492
- className: "grid gap-1.5",
493
- children: [
494
- /* @__PURE__ */ z("span", {
495
- className: "text-sm font-medium",
496
- children: C("postManager.body")
497
- }),
498
- b ? b($) : /* @__PURE__ */ z(v, {
499
- "aria-label": $["aria-label"],
500
- rows: 12,
501
- value: J.body,
502
- placeholder: $.placeholder,
503
- onChange: (e) => Y({ body: e.target.value })
504
- }),
505
- !Z && /* @__PURE__ */ z("p", {
506
- className: "text-xs text-muted-foreground",
507
- children: C("postManager.imagesAfterCreate")
508
- })
509
- ]
510
- }),
511
- j && /* @__PURE__ */ z(y, { children: typeof j == "string" ? j : x(S, j) }),
512
- R && !j && /* @__PURE__ */ z("p", {
513
- role: "status",
514
- className: "text-sm text-muted-foreground",
515
- children: R
516
- }),
517
- /* @__PURE__ */ B("div", {
518
- className: "flex flex-wrap gap-2 border-t border-border pt-4",
519
- children: [
520
- /* @__PURE__ */ z(a, {
521
- type: "submit",
522
- disabled: E.saving,
523
- children: E.saving ? C("common.saving") : C(Z ? "common.save" : "postManager.createDraft")
524
- }),
525
- Z && /* @__PURE__ */ z(a, {
526
- type: "button",
527
- variant: "outline",
528
- disabled: E.saving,
529
- onClick: () => void le(!Z.is_draft),
530
- children: C(Z.is_draft ? "postManager.publish" : "postManager.unpublish")
531
- }),
532
- Z && /* @__PURE__ */ z(a, {
533
- type: "button",
534
- variant: "destructive",
535
- className: "ms-auto",
536
- disabled: E.saving,
537
- onClick: () => void ue(),
538
- children: C("postManager.delete")
539
- })
540
- ]
541
- }),
542
- W
543
- ]
544
- });
545
- }
546
- function se({ post: e, src: n, saving: r, onFile: i }) {
547
- let { t: o } = t(), s = I(null);
548
- return /* @__PURE__ */ B("div", {
549
- className: "grid gap-1.5",
550
- "data-ckui": "post-cover",
551
- children: [/* @__PURE__ */ z("span", {
552
- className: "text-sm font-medium",
553
- children: o("postManager.cover")
554
- }), e ? /* @__PURE__ */ B("div", {
555
- className: "flex flex-wrap items-center gap-3",
556
- children: [
557
- n ? /* @__PURE__ */ z("img", {
558
- src: n,
559
- alt: "",
560
- className: "h-20 w-36 rounded-md border border-border object-cover"
561
- }) : /* @__PURE__ */ z("span", {
562
- className: "text-muted-foreground",
563
- children: o("postManager.noCover")
564
- }),
565
- /* @__PURE__ */ z(a, {
566
- type: "button",
567
- size: "sm",
568
- variant: "outline",
569
- disabled: r,
570
- onClick: () => s.current?.click(),
571
- children: o(n ? "pollEditor.replaceImage" : "postManager.addCover")
572
- }),
573
- n && /* @__PURE__ */ z(a, {
574
- type: "button",
575
- size: "sm",
576
- variant: "ghost",
577
- disabled: r,
578
- onClick: () => i(null),
579
- children: o("pollEditor.removeImage")
580
- }),
581
- /* @__PURE__ */ z("input", {
582
- ref: s,
583
- type: "file",
584
- accept: "image/*",
585
- hidden: !0,
586
- "aria-label": o("postManager.cover"),
587
- onChange: (e) => {
588
- let t = e.target.files?.[0];
589
- e.target.value = "", t && i(t);
590
- }
591
- })
592
- ]
593
- }) : /* @__PURE__ */ z("p", {
594
- className: "text-xs text-muted-foreground",
595
- children: o("postManager.imagesAfterCreate")
596
- })]
597
- });
598
- }
599
- //#endregion
600
- export { U as PostManager, H as postStatus, V as usePostManagerAccess };
601
-
602
- //# sourceMappingURL=post-manager.js.map