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