@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.
- package/README.md +9 -1
- package/dist/client/discovery.d.ts +2 -1
- package/dist/client/discovery.js.map +1 -1
- package/dist/client/entities.d.ts +6 -0
- package/dist/client/entities.js +13 -0
- package/dist/client/entities.js.map +1 -1
- package/dist/client/generated/routes.d.ts +26 -0
- package/dist/client/generated/routes.js +44 -0
- package/dist/client/generated/routes.js.map +1 -1
- package/dist/client/generated/wire.d.ts +7 -11
- package/dist/client/generated/wire.js.map +1 -1
- package/dist/client/http.d.ts +1 -0
- package/dist/client/http.js +5 -4
- package/dist/client/http.js.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/reader-preferences.js +3 -7
- package/dist/client/reader-preferences.js.map +1 -1
- package/dist/components/admin/content-manager.d.ts +3 -1
- package/dist/components/admin/content-manager.js +241 -239
- package/dist/components/admin/content-manager.js.map +1 -1
- package/dist/components/admin/group-manager.js +133 -119
- package/dist/components/admin/group-manager.js.map +1 -1
- package/dist/components/content/editors.d.ts +1 -0
- package/dist/components/content/editors.js +1 -0
- package/dist/components/content/editors.js.map +1 -1
- package/dist/components/content/filters.d.ts +1 -1
- package/dist/components/content/filters.js +1 -1
- package/dist/components/content/filters.js.map +1 -1
- package/dist/components/groups/banner.d.ts +3 -1
- package/dist/components/groups/banner.js +29 -26
- package/dist/components/groups/banner.js.map +1 -1
- package/dist/components/groups/editor.d.ts +4 -1
- package/dist/components/groups/editor.js +369 -315
- package/dist/components/groups/editor.js.map +1 -1
- package/dist/components/groups/memberships.d.ts +2 -0
- package/dist/components/groups/memberships.js +1 -0
- package/dist/components/groups/memberships.js.map +1 -1
- package/dist/components/groups/parts.d.ts +4 -1
- package/dist/components/groups/parts.js +32 -30
- package/dist/components/groups/parts.js.map +1 -1
- package/dist/locales/en.d.ts +2 -0
- package/dist/locales/groups/de.js +2 -0
- package/dist/locales/groups/de.js.map +1 -1
- package/dist/locales/groups/en.d.ts +2 -0
- package/dist/locales/groups/en.js +2 -0
- package/dist/locales/groups/en.js.map +1 -1
- package/dist/locales/groups/es.js +2 -0
- package/dist/locales/groups/es.js.map +1 -1
- package/dist/locales/groups/ja.js +2 -0
- package/dist/locales/groups/ja.js.map +1 -1
- package/dist/locales/groups/ko.js +2 -0
- package/dist/locales/groups/ko.js.map +1 -1
- package/dist/locales/groups/zh.js +2 -0
- package/dist/locales/groups/zh.js.map +1 -1
- package/dist/react/discovery.d.ts +2 -1
- package/dist/react/discovery.js +54 -29
- package/dist/react/discovery.js.map +1 -1
- package/dist/react/groups.d.ts +3 -1
- package/dist/react/groups.js +7 -7
- package/dist/react/groups.js.map +1 -1
- 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
|
|
16
|
-
import { localInput as
|
|
17
|
-
import { imageRefs as
|
|
18
|
-
import { useAdminLocation as
|
|
19
|
-
import { ContentSections as
|
|
20
|
-
import { useContent as
|
|
21
|
-
import { useEffect as
|
|
22
|
-
import { Fragment as
|
|
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
|
|
25
|
-
return
|
|
24
|
+
function P(e = {}) {
|
|
25
|
+
return T(["contents"], e);
|
|
26
26
|
}
|
|
27
|
-
function
|
|
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
|
|
30
|
+
var he = (e) => (e ?? []).map((e) => typeof e == "string" ? {
|
|
31
31
|
value: e,
|
|
32
32
|
label: e
|
|
33
|
-
} : e),
|
|
33
|
+
} : e), ge = {
|
|
34
34
|
published: "default",
|
|
35
35
|
scheduled: "secondary",
|
|
36
36
|
draft: "outline",
|
|
37
37
|
held: "secondary",
|
|
38
38
|
rejected: "destructive"
|
|
39
|
-
},
|
|
39
|
+
}, I = [
|
|
40
40
|
"draft",
|
|
41
41
|
"scheduled",
|
|
42
42
|
"published"
|
|
43
43
|
];
|
|
44
|
-
function
|
|
45
|
-
let l =
|
|
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__ */
|
|
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__ */
|
|
57
|
+
children: /* @__PURE__ */ M(R, {
|
|
58
58
|
...c,
|
|
59
59
|
client: l
|
|
60
60
|
})
|
|
61
61
|
});
|
|
62
62
|
}
|
|
63
|
-
function
|
|
64
|
-
let { t: i } = t(), a =
|
|
65
|
-
return o.loading ? /* @__PURE__ */
|
|
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__ */
|
|
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__ */
|
|
77
|
+
}, a.view)] }) : /* @__PURE__ */ M(z, {
|
|
77
78
|
...r,
|
|
78
79
|
loc: a
|
|
79
|
-
}) : /* @__PURE__ */
|
|
80
|
+
}) : /* @__PURE__ */ M(y, { children: i("contentManager.noAccess") });
|
|
80
81
|
}
|
|
81
|
-
function
|
|
82
|
-
let h = t(), { t: _ } = h, v =
|
|
83
|
-
q:
|
|
84
|
-
status:
|
|
85
|
-
deleted:
|
|
86
|
-
},
|
|
87
|
-
...
|
|
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
|
-
}), [
|
|
90
|
-
|
|
91
|
-
let { store:
|
|
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:
|
|
94
|
-
},
|
|
94
|
+
scope: C ? "deleted" : void 0
|
|
95
|
+
}, w, l, (e, t) => n.contents.manage({
|
|
95
96
|
...e,
|
|
96
97
|
kind: r,
|
|
97
|
-
q:
|
|
98
|
-
state:
|
|
98
|
+
q: x || void 0,
|
|
99
|
+
state: L,
|
|
99
100
|
language: y
|
|
100
|
-
}, t)),
|
|
101
|
-
await
|
|
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
|
|
106
|
+
}) && await z.run(() => n.contents.remove(e.id));
|
|
106
107
|
};
|
|
107
|
-
return /* @__PURE__ */
|
|
108
|
+
return /* @__PURE__ */ N("div", {
|
|
108
109
|
className: "grid gap-4",
|
|
109
110
|
children: [
|
|
110
|
-
/* @__PURE__ */
|
|
111
|
+
/* @__PURE__ */ N("div", {
|
|
111
112
|
className: "flex flex-wrap items-center justify-between gap-2",
|
|
112
|
-
children: [/* @__PURE__ */
|
|
113
|
+
children: [/* @__PURE__ */ M("h2", {
|
|
113
114
|
className: "text-base font-semibold",
|
|
114
115
|
children: _("contentManager.title")
|
|
115
|
-
}), /* @__PURE__ */
|
|
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__ */
|
|
122
|
+
/* @__PURE__ */ N("div", {
|
|
122
123
|
className: "flex gap-2",
|
|
123
124
|
role: "group",
|
|
124
125
|
"aria-label": _("contentManager.title"),
|
|
125
|
-
children: [/* @__PURE__ */
|
|
126
|
+
children: [/* @__PURE__ */ M(u, {
|
|
126
127
|
size: "sm",
|
|
127
|
-
variant:
|
|
128
|
-
"aria-pressed": !
|
|
129
|
-
onClick: () => e.go("", { q:
|
|
128
|
+
variant: C ? "outline" : "default",
|
|
129
|
+
"aria-pressed": !C,
|
|
130
|
+
onClick: () => e.go("", { q: x }),
|
|
130
131
|
children: _("contentManager.items")
|
|
131
|
-
}), /* @__PURE__ */
|
|
132
|
+
}), /* @__PURE__ */ M(u, {
|
|
132
133
|
size: "sm",
|
|
133
|
-
variant:
|
|
134
|
-
"aria-pressed":
|
|
134
|
+
variant: C ? "default" : "outline",
|
|
135
|
+
"aria-pressed": C,
|
|
135
136
|
onClick: () => e.go("", {
|
|
136
|
-
q:
|
|
137
|
+
q: x,
|
|
137
138
|
deleted: "1"
|
|
138
139
|
}),
|
|
139
140
|
children: _("contentManager.deleted")
|
|
140
141
|
})]
|
|
141
142
|
}),
|
|
142
|
-
/* @__PURE__ */
|
|
143
|
+
/* @__PURE__ */ N("div", {
|
|
143
144
|
className: "grid gap-2 sm:grid-cols-[minmax(0,1fr)_auto]",
|
|
144
|
-
children: [/* @__PURE__ */
|
|
145
|
+
children: [/* @__PURE__ */ N("form", {
|
|
145
146
|
className: "flex gap-2",
|
|
146
147
|
role: "search",
|
|
147
148
|
onSubmit: (e) => {
|
|
148
|
-
e.preventDefault(),
|
|
149
|
+
e.preventDefault(), E({ q: D.trim() });
|
|
149
150
|
},
|
|
150
151
|
children: [
|
|
151
|
-
/* @__PURE__ */
|
|
152
|
+
/* @__PURE__ */ M(f, {
|
|
152
153
|
htmlFor: `${v}-q`,
|
|
153
154
|
className: "sr-only",
|
|
154
155
|
children: _("contentManager.search")
|
|
155
156
|
}),
|
|
156
|
-
/* @__PURE__ */
|
|
157
|
+
/* @__PURE__ */ M(d, {
|
|
157
158
|
id: `${v}-q`,
|
|
158
159
|
className: "h-8",
|
|
159
160
|
type: "search",
|
|
160
|
-
value:
|
|
161
|
+
value: D,
|
|
161
162
|
placeholder: _("contentManager.search"),
|
|
162
|
-
onChange: (e) =>
|
|
163
|
+
onChange: (e) => O(e.target.value)
|
|
163
164
|
}),
|
|
164
|
-
/* @__PURE__ */
|
|
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
|
-
}), !
|
|
172
|
-
value:
|
|
173
|
-
onValueChange: (e) =>
|
|
174
|
-
children: [/* @__PURE__ */
|
|
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__ */
|
|
178
|
-
}), /* @__PURE__ */
|
|
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
|
-
}),
|
|
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__ */
|
|
188
|
-
|
|
189
|
-
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:
|
|
192
|
-
}) :
|
|
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":
|
|
195
|
-
children:
|
|
196
|
-
let r =
|
|
197
|
-
return /* @__PURE__ */
|
|
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":
|
|
201
|
-
children: [/* @__PURE__ */
|
|
201
|
+
"data-status": C ? "deleted" : r,
|
|
202
|
+
children: [/* @__PURE__ */ N("div", {
|
|
202
203
|
className: "grid min-w-0 flex-1 gap-1",
|
|
203
|
-
children: [
|
|
204
|
+
children: [C ? /* @__PURE__ */ M("span", {
|
|
204
205
|
className: "font-medium break-words",
|
|
205
206
|
children: t.title
|
|
206
|
-
}) : /* @__PURE__ */
|
|
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__ */
|
|
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
|
-
!
|
|
215
|
-
variant:
|
|
215
|
+
!C && /* @__PURE__ */ M(te, {
|
|
216
|
+
variant: ge[r],
|
|
216
217
|
children: _(`contentManager.${r}`)
|
|
217
218
|
}),
|
|
218
|
-
/* @__PURE__ */
|
|
219
|
-
/* @__PURE__ */
|
|
220
|
-
r === "scheduled" && t.publish_at && /* @__PURE__ */
|
|
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__ */
|
|
224
|
+
}), /* @__PURE__ */ M("div", {
|
|
224
225
|
className: "flex flex-wrap gap-2",
|
|
225
|
-
children:
|
|
226
|
+
children: C ? /* @__PURE__ */ M(u, {
|
|
226
227
|
size: "sm",
|
|
227
228
|
variant: "outline",
|
|
228
|
-
disabled:
|
|
229
|
-
onClick: () => void
|
|
229
|
+
disabled: z.pending,
|
|
230
|
+
onClick: () => void z.run(() => n.contents.restore(t.id)),
|
|
230
231
|
children: _("moderation.restore")
|
|
231
|
-
}) : /* @__PURE__ */
|
|
232
|
-
i && /* @__PURE__ */
|
|
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__ */
|
|
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__ */
|
|
247
|
+
/* @__PURE__ */ M(u, {
|
|
247
248
|
size: "sm",
|
|
248
249
|
variant: "destructive",
|
|
249
|
-
disabled:
|
|
250
|
-
onClick: () => void
|
|
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__ */
|
|
258
|
+
}) : /* @__PURE__ */ M("p", {
|
|
258
259
|
className: "text-muted-foreground",
|
|
259
|
-
children: _(
|
|
260
|
+
children: _(C ? "contentManager.noDeleted" : "contentManager.empty")
|
|
260
261
|
}),
|
|
261
|
-
/* @__PURE__ */
|
|
262
|
-
page:
|
|
263
|
-
hasNext:
|
|
264
|
-
disabled:
|
|
262
|
+
/* @__PURE__ */ M(ue, {
|
|
263
|
+
page: w,
|
|
264
|
+
hasNext: R.hasNext,
|
|
265
|
+
disabled: R.loading,
|
|
265
266
|
onPage: (t) => e.go("", {
|
|
266
|
-
...
|
|
267
|
+
...T,
|
|
267
268
|
page: t > 1 ? t : void 0
|
|
268
269
|
})
|
|
269
270
|
}),
|
|
270
|
-
|
|
271
|
+
V
|
|
271
272
|
]
|
|
272
273
|
});
|
|
273
274
|
}
|
|
274
|
-
var
|
|
275
|
+
var B = {
|
|
275
276
|
title: "",
|
|
276
277
|
slug: "",
|
|
277
278
|
description: "",
|
|
278
279
|
publishAt: "",
|
|
279
280
|
body: ""
|
|
280
281
|
};
|
|
281
|
-
function
|
|
282
|
-
let
|
|
283
|
-
|
|
284
|
-
if (!
|
|
285
|
-
let e =
|
|
286
|
-
|
|
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:
|
|
292
|
+
publishAt: q.publish_at && !q.live ? x(new Date(q.publish_at)) : ""
|
|
292
293
|
});
|
|
293
|
-
}, [
|
|
294
|
-
let { imageSrc:
|
|
295
|
-
let n =
|
|
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,
|
|
298
|
-
if (i && !H) return R.error ? /* @__PURE__ */
|
|
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__ */
|
|
303
|
+
}) : /* @__PURE__ */ N("div", {
|
|
303
304
|
className: "grid gap-3",
|
|
304
305
|
"aria-busy": !0,
|
|
305
|
-
children: [/* @__PURE__ */
|
|
306
|
+
children: [/* @__PURE__ */ M(m, { className: "h-9 w-full" }), /* @__PURE__ */ M(m, { className: "h-48 w-full" })]
|
|
306
307
|
});
|
|
307
|
-
let
|
|
308
|
+
let J = H, Y = (e) => U((t) => ({
|
|
308
309
|
...t,
|
|
309
310
|
...e
|
|
310
|
-
})),
|
|
311
|
+
})), X = (t) => {
|
|
311
312
|
let n = e(t);
|
|
312
|
-
|
|
313
|
-
},
|
|
314
|
-
title:
|
|
315
|
-
slug:
|
|
316
|
-
description:
|
|
317
|
-
body:
|
|
318
|
-
}),
|
|
319
|
-
if (
|
|
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 (!
|
|
322
|
+
if (!q) {
|
|
322
323
|
let e = await R.create({
|
|
323
324
|
kind: o,
|
|
324
|
-
text: { [
|
|
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(
|
|
331
|
-
|
|
331
|
+
let e = await R.putText(Ce());
|
|
332
|
+
K(T("pollEditor.saved")), U((t) => ({
|
|
332
333
|
...t,
|
|
333
|
-
slug: e.text?.[
|
|
334
|
+
slug: e.text?.[I]?.slug ?? t.slug
|
|
334
335
|
}));
|
|
335
336
|
} catch (e) {
|
|
336
|
-
|
|
337
|
+
X(e);
|
|
337
338
|
}
|
|
338
|
-
},
|
|
339
|
-
|
|
339
|
+
}, Te = async (e) => {
|
|
340
|
+
G(null), K(null);
|
|
340
341
|
try {
|
|
341
|
-
e ? await R.publish(
|
|
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
|
-
|
|
344
|
+
X(e);
|
|
344
345
|
}
|
|
345
|
-
},
|
|
346
|
-
if (
|
|
347
|
-
title: T("contentManager.deleteTitle", { 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?.(
|
|
352
|
+
await R.remove(), ue?.(q);
|
|
352
353
|
} catch (e) {
|
|
353
|
-
|
|
354
|
+
X(e);
|
|
354
355
|
}
|
|
355
|
-
},
|
|
356
|
-
value:
|
|
357
|
-
onChange: (e) =>
|
|
358
|
-
uploadImage:
|
|
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__ */
|
|
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(),
|
|
368
|
+
e.preventDefault(), we();
|
|
368
369
|
},
|
|
369
370
|
children: [
|
|
370
|
-
/* @__PURE__ */
|
|
371
|
+
/* @__PURE__ */ N("div", {
|
|
371
372
|
className: "flex flex-wrap items-center gap-2",
|
|
372
373
|
children: [
|
|
373
|
-
/* @__PURE__ */
|
|
374
|
+
/* @__PURE__ */ M("h2", {
|
|
374
375
|
className: "text-base font-semibold",
|
|
375
|
-
children: T(
|
|
376
|
+
children: T(q ? "contentManager.editTitle" : "contentManager.newTitle")
|
|
376
377
|
}),
|
|
377
|
-
|
|
378
|
-
variant:
|
|
379
|
-
children: T(`contentManager.${
|
|
378
|
+
q && /* @__PURE__ */ M(te, {
|
|
379
|
+
variant: ge[Z],
|
|
380
|
+
children: T(`contentManager.${Z}`)
|
|
380
381
|
}),
|
|
381
|
-
|
|
382
|
+
Q && /* @__PURE__ */ M("a", {
|
|
382
383
|
className: "text-xs text-muted-foreground hover:underline",
|
|
383
|
-
href:
|
|
384
|
+
href: Q,
|
|
384
385
|
children: T("contentManager.view")
|
|
385
386
|
})
|
|
386
387
|
]
|
|
387
388
|
}),
|
|
388
|
-
|
|
389
|
-
variant:
|
|
390
|
-
children: /* @__PURE__ */
|
|
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
|
-
|
|
393
|
+
P.length > 1 && /* @__PURE__ */ N("div", {
|
|
393
394
|
className: "grid gap-1.5",
|
|
394
|
-
children: [/* @__PURE__ */
|
|
395
|
-
htmlFor: `${
|
|
395
|
+
children: [/* @__PURE__ */ M(f, {
|
|
396
|
+
htmlFor: `${k}-lang`,
|
|
396
397
|
children: T("contentManager.language")
|
|
397
|
-
}), /* @__PURE__ */
|
|
398
|
-
value:
|
|
398
|
+
}), /* @__PURE__ */ N(ne, {
|
|
399
|
+
value: I,
|
|
399
400
|
onValueChange: (e) => {
|
|
400
|
-
L(String(e ?? "")),
|
|
401
|
+
L(String(e ?? "")), U(q ? null : B);
|
|
401
402
|
},
|
|
402
|
-
children: [/* @__PURE__ */
|
|
403
|
-
id: `${
|
|
403
|
+
children: [/* @__PURE__ */ M(ie, {
|
|
404
|
+
id: `${k}-lang`,
|
|
404
405
|
className: "w-full",
|
|
405
|
-
children: /* @__PURE__ */
|
|
406
|
-
}), /* @__PURE__ */
|
|
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__ */
|
|
413
|
+
/* @__PURE__ */ N("div", {
|
|
413
414
|
className: "grid gap-1.5",
|
|
414
|
-
children: [/* @__PURE__ */
|
|
415
|
-
htmlFor: `${
|
|
415
|
+
children: [/* @__PURE__ */ M(f, {
|
|
416
|
+
htmlFor: `${k}-title`,
|
|
416
417
|
children: T("contentManager.itemTitle")
|
|
417
|
-
}), /* @__PURE__ */
|
|
418
|
-
id: `${
|
|
419
|
-
value:
|
|
418
|
+
}), /* @__PURE__ */ M(d, {
|
|
419
|
+
id: `${k}-title`,
|
|
420
|
+
value: J.title,
|
|
420
421
|
required: !0,
|
|
421
422
|
maxLength: 300,
|
|
422
|
-
onChange: (e) =>
|
|
423
|
+
onChange: (e) => Y({ title: e.target.value })
|
|
423
424
|
})]
|
|
424
425
|
}),
|
|
425
|
-
/* @__PURE__ */
|
|
426
|
+
/* @__PURE__ */ N("div", {
|
|
426
427
|
className: "grid gap-4 sm:grid-cols-2",
|
|
427
|
-
children: [/* @__PURE__ */
|
|
428
|
+
children: [/* @__PURE__ */ N("div", {
|
|
428
429
|
className: "grid gap-1.5",
|
|
429
|
-
children: [/* @__PURE__ */
|
|
430
|
-
htmlFor: `${
|
|
430
|
+
children: [/* @__PURE__ */ M(f, {
|
|
431
|
+
htmlFor: `${k}-slug`,
|
|
431
432
|
children: T("contentManager.slug")
|
|
432
|
-
}), /* @__PURE__ */
|
|
433
|
-
id: `${
|
|
434
|
-
value:
|
|
433
|
+
}), /* @__PURE__ */ M(d, {
|
|
434
|
+
id: `${k}-slug`,
|
|
435
|
+
value: J.slug,
|
|
435
436
|
placeholder: T("contentManager.slugAuto"),
|
|
436
|
-
onChange: (e) =>
|
|
437
|
+
onChange: (e) => Y({ slug: e.target.value })
|
|
437
438
|
})]
|
|
438
|
-
}), /* @__PURE__ */
|
|
439
|
+
}), /* @__PURE__ */ N("div", {
|
|
439
440
|
className: "grid gap-1.5",
|
|
440
|
-
children: [/* @__PURE__ */
|
|
441
|
-
htmlFor: `${
|
|
441
|
+
children: [/* @__PURE__ */ M(f, {
|
|
442
|
+
htmlFor: `${k}-publish`,
|
|
442
443
|
children: T("contentManager.publishAt")
|
|
443
|
-
}), /* @__PURE__ */
|
|
444
|
-
id: `${
|
|
444
|
+
}), /* @__PURE__ */ M(d, {
|
|
445
|
+
id: `${k}-publish`,
|
|
445
446
|
type: "datetime-local",
|
|
446
|
-
value:
|
|
447
|
-
onChange: (e) =>
|
|
447
|
+
value: J.publishAt,
|
|
448
|
+
onChange: (e) => Y({ publishAt: e.target.value })
|
|
448
449
|
})]
|
|
449
450
|
})]
|
|
450
451
|
}),
|
|
451
|
-
/* @__PURE__ */
|
|
452
|
+
/* @__PURE__ */ N("div", {
|
|
452
453
|
className: "grid gap-1.5",
|
|
453
|
-
children: [/* @__PURE__ */
|
|
454
|
-
htmlFor: `${
|
|
454
|
+
children: [/* @__PURE__ */ M(f, {
|
|
455
|
+
htmlFor: `${k}-description`,
|
|
455
456
|
children: T("contentManager.description")
|
|
456
|
-
}), /* @__PURE__ */
|
|
457
|
-
id: `${
|
|
457
|
+
}), /* @__PURE__ */ M(h, {
|
|
458
|
+
id: `${k}-description`,
|
|
458
459
|
rows: 2,
|
|
459
|
-
value:
|
|
460
|
-
onChange: (e) =>
|
|
460
|
+
value: J.description,
|
|
461
|
+
onChange: (e) => Y({ description: e.target.value })
|
|
461
462
|
})]
|
|
462
463
|
}),
|
|
463
|
-
(z || !
|
|
464
|
-
item:
|
|
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(
|
|
468
|
+
onFile: (e) => void R.setCover(e).catch(X)
|
|
468
469
|
}),
|
|
469
|
-
/* @__PURE__ */
|
|
470
|
+
/* @__PURE__ */ N("div", {
|
|
470
471
|
className: "grid gap-1.5",
|
|
471
472
|
children: [
|
|
472
|
-
/* @__PURE__ */
|
|
473
|
+
/* @__PURE__ */ M("span", {
|
|
473
474
|
className: "text-sm font-medium",
|
|
474
475
|
children: T("contentManager.body")
|
|
475
476
|
}),
|
|
476
|
-
g ? g($) : /* @__PURE__ */
|
|
477
|
+
g ? g($) : /* @__PURE__ */ M(h, {
|
|
477
478
|
"aria-label": $["aria-label"],
|
|
478
479
|
rows: 12,
|
|
479
|
-
value:
|
|
480
|
+
value: J.body,
|
|
480
481
|
placeholder: $.placeholder,
|
|
481
|
-
onChange: (e) =>
|
|
482
|
+
onChange: (e) => Y({ body: e.target.value })
|
|
482
483
|
}),
|
|
483
|
-
!
|
|
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
|
-
|
|
490
|
-
|
|
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:
|
|
494
|
+
children: ve
|
|
494
495
|
}),
|
|
495
|
-
/* @__PURE__ */
|
|
496
|
+
/* @__PURE__ */ N("div", {
|
|
496
497
|
className: "flex flex-wrap gap-2 border-t border-border pt-4",
|
|
497
498
|
children: [
|
|
498
|
-
/* @__PURE__ */
|
|
499
|
+
/* @__PURE__ */ M(u, {
|
|
499
500
|
type: "submit",
|
|
500
501
|
disabled: R.saving,
|
|
501
|
-
children: R.saving ? T("common.saving") : T(
|
|
502
|
+
children: R.saving ? T("common.saving") : T(q ? "common.save" : "contentManager.createDraft")
|
|
502
503
|
}),
|
|
503
|
-
|
|
504
|
+
q && !q.live && /* @__PURE__ */ M(u, {
|
|
504
505
|
type: "button",
|
|
505
506
|
variant: "outline",
|
|
506
507
|
disabled: R.saving,
|
|
507
|
-
onClick: () => void
|
|
508
|
+
onClick: () => void Te(!0),
|
|
508
509
|
children: T("contentManager.publish")
|
|
509
510
|
}),
|
|
510
|
-
|
|
511
|
+
q?.state === "published" && /* @__PURE__ */ M(u, {
|
|
511
512
|
type: "button",
|
|
512
513
|
variant: "outline",
|
|
513
514
|
disabled: R.saving,
|
|
514
|
-
onClick: () => void
|
|
515
|
+
onClick: () => void Te(!1),
|
|
515
516
|
children: T("contentManager.unpublish")
|
|
516
517
|
}),
|
|
517
|
-
|
|
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
|
|
523
|
+
onClick: () => void Ee(),
|
|
523
524
|
children: T("contentManager.delete")
|
|
524
525
|
})
|
|
525
526
|
]
|
|
526
527
|
}),
|
|
527
|
-
|
|
528
|
+
be
|
|
528
529
|
]
|
|
529
|
-
}),
|
|
530
|
-
|
|
531
|
-
|
|
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
|
|
537
|
-
let { t: a } = t(), o =
|
|
538
|
-
return /* @__PURE__ */
|
|
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__ */
|
|
543
|
+
children: [/* @__PURE__ */ M("span", {
|
|
542
544
|
className: "text-sm font-medium",
|
|
543
545
|
children: a("contentManager.cover")
|
|
544
|
-
}), e ? /* @__PURE__ */
|
|
546
|
+
}), e ? /* @__PURE__ */ N("div", {
|
|
545
547
|
className: "flex flex-wrap items-center gap-3",
|
|
546
548
|
children: [
|
|
547
|
-
n ? /* @__PURE__ */
|
|
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__ */
|
|
553
|
+
}) : /* @__PURE__ */ M("span", {
|
|
552
554
|
className: "text-muted-foreground",
|
|
553
555
|
children: a("contentManager.noCover")
|
|
554
556
|
}),
|
|
555
|
-
/* @__PURE__ */
|
|
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__ */
|
|
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__ */
|
|
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__ */
|
|
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 {
|
|
592
|
+
export { V as ContentEditor, L as ContentManager, F as contentStatus, P as useContentManagerAccess };
|
|
591
593
|
|
|
592
594
|
//# sourceMappingURL=content-manager.js.map
|