@phtngyn/cms 0.2.0-beta.5 → 0.2.0-beta.7

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 (45) hide show
  1. package/package.json +1 -1
  2. package/src/{Configuration-JQ1qyaU0.js → Configuration-Da5B2PVH.js} +2 -2
  3. package/src/{Configuration-JQ1qyaU0.js.map → Configuration-Da5B2PVH.js.map} +1 -1
  4. package/src/Content.js +3 -3
  5. package/src/Content.js.map +1 -1
  6. package/src/{DocumentEngine-j6Vi7nQo.js → DocumentEngine-hh_IGPXO.js} +2 -2
  7. package/src/{DocumentEngine-j6Vi7nQo.js.map → DocumentEngine-hh_IGPXO.js.map} +1 -1
  8. package/src/Module.js +1 -1
  9. package/src/{S3MediaObjects-BRuPQbxl.js → S3MediaObjects-Dwhl2deX.js} +4 -4
  10. package/src/{S3MediaObjects-BRuPQbxl.js.map → S3MediaObjects-Dwhl2deX.js.map} +1 -1
  11. package/src/cli.js +3 -3
  12. package/src/{dev-lifecycle-DdBluSiR.js → dev-lifecycle-CjDq63Ft.js} +8 -8
  13. package/src/dev-lifecycle-CjDq63Ft.js.map +1 -0
  14. package/src/{installation-BoG8E3nJ.js → installation-DYNQQBD3.js} +7 -9
  15. package/src/{installation-BoG8E3nJ.js.map → installation-DYNQQBD3.js.map} +1 -1
  16. package/src/internal/authoring-catalog.js +1 -1
  17. package/src/internal/authoring-metadata.js +1 -1
  18. package/src/internal/configuration.js +1 -1
  19. package/src/internal/dev-lifecycle.js +1 -1
  20. package/src/internal/document-model.js +2 -2
  21. package/src/{metadata-UzZmjwxM.js → metadata-DN9_K6Yl.js} +87 -7
  22. package/src/metadata-DN9_K6Yl.js.map +1 -0
  23. package/src/runtime/installation.js +1 -1
  24. package/src/runtime/plugin.js +1 -1
  25. package/src/runtime/preview/controller.js +3 -2
  26. package/src/runtime/preview/controller.js.map +1 -1
  27. package/src/runtime/preview/crypto.js +16 -0
  28. package/src/runtime/preview/crypto.js.map +1 -0
  29. package/src/runtime/preview/plugin.client.js +1 -1
  30. package/src/runtime/preview/store.js +1 -1
  31. package/src/runtime/studio-app.js +1 -1
  32. package/src/runtime/studio-app.js.map +1 -1
  33. package/src/runtime/studio-document.js +46 -0
  34. package/src/runtime/studio-document.js.map +1 -0
  35. package/src/runtime/studio-entry.js +5 -22
  36. package/src/runtime/studio-entry.js.map +1 -1
  37. package/src/{store-PKKB8xa2.js → store-X1e1o_MF.js} +2 -2
  38. package/src/{store-PKKB8xa2.js.map → store-X1e1o_MF.js.map} +1 -1
  39. package/studio/CreateDocumentDialog-BpjBYGfI.js +335 -0
  40. package/studio/{documentPlanning-Bx3W9KkD.js → SelectMenu-KiXwx4Y_.js} +15513 -11376
  41. package/studio/host.css +1 -1
  42. package/studio/host.js +10343 -14430
  43. package/src/dev-lifecycle-DdBluSiR.js.map +0 -1
  44. package/src/metadata-UzZmjwxM.js.map +0 -1
  45. package/studio/CreateDocumentDialog-vQ8hDs2C.js +0 -253
