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