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