@@ -0,0 +1,335 @@
1
+ import { $ as e, Bt as t, Dt as n, Et as r, It as i, Nt as a, Pt as o, Q as s, Y as c, at as l, cn as u, dn as d, en as f, et as p, ht as m, mt as h, nt as g, on as _, q as v, st as y, tt as b, wt as x } from "./editor-P2rB7Csp.js";
2
+ import { Ar as S, Di as C, F as ee, I as te, L as ne, Ma as w, O as re, Oi as T, Or as ie, P as E, j as ae, jr as D, ki as O, kr as k, n as A, or as j, r as oe, sr as se, t as ce, ua as M, vr as le, z as ue } from "./SelectMenu-KiXwx4Y_.js";
3
+ //#region virtual:nuxt-ui-templates/ui/collapsible.ts
4
+ var N = { slots: {
5
+ root: "",
6
+ content: "data-[state=open]:animate-[collapsible-down_200ms_var(--ease-out)] data-[state=closed]:animate-[collapsible-up_200ms_var(--ease-out)] data-[state=closed]:overflow-hidden"
7
+ } }, de = {
8
+ __name: "Collapsible",
9
+ props: {
10
+ as: {
11
+ type: null,
12
+ required: !1
13
+ },
14
+ class: {
15
+ type: null,
16
+ required: !1
17
+ },
18
+ ui: {
19
+ type: Object,
20
+ required: !1
21
+ },
22
+ defaultOpen: {
23
+ type: Boolean,
24
+ required: !1
25
+ },
26
+ open: {
27
+ type: Boolean,
28
+ required: !1
29
+ },
30
+ disabled: {
31
+ type: Boolean,
32
+ required: !1
33
+ },
34
+ unmountOnHide: {
35
+ type: Boolean,
36
+ required: !1,
37
+ default: !0
38
+ }
39
+ },
40
+ emits: ["update:open"],
41
+ setup(e, { emit: r }) {
42
+ let i = e, a = r, c = o(), d = D("collapsible", i), f = M(), h = S(w(d, "as", "defaultOpen", "open", "disabled", "unmountOnHide"), a), g = s(() => k({
43
+ extend: N,
44
+ ...f.ui?.collapsible || {}
45
+ })());
46
+ return (e, r) => (x(), p(_(O), m(_(h), {
47
+ "data-slot": "root",
48
+ class: g.value.root({ class: [_(d).ui?.root, _(d).class] })
49
+ }), {
50
+ default: t(({ open: r }) => [c.default ? (x(), p(_(C), {
51
+ key: 0,
52
+ "as-child": ""
53
+ }, {
54
+ default: t(() => [n(e.$slots, "default", { open: r })]),
55
+ _: 2
56
+ }, 1024)) : b("", !0), l(_(T), {
57
+ "data-slot": "content",
58
+ class: u(g.value.content({ class: _(d).ui?.content }))
59
+ }, {
60
+ default: t(() => [n(e.$slots, "content")]),
61
+ _: 3
62
+ }, 8, ["class"])]),
63
+ _: 3
64
+ }, 16, ["class"]));
65
+ }
66
+ }, fe = { key: 2 }, pe = { class: "grid grid-flow-col auto-cols-fr overflow-x-auto rounded-md border border-default" }, me = ["aria-pressed", "onClick"], he = { class: "block truncate" }, P = { key: 3 }, F = {
67
+ key: 4,
68
+ class: "overflow-hidden rounded-md border border-default bg-elevated/20"
69
+ }, I = {
70
+ type: "button",
71
+ class: "group flex w-full min-w-0 items-center gap-3 px-3 py-2.5 text-left transition-[background-color,transform] duration-150 ease-out hover:bg-elevated/50 active:scale-[0.99] motion-reduce:transition-none"
72
+ }, L = { class: "min-w-0 flex-1" }, ge = { class: "block truncate text-xs text-muted" }, _e = { class: "shrink-0 text-xs font-medium text-muted group-hover:text-highlighted" }, ve = { class: "grid gap-4 border-t border-default px-3 py-3 sm:grid-cols-2" }, ye = {
73
+ key: 5,
74
+ class: "-mt-2 text-xs text-error"
75
+ }, be = {
76
+ key: 6,
77
+ class: "-mt-2 text-xs text-error"
78
+ }, xe = { class: "flex w-full justify-end gap-2" }, R = "__top_level__", z = /* @__PURE__ */ y({
79
+ __name: "CreateDocumentDialog",
80
+ props: /*@__PURE__*/ h({
81
+ catalog: {},
82
+ context: {}
83
+ }, {
84
+ open: { type: Boolean },
85
+ openModifiers: {}
86
+ }),
87
+ emits: /*@__PURE__*/ h(["close"], ["update:open"]),
88
+ setup(n, { emit: o }) {
89
+ let m = o, h = a(n, "open"), y = E(), S = y.bootstrap.documents, C = S.types.filter((e) => e.canCreate), w = (S.locales?.locales ?? []).map((e) => ({
90
+ label: $(e),
91
+ value: String(e)
92
+ })), T = f(""), D = f(!1), O = f(""), k = f(""), M = f(!1), N = f(""), z = f(R), B = f(S.locales?.defaultLocale ?? ""), V = f(!1), H = s(() => {
93
+ let e = C.map((e) => ({
94
+ collection: e.collection,
95
+ key: `entry:${e.collection}`,
96
+ kind: "entry",
97
+ label: e.label,
98
+ type: e,
99
+ urlHint: e.routes.entry.replace(/:[a-z][\w.]*\*?/giu, "…")
100
+ }));
101
+ return [...C.filter((e) => !n.catalog.entries.value.some((t) => t.document.collection === e.collection && t.document.locale === (B.value || void 0) && t.document.placement.kind === "home")).flatMap((e) => {
102
+ let t = A(S, {
103
+ collection: e.collection,
104
+ locale: B.value || void 0,
105
+ placement: { kind: "home" },
106
+ title: "Home"
107
+ });
108
+ return j(t) || n.catalog.entries.value.some((e) => e.document.path === t.success.path) ? [] : [{
109
+ collection: e.collection,
110
+ key: `home:${e.collection}`,
111
+ kind: "home",
112
+ label: "Home",
113
+ type: e,
114
+ urlHint: t.success.path
115
+ }];
116
+ }), ...e];
117
+ }), U = s(() => H.value.find((e) => e.key === N.value)), W = s(() => n.catalog.entries.value.find((e) => e.document.collection === U.value?.collection && e.document.locale === (B.value || void 0) && e.document.placement.kind === "home")), Se = s(() => H.value.length > 1 ? "Choose a page type and add a title." : "Add a title to get started."), Ce = s(() => U.value?.kind === "home" ? "Homepage" : z.value === R || z.value === W.value?.document.id ? "Top level" : n.catalog.byId(z.value)?.document.title ?? "Selected location"), we = s(() => {
118
+ let e = [Ce.value];
119
+ return w.length && e.unshift($(B.value)), e.join(" · ");
120
+ }), G = s(() => {
121
+ if (U.value?.kind === "home") return { kind: "home" };
122
+ let e = z.value === R ? W.value?.document.id : z.value;
123
+ return e ? {
124
+ kind: "entry",
125
+ parentDocumentId: e,
126
+ slug: k.value
127
+ } : void 0;
128
+ }), K = s(() => {
129
+ let e = U.value, t = G.value;
130
+ if (!e || !t || e.kind === "entry" && !k.value.trim()) return;
131
+ let r = {
132
+ collection: e.collection,
133
+ placement: t,
134
+ title: O.value || "Untitled"
135
+ }, i = r.placement.kind === "entry" ? n.catalog.byId(r.placement.parentDocumentId)?.document.path : void 0;
136
+ return A(S, B.value ? {
137
+ ...r,
138
+ locale: B.value
139
+ } : r, i);
140
+ }), q = s(() => {
141
+ let e = K.value;
142
+ return e && se(e) ? e.success : void 0;
143
+ }), J = s(() => {
144
+ let e = K.value;
145
+ return e && j(e) ? e.failure : "";
146
+ }), Y = s(() => q.value && n.catalog.entries.value.some((e) => e.document.path === q.value?.path)), X = s(() => {
147
+ let e = U.value;
148
+ if (!e || e.kind === "home" || !e.type.hierarchy) return [];
149
+ let t = n.catalog.entries.value.flatMap((t) => t.document.collection !== e.collection || t.document.locale !== (B.value || void 0) || t.document.placement.kind === "home" ? [] : [{
150
+ description: String(t.document.path),
151
+ label: t.document.title,
152
+ value: String(t.document.id)
153
+ }]);
154
+ return n.context?.parent && !t.some((e) => e.value === n.context.parent) && t.push({
155
+ description: n.context.parent,
156
+ label: "Selected location",
157
+ value: n.context.parent
158
+ }), [{
159
+ description: "Add this page directly below the homepage.",
160
+ label: "Top level",
161
+ value: R
162
+ }, ...t];
163
+ }), Z = s(() => !!O.value.trim() && !!U.value && !!q.value && !Y.value);
164
+ i(O, (e) => {
165
+ M.value || (k.value = oe(e));
166
+ }), i(N, () => z.value = R, { flush: "sync" }), i(B, () => {
167
+ z.value = R, U.value || (N.value = Q());
168
+ }, { flush: "sync" }), i(h, (e) => {
169
+ e && (T.value = "", O.value = "", k.value = "", M.value = !1, V.value = !1, B.value = n.context?.locale ?? S.locales?.defaultLocale ?? "", N.value = n.context?.collection ? `entry:${n.context.collection}` : Q(), z.value = n.context?.parent === W.value?.document.id ? R : n.context?.parent || R, n.context?.slug && (k.value = n.context.slug, M.value = !0));
170
+ }, { immediate: !0 });
171
+ async function Te() {
172
+ let e = U.value, t = G.value;
173
+ if (Z.value && e && t && !D.value) {
174
+ D.value = !0, T.value = "";
175
+ try {
176
+ let r = {
177
+ collection: e.collection,
178
+ placement: t,
179
+ title: O.value
180
+ }, i = await y.gateway.documents.create(B.value ? {
181
+ ...r,
182
+ locale: B.value
183
+ } : r);
184
+ await n.catalog.refresh(!0);
185
+ let a = n.catalog.byId(i.documentId);
186
+ if (!a) throw Error("The page was created but could not be opened.");
187
+ m("close", a.document.id);
188
+ } catch (e) {
189
+ T.value = ue(e);
190
+ } finally {
191
+ D.value = !1;
192
+ }
193
+ }
194
+ }
195
+ function Q() {
196
+ return H.value[0]?.key ?? "";
197
+ }
198
+ function $(e) {
199
+ try {
200
+ return new Intl.DisplayNames(void 0, { type: "language" }).of(e) ?? e.toLocaleUpperCase();
201
+ } catch {
202
+ return e.toLocaleUpperCase();
203
+ }
204
+ }
205
+ return (n, i) => {
206
+ let a = ne, o = ee, s = te, f = ie, m = re, y = ce, S = de, C = le, E = ae;
207
+ return x(), p(E, {
208
+ open: h.value,
209
+ "onUpdate:open": i[7] ||= (e) => h.value = e,
210
+ title: "Create page",
211
+ description: Se.value,
212
+ ui: { content: "max-w-lg" }
213
+ }, {
214
+ body: t(() => [e("form", {
215
+ id: "create-document-form",
216
+ class: "space-y-4",
217
+ onSubmit: v(Te, ["prevent"])
218
+ }, [
219
+ T.value ? (x(), p(a, {
220
+ key: 0,
221
+ description: T.value,
222
+ color: "error",
223
+ variant: "subtle"
224
+ }, null, 8, ["description"])) : b("", !0),
225
+ H.value.length ? H.value.length > 1 ? (x(), g("fieldset", fe, [i[8] ||= e("legend", { class: "mb-2 text-sm font-medium text-highlighted" }, "Page type", -1), e("div", pe, [(x(!0), g(c, null, r(H.value, (t) => (x(), g("button", {
226
+ key: t.key,
227
+ type: "button",
228
+ "aria-pressed": t.key === N.value,
229
+ class: u(["min-w-28 border-l border-default px-3 py-2 text-center text-sm transition-[color,background-color,transform] duration-150 ease-out first:border-l-0 active:scale-[0.98] motion-reduce:transition-none", t.key === N.value ? "bg-muted font-medium text-highlighted" : "bg-default text-muted hover:bg-muted/50 hover:text-highlighted"]),
230
+ onClick: (e) => N.value = t.key
231
+ }, [e("span", he, d(t.label), 1)], 10, me))), 128))])])) : b("", !0) : (x(), p(a, {
232
+ key: 1,
233
+ title: "Document creation is not configured",
234
+ description: "A developer needs to make at least one collection creatable in Studio.",
235
+ color: "warning",
236
+ variant: "subtle"
237
+ })),
238
+ U.value ? (x(), g("div", P, [l(s, {
239
+ label: "Title",
240
+ required: ""
241
+ }, {
242
+ default: t(() => [l(o, {
243
+ modelValue: O.value,
244
+ "onUpdate:modelValue": i[0] ||= (e) => O.value = e,
245
+ autofocus: "",
246
+ placeholder: "About us",
247
+ class: "w-full"
248
+ }, null, 8, ["modelValue"])]),
249
+ _: 1
250
+ })])) : b("", !0),
251
+ U.value ? (x(), g("div", F, [l(S, {
252
+ open: V.value,
253
+ "onUpdate:open": i[5] ||= (e) => V.value = e
254
+ }, {
255
+ content: t(() => [e("div", ve, [
256
+ _(w).length ? (x(), p(s, {
257
+ key: 0,
258
+ label: "Language"
259
+ }, {
260
+ default: t(() => [l(m, {
261
+ modelValue: B.value,
262
+ "onUpdate:modelValue": i[1] ||= (e) => B.value = e,
263
+ items: _(w),
264
+ "value-key": "value",
265
+ class: "w-full"
266
+ }, null, 8, ["modelValue", "items"])]),
267
+ _: 1
268
+ })) : b("", !0),
269
+ U.value.kind === "entry" && U.value.type.hierarchy ? (x(), p(s, {
270
+ key: 1,
271
+ label: "Location",
272
+ class: u(_(w).length ? "" : "sm:col-span-2")
273
+ }, {
274
+ default: t(() => [l(y, {
275
+ modelValue: z.value,
276
+ "onUpdate:modelValue": i[2] ||= (e) => z.value = e,
277
+ "aria-label": "Location",
278
+ items: X.value,
279
+ "value-key": "value",
280
+ "filter-fields": ["label", "description"],
281
+ "search-input": { placeholder: "Search pages…" },
282
+ class: "w-full"
283
+ }, null, 8, ["modelValue", "items"])]),
284
+ _: 1
285
+ }, 8, ["class"])) : b("", !0),
286
+ U.value.kind === "entry" ? (x(), p(s, {
287
+ key: 2,
288
+ label: "Page address",
289
+ description: "The final part of this page's web address.",
290
+ class: "sm:col-span-2",
291
+ required: ""
292
+ }, {
293
+ default: t(() => [l(o, {
294
+ modelValue: k.value,
295
+ "onUpdate:modelValue": [i[3] ||= (e) => k.value = e, i[4] ||= (e) => M.value = !0],
296
+ placeholder: "about-us",
297
+ class: "w-full"
298
+ }, null, 8, ["modelValue"])]),
299
+ _: 1
300
+ })) : b("", !0)
301
+ ])]),
302
+ default: t(() => [e("button", I, [
303
+ e("span", L, [e("span", ge, d(we.value), 1), e("span", { class: u(["mt-0.5 block truncate font-mono text-xs", Y.value || J.value ? "text-error" : "text-highlighted"]) }, d(q.value?.path || U.value.urlHint), 3)]),
304
+ e("span", _e, d(V.value ? "Done" : "Edit details"), 1),
305
+ l(f, {
306
+ name: "i-lucide-chevron-down",
307
+ class: u(["size-3.5 shrink-0 text-dimmed transition-transform duration-150 ease-out motion-reduce:transition-none", V.value ? "rotate-180" : ""])
308
+ }, null, 8, ["class"])
309
+ ])]),
310
+ _: 1
311
+ }, 8, ["open"])])) : b("", !0),
312
+ Y.value ? (x(), g("p", ye, "This page address is already in use.")) : J.value ? (x(), g("p", be, d(J.value), 1)) : b("", !0)
313
+ ], 32)]),
314
+ footer: t(() => [e("div", xe, [l(C, {
315
+ color: "neutral",
316
+ variant: "ghost",
317
+ label: "Cancel",
318
+ class: "transition-transform duration-150 ease-out active:scale-[0.97] motion-reduce:transition-none",
319
+ onClick: i[6] ||= (e) => h.value = !1
320
+ }), l(C, {
321
+ type: "submit",
322
+ form: "create-document-form",
323
+ color: "neutral",
324
+ label: "Create page",
325
+ class: "transition-transform duration-150 ease-out active:scale-[0.97] motion-reduce:transition-none",
326
+ loading: D.value,
327
+ disabled: !Z.value
328
+ }, null, 8, ["loading", "disabled"])])]),
329
+ _: 1
330
+ }, 8, ["open", "description"]);
331
+ };
332
+ }
333
+ });
334
+ //#endregion
335
+ export { z as default };