@openrails/contentkit-ui 0.103.1 → 0.103.2

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