@opengis/cms 0.0.48 → 0.0.49

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.
@@ -0,0 +1,803 @@
1
+ import { ref as v, useModel as V, onMounted as P, openBlock as m, createElementBlock as g, createVNode as x, createCommentVNode as O, computed as F, createElementVNode as l, unref as w, createTextVNode as H, toDisplayString as a, withCtx as j, mergeModels as ee, defineAsyncComponent as G, Fragment as J, createBlock as U, normalizeClass as Y, resolveDynamicComponent as K, onBeforeUnmount as te, defineComponent as le, inject as se, renderList as ie } from "vue";
2
+ import { useRoute as oe, useRouter as re } from "vue-router";
3
+ import { _ as ae } from "./MonacoEditor.vue_vue_type_script_setup_true_lang-B1DrxmQX.js";
4
+ import { Plus as ne, Edit as de, Trash as ce, Type as M, File as S, Link as B, LayoutTemplate as ue, Image as A, ListTree as D, CheckSquare as E, List as me, Clock as pe, Calendar as be, Hash as R } from "lucide-vue-next";
5
+ import { VForm as Q, inputs as $ } from "@opengis/form";
6
+ import { VsModal as W, notify as T, confirm as fe } from "@opengis/core";
7
+ import { useI18n as I } from "vue-i18n";
8
+ import { d as ve } from "./vuedraggable-CoAPPFYd.js";
9
+ import { _ as ge, a as ye, V as he, b as z, c as xe, d as we, e as _e, g as ke } from "./getField-C7EZs-YQ.js";
10
+ import { _ as $e } from "./CollectionsBreadcrumb.vue_vue_type_script_setup_true_lang-CnOe9ORD.js";
11
+ const Ce = {
12
+ __name: "vs-builder-monaco",
13
+ props: {
14
+ yaml: { type: String, default: "" },
15
+ yamlModifiers: {}
16
+ },
17
+ emits: ["update:yaml"],
18
+ setup(n) {
19
+ const e = v("");
20
+ V(n, "yaml");
21
+ const d = v(null);
22
+ return P(() => {
23
+ d.value = Math.random().toString(36).substring(2, 15);
24
+ }), (s, t) => d.value ? (m(), g("div", { key: d.value }, [
25
+ x(ae, {
26
+ modelValue: e.value,
27
+ "onUpdate:modelValue": t[0] || (t[0] = (i) => e.value = i),
28
+ language: "yaml",
29
+ theme: "vs-light",
30
+ height: "calc(100vh - 200px)",
31
+ width: "100%",
32
+ options: {
33
+ minimap: { enabled: !1 }
34
+ }
35
+ }, null, 8, ["modelValue"])
36
+ ])) : O("", !0);
37
+ }
38
+ }, q = (n = 0, e) => ({
39
+ name: {
40
+ type: "text",
41
+ label: e("cms.builder.fieldLabels.name"),
42
+ required: !0,
43
+ placeholder: e("cms.builder.fieldPlaceholders.name"),
44
+ validators: ["required"]
45
+ },
46
+ label: {
47
+ type: "text",
48
+ label: e("cms.builder.fieldLabels.label"),
49
+ required: !0,
50
+ placeholder: e("cms.builder.fieldPlaceholders.label"),
51
+ validators: ["required"]
52
+ },
53
+ placeholder: {
54
+ type: "text",
55
+ label: e("cms.builder.fieldLabels.placeholder"),
56
+ required: !0,
57
+ placeholder: e("cms.builder.fieldPlaceholders.placeholder")
58
+ },
59
+ help: {
60
+ type: "text",
61
+ label: e("cms.builder.fieldLabels.help"),
62
+ placeholder: e("cms.builder.fieldPlaceholders.help")
63
+ },
64
+ type: {
65
+ type: "combobox",
66
+ mode: "combo",
67
+ label: e("cms.builder.fieldLabels.type"),
68
+ required: !0,
69
+ maxHeight: "300",
70
+ slots: {
71
+ option: '<div class="flex items-center gap-2 p-2 py-1 rounded hover:bg-gray-100" :class="{ \'bg-gray-100\': selectedNavIndex === ind, \'bg-gray-100\': modelValue == ind }" ><div :class="`flex items-center gap-2 p-1 bg-${color }-100 rounded`"><component :is="`icon-${id}`" class="block" height="24" width="30" /></div><span class="text-sm text-gray-700">{{ text }}</span></div>'
72
+ },
73
+ options: [
74
+ { text: e("cms.builder.fieldOptions.text"), id: "text", color: "blue", icon: "Type" },
75
+ { text: e("cms.builder.fieldOptions.number"), id: "number", color: "green", icon: "Hash" },
76
+ { text: e("cms.builder.fieldOptions.date"), id: "date", color: "red", icon: "Calendar" },
77
+ { text: e("cms.builder.fieldOptions.datetime"), id: "datetime", color: "purple", icon: "CalendarClock" },
78
+ { text: e("cms.builder.fieldOptions.file"), id: "file", color: "yellow", icon: "File" },
79
+ { text: e("cms.builder.fieldOptions.select"), id: "select", color: "yellow", icon: "Check" },
80
+ { text: e("cms.builder.fieldOptions.multiselect"), id: "multiselect", color: "blue", icon: "List" },
81
+ { text: e("cms.builder.fieldOptions.mediaselect"), id: "mediaselect", color: "orange", icon: "Image" },
82
+ { text: e("cms.builder.fieldOptions.radio"), id: "radio", color: "blue", icon: "Disc" },
83
+ { text: e("cms.builder.fieldOptions.boolean"), id: "boolean", color: "red", icon: "ToggleRight" },
84
+ { text: e("cms.builder.fieldOptions.datalist"), id: "datalist", color: "orange", icon: "ListChecks" },
85
+ { text: e("cms.builder.fieldOptions.image"), id: "image", color: "blue", icon: "Image" },
86
+ { text: e("cms.builder.fieldOptions.slug"), id: "slug", color: "green", icon: "Link" },
87
+ { text: e("cms.builder.fieldOptions.richtext"), id: "richtext", color: "red", icon: "AlignLeft" },
88
+ { text: e("cms.builder.fieldOptions.reference"), id: "reference", color: "yellow", icon: "FileText" },
89
+ { text: e("cms.builder.fieldOptions.relation"), id: "relation", color: "pink", icon: "GitBranch" },
90
+ { text: e("cms.builder.fieldOptions.fileList"), id: "FileList", color: "orange", icon: "Files" },
91
+ { text: e("cms.builder.fieldOptions.tags"), id: "tags", color: "blue", icon: "Tags" }
92
+ ].filter((d) => n > 1 ? d.id !== "datalist" : !0),
93
+ validators: ["required"]
94
+ },
95
+ subtype: {
96
+ type: "combobox",
97
+ mode: "combo",
98
+ label: e("cms.builder.fieldLabels.subtype"),
99
+ placeholder: e("cms.builder.fieldPlaceholders.subtype"),
100
+ options: [
101
+ { text: e("cms.builder.fieldOptions.text"), id: "text" },
102
+ { text: e("cms.builder.fieldOptions.number"), id: "number" },
103
+ { text: e("cms.builder.fieldOptions.date"), id: "date" },
104
+ { text: e("cms.builder.fieldOptions.datetime"), id: "datetime" }
105
+ ],
106
+ conditions: ["type", "==", "array"]
107
+ },
108
+ parent: {
109
+ type: "text",
110
+ label: e("cms.builder.fieldLabels.parent"),
111
+ placeholder: e("cms.builder.fieldPlaceholders.parent"),
112
+ conditions: ["type", "in", ["slug", "select", "multiselect"]]
113
+ },
114
+ data: {
115
+ type: "text",
116
+ label: e("cms.builder.fieldLabels.data"),
117
+ placeholder: e("cms.builder.fieldPlaceholders.data"),
118
+ conditions: ["type", "in", ["select", "multiselect"]]
119
+ },
120
+ options: {
121
+ type: "datatable",
122
+ label: e("cms.builder.fieldLabels.options"),
123
+ conditions: ["type", "in", ["select", "multiselect", "radio"]],
124
+ colModel: [
125
+ {
126
+ key: "id",
127
+ label: "ID",
128
+ type: "text",
129
+ validators: ["required"],
130
+ col: 6
131
+ },
132
+ {
133
+ key: "text",
134
+ label: "Text",
135
+ type: "text",
136
+ validators: ["required"],
137
+ col: 6
138
+ }
139
+ ]
140
+ },
141
+ colModel: n <= 1 ? {
142
+ type: "datatable",
143
+ label: e("cms.builder.fieldLabels.colModel"),
144
+ conditions: ["type", "==", "datalist"],
145
+ colModel: Object.entries(q(n + 1, e)).map(([d, s]) => ({
146
+ key: d,
147
+ ...s,
148
+ ua: (s == null ? void 0 : s.label) || (s == null ? void 0 : s.ua)
149
+ }))
150
+ } : {
151
+ type: "switcher",
152
+ label: e("cms.builder.fieldLabels.required"),
153
+ hidden: !0,
154
+ required: !0
155
+ },
156
+ multiple: {
157
+ type: "switcher",
158
+ label: e("cms.builder.fieldLabels.multiple"),
159
+ conditions: ["type", "==", "file"]
160
+ },
161
+ relation: {
162
+ type: "combobox",
163
+ data: "collection",
164
+ label: e("cms.builder.fieldLabels.relation"),
165
+ conditions: ["type", "==", "relation"]
166
+ },
167
+ required: {
168
+ type: "switcher",
169
+ label: e("cms.builder.fieldLabels.required"),
170
+ required: !0
171
+ },
172
+ localization: {
173
+ type: "switcher",
174
+ label: e("cms.builder.fieldLabels.localization"),
175
+ conditions: ["type", "in", ["richtext", "text", "reference", "multiselect", "datalist"]],
176
+ required: !0
177
+ }
178
+ }), Ve = { class: "flex justify-end p-[20px] gap-[10px] border-t w-full" }, Le = {
179
+ __name: "vs-builder-datatable-form",
180
+ props: {
181
+ modelValue: {
182
+ type: Array,
183
+ default: () => []
184
+ },
185
+ modelModifiers: {}
186
+ },
187
+ emits: ["update:modelValue"],
188
+ setup(n) {
189
+ const { t: e } = I(), d = V(n, "modelValue"), s = v(!1), t = v({}), i = v({}), p = F(() => (i.value, q(0, e))), c = async () => {
190
+ if (await t.value.validate()) {
191
+ T({
192
+ type: "warning",
193
+ title: e("cms.common.actions.warning"),
194
+ message: e("cms.builder.createFieldFailed")
195
+ });
196
+ return;
197
+ }
198
+ try {
199
+ d.value = [...d.value, i.value], i.value = {}, s.value = !1;
200
+ } catch (r) {
201
+ console.log(r);
202
+ }
203
+ };
204
+ return (o, r) => (m(), g("div", null, [
205
+ l("button", {
206
+ onClick: r[0] || (r[0] = (y) => s.value = !0),
207
+ class: "inline-flex items-center justify-center h-10 gap-2 px-4 py-2 text-sm font-medium transition-colors border rounded-md hover hover:bg-gray-200 whitespace-nowrap ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring 0"
208
+ }, [
209
+ x(w(ne), { class: "w-4 h-4 mr-2" }),
210
+ H(" " + a(o.$t("cms.common.actions.addField")), 1)
211
+ ]),
212
+ x(w(W), {
213
+ teleport: "#modal",
214
+ title: o.$t("cms.builder.createField"),
215
+ size: "small",
216
+ visible: s.value,
217
+ "onUpdate:visible": r[4] || (r[4] = (y) => s.value = y),
218
+ onClose: r[5] || (r[5] = (y) => s.value = !1)
219
+ }, {
220
+ footer: j(() => [
221
+ l("div", Ve, [
222
+ l("button", {
223
+ class: "inline-flex items-center px-3 py-2 text-sm text-black duration-300 border border-gray-200 rounded-lg gap-x-2 whitespace-nowrap hover:bg-gray-100",
224
+ onClick: r[3] || (r[3] = (y) => s.value = !1)
225
+ }, a(o.$t("cms.common.actions.cancel")), 1),
226
+ l("button", {
227
+ onClick: c,
228
+ class: "py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-white bg-blue-500 rounded-lg !border-gray-200 hover:bg-blue-700 duration-300"
229
+ }, a(o.$t("cms.common.actions.save")), 1)
230
+ ])
231
+ ]),
232
+ default: j(() => [
233
+ x(w(Q), {
234
+ modelValue: i.value,
235
+ "onUpdate:modelValue": r[1] || (r[1] = (y) => i.value = y),
236
+ schema: p.value,
237
+ form: t.value,
238
+ "onUpdate:form": r[2] || (r[2] = (y) => t.value = y)
239
+ }, null, 8, ["modelValue", "schema", "form"])
240
+ ]),
241
+ _: 1
242
+ }, 8, ["title", "visible"])
243
+ ]));
244
+ }
245
+ }, qe = { class: "flex items-center justify-end col-span-3 gap-2" }, Fe = {
246
+ key: 2,
247
+ class: "w-8 h-4"
248
+ }, Oe = { class: "flex justify-end p-[20px] gap-[10px] border-t w-full" }, Te = {
249
+ __name: "vs-builder-datatable-controls",
250
+ props: /* @__PURE__ */ ee({
251
+ index: {
252
+ type: Number,
253
+ required: !0
254
+ },
255
+ data: {
256
+ type: Object,
257
+ required: !0
258
+ }
259
+ }, {
260
+ columns: {
261
+ type: Array,
262
+ default: () => []
263
+ },
264
+ columnsModifiers: {}
265
+ }),
266
+ emits: ["update:columns"],
267
+ setup(n) {
268
+ const { t: e } = I(), d = G(() => import("@opengis/form")), s = n, t = V(n, "columns"), i = v(!1), p = v({}), c = v({ ...s.data || {} }), o = v({});
269
+ P(() => {
270
+ s.data.required ? o.value = {
271
+ ...q(0, e),
272
+ name: {
273
+ ...q(0, e).name,
274
+ disabled: !0
275
+ },
276
+ label: {
277
+ ...q(0, e).label,
278
+ disabled: !0
279
+ },
280
+ type: {
281
+ ...q(0, e).type,
282
+ disabled: !0
283
+ }
284
+ } : o.value = q(0, e);
285
+ });
286
+ const r = () => {
287
+ fe({
288
+ title: e("cms.builder.deleteTitle"),
289
+ message: e("cms.builder.deleteField"),
290
+ type: "error",
291
+ onConfirm: () => {
292
+ y();
293
+ }
294
+ });
295
+ }, y = () => {
296
+ t.value = t.value.filter((k, b) => b !== s.index);
297
+ }, _ = async () => {
298
+ if (await p.value.validate()) {
299
+ T({
300
+ type: "warning",
301
+ title: e("cms.common.actions.warning"),
302
+ message: e("cms.builder.editFieldFailed")
303
+ });
304
+ return;
305
+ }
306
+ try {
307
+ t.value[s.index] = c.value, i.value = !1;
308
+ } catch (b) {
309
+ console.log(b);
310
+ }
311
+ };
312
+ return (k, b) => (m(), g("div", qe, [
313
+ ["status"].includes(n.data.name) ? O("", !0) : (m(), g("button", {
314
+ key: 0,
315
+ onClick: b[0] || (b[0] = (C) => i.value = !0),
316
+ class: "inline-flex items-center justify-center gap-2 whitespace-nowrap text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 hover:text-accent-foreground h-8 w-8 rounded-full hover:bg-gray-100"
317
+ }, [
318
+ x(w(de), { class: "w-4 h-4" })
319
+ ])),
320
+ n.data.required ? (m(), g("button", Fe)) : (m(), g("button", {
321
+ key: 1,
322
+ onClick: r,
323
+ class: "inline-flex items-center justify-center gap-2 whitespace-nowrap text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 h-8 w-8 rounded-full hover:bg-red-100 text-red-600 hover:text-red-700"
324
+ }, [
325
+ x(w(ce), { class: "w-4 h-4" })
326
+ ])),
327
+ x(w(W), {
328
+ teleport: "#modal",
329
+ visible: i.value,
330
+ title: k.$t("cms.builder.editField"),
331
+ onClose: b[4] || (b[4] = (C) => i.value = !1)
332
+ }, {
333
+ footer: j(() => [
334
+ l("div", Oe, [
335
+ l("button", {
336
+ class: "inline-flex items-center px-3 py-2 text-sm text-black duration-300 border border-gray-200 rounded-lg gap-x-2 whitespace-nowrap hover:bg-gray-100",
337
+ onClick: b[3] || (b[3] = (C) => i.value = !1)
338
+ }, a(k.$t("cms.common.actions.cancel")), 1),
339
+ l("button", {
340
+ class: "py-2 px-3 inline-flex items-center gap-x-2 text-sm whitespace-nowrap text-white bg-blue-500 rounded-lg !border-gray-200 hover:bg-blue-700 duration-300",
341
+ onClick: _
342
+ }, a(k.$t("cms.common.actions.save")), 1)
343
+ ])
344
+ ]),
345
+ default: j(() => [
346
+ x(w(d), {
347
+ modelValue: c.value,
348
+ "onUpdate:modelValue": b[1] || (b[1] = (C) => c.value = C),
349
+ schema: o.value,
350
+ form: p.value,
351
+ "onUpdate:form": b[2] || (b[2] = (C) => p.value = C)
352
+ }, null, 8, ["modelValue", "schema", "form"])
353
+ ]),
354
+ _: 1
355
+ }, 8, ["visible", "title"])
356
+ ]));
357
+ }
358
+ }, je = { class: "flex items-center justify-between mb-6" }, Me = { class: "text-xl font-semibold text-gray-900" }, Ue = { class: "mt-1 text-sm text-gray-600" }, Ie = { class: "flex items-center gap-2" }, ze = { class: "overflow-hidden bg-white border border-gray-200 shadow-sm rounded-xl" }, Pe = { class: "grid grid-cols-12 gap-4 px-6 py-4 border-b border-gray-200 bg-gray-50" }, Ne = { class: "col-span-5 font-medium text-gray-700" }, Se = { class: "col-span-3 font-medium text-gray-700" }, Be = { class: "col-span-2 font-medium text-gray-700" }, Ae = { class: "col-span-2 font-medium text-right text-gray-700" }, De = { class: "divide-y divide-gray-100" }, Ee = { class: "grid items-center grid-cols-12 gap-4 px-6 py-4 transition-colors hover:bg-gray-50/50" }, Re = { class: "flex items-center col-span-5 gap-3" }, He = { class: "font-medium text-gray-900" }, Ge = { class: "text-xs text-gray-500" }, Je = {
359
+ key: 0,
360
+ class: "inline-flex items-center px-2 py-1 text-xs font-medium text-blue-700 rounded-full bg-blue-50 ring-1 ring-inset ring-blue-700/10"
361
+ }, Ye = { class: "col-span-3" }, Ke = { class: "inline-flex items-center px-2 py-1 text-sm font-medium text-gray-600 rounded-md bg-gray-50 ring-1 ring-inset ring-gray-500/10" }, Qe = { class: "col-span-1" }, We = {
362
+ key: 0,
363
+ xmlns: "http://www.w3.org/2000/svg",
364
+ width: "24",
365
+ height: "24",
366
+ viewBox: "0 0 24 24",
367
+ fill: "none",
368
+ stroke: "currentColor",
369
+ "stroke-width": "2",
370
+ "stroke-linecap": "round",
371
+ "stroke-linejoin": "round",
372
+ class: "lucide lucide-circle-check w-4 h-4 text-emerald-600"
373
+ }, Xe = {
374
+ key: 1,
375
+ class: "grid items-center grid-cols-12 gap-4 px-6 py-4 transition-colors hover:bg-gray-50/50"
376
+ }, Ze = { class: "col-span-5" }, et = { class: "text-gray-500" }, tt = {
377
+ __name: "vs-builder-datatable",
378
+ props: {
379
+ modelValue: {},
380
+ modelModifiers: {}
381
+ },
382
+ emits: ["update:modelValue"],
383
+ setup(n) {
384
+ const e = V(n, "modelValue"), d = (t) => t === "array" ? "purple" : t === "boolean" || t === "date" ? "red" : t === "datetime" ? "purple" : t === "number" ? "green" : t === "text" ? "blue" : t === "file" || t === "select" ? "yellow" : t === "slug" ? "green" : t === "image" ? "blue" : "gray", s = (t) => {
385
+ switch (t) {
386
+ case "text":
387
+ return M;
388
+ case "number":
389
+ return R;
390
+ case "integer":
391
+ return R;
392
+ case "date":
393
+ return be;
394
+ case "datetime":
395
+ return pe;
396
+ case "file":
397
+ return S;
398
+ case "select":
399
+ return D;
400
+ case "multiselect":
401
+ return me;
402
+ case "mediaselect":
403
+ return A;
404
+ case "radio":
405
+ return E;
406
+ case "boolean":
407
+ return E;
408
+ case "datalist":
409
+ return D;
410
+ case "image":
411
+ return A;
412
+ case "slug":
413
+ return B;
414
+ case "richtext":
415
+ return M;
416
+ case "markdown":
417
+ return M;
418
+ case "reference":
419
+ return ue;
420
+ case "relation":
421
+ return B;
422
+ case "FileList":
423
+ return S;
424
+ default:
425
+ return M;
426
+ }
427
+ };
428
+ return (t, i) => {
429
+ var p, c;
430
+ return m(), g(J, null, [
431
+ l("div", je, [
432
+ l("div", null, [
433
+ l("h2", Me, a(t.$t("cms.builder.collectionStructure")), 1),
434
+ l("p", Ue, a(t.$t("cms.builder.defineFields")), 1)
435
+ ]),
436
+ l("div", Ie, [
437
+ x(Le, {
438
+ modelValue: e.value.columns,
439
+ "onUpdate:modelValue": i[0] || (i[0] = (o) => e.value.columns = o)
440
+ }, null, 8, ["modelValue"])
441
+ ])
442
+ ]),
443
+ l("div", ze, [
444
+ l("div", Pe, [
445
+ l("div", Ne, a(t.$t("cms.builder.name")), 1),
446
+ l("div", Se, a(t.$t("cms.builder.type")), 1),
447
+ l("div", Be, a(t.$t("cms.builder.localization")), 1),
448
+ l("div", Ae, a(t.$t("cms.builder.actions")), 1)
449
+ ]),
450
+ l("div", De, [
451
+ (c = (p = e.value) == null ? void 0 : p.columns) != null && c.length ? (m(), U(w(ve), {
452
+ key: 0,
453
+ modelValue: e.value.columns,
454
+ "onUpdate:modelValue": i[2] || (i[2] = (o) => e.value.columns = o),
455
+ "item-key": "name",
456
+ handle: ".drag-handle",
457
+ animation: 200
458
+ }, {
459
+ item: j(({ element: o, index: r }) => {
460
+ var y, _;
461
+ return [
462
+ l("div", Ee, [
463
+ l("div", Re, [
464
+ i[3] || (i[3] = l("span", { class: "drag-handle cursor-move mr-2 text-gray-400" }, "☰", -1)),
465
+ l("div", {
466
+ class: Y(["flex items-center justify-center p-1 rounded", `bg-${d((y = o.type) == null ? void 0 : y.toLowerCase())}-100`])
467
+ }, [
468
+ (m(), U(K(s((_ = o.type) == null ? void 0 : _.toLowerCase())), { class: "w-4 h-4" }))
469
+ ], 2),
470
+ l("div", null, [
471
+ l("p", He, a(o.label), 1),
472
+ l("p", Ge, a(o.name), 1)
473
+ ]),
474
+ o.required ? (m(), g("span", Je, a(t.$t("cms.builder.required")), 1)) : O("", !0)
475
+ ]),
476
+ l("div", Ye, [
477
+ l("span", Ke, a(o.type), 1)
478
+ ]),
479
+ l("div", Qe, [
480
+ o.localization ? (m(), g("svg", We, [...i[4] || (i[4] = [
481
+ l("circle", {
482
+ cx: "12",
483
+ cy: "12",
484
+ r: "10"
485
+ }, null, -1),
486
+ l("path", { d: "m9 12 2 2 4-4" }, null, -1)
487
+ ])])) : O("", !0)
488
+ ]),
489
+ x(Te, {
490
+ columns: e.value.columns,
491
+ "onUpdate:columns": i[1] || (i[1] = (k) => e.value.columns = k),
492
+ data: e.value.columns[r],
493
+ index: r
494
+ }, null, 8, ["columns", "data", "index"])
495
+ ])
496
+ ];
497
+ }),
498
+ _: 1
499
+ }, 8, ["modelValue"])) : (m(), g("div", Xe, [
500
+ l("div", Ze, [
501
+ l("p", et, a(t.$t("cms.builder.noColumnsFound")), 1)
502
+ ])
503
+ ]))
504
+ ])
505
+ ])
506
+ ], 64);
507
+ };
508
+ }
509
+ }, lt = {
510
+ __name: "vs-builder-edit",
511
+ props: {
512
+ data: {},
513
+ dataModifiers: {},
514
+ form: {},
515
+ formModifiers: {}
516
+ },
517
+ emits: ["update:data", "update:form"],
518
+ setup(n) {
519
+ const { t: e } = I(), d = G(() => import("@opengis/form")), s = V(n, "data"), t = V(n, "form");
520
+ v({});
521
+ const i = F(() => ({
522
+ name: {
523
+ type: "text",
524
+ disabled: !0,
525
+ readonly: !0,
526
+ label: e("cms.builder.scheme.name.label"),
527
+ required: !0,
528
+ placeholder: e("cms.builder.scheme.name.placeholder"),
529
+ validators: ["required"],
530
+ col: 3
531
+ },
532
+ title: {
533
+ type: "text",
534
+ label: e("cms.builder.scheme.title.label"),
535
+ required: !0,
536
+ placeholder: e("cms.builder.scheme.title.placeholder"),
537
+ validators: ["required"],
538
+ col: 3
539
+ },
540
+ preview_path: {
541
+ type: "text",
542
+ label: e("cms.builder.scheme.preview_path.label"),
543
+ placeholder: e("cms.builder.scheme.preview_path.placeholder"),
544
+ col: 3,
545
+ info: e("cms.builder.scheme.preview_path.info")
546
+ },
547
+ // slug: {
548
+ // type: "slug",
549
+ // label: "Title",
550
+ // parent: "title",
551
+ // required: true,
552
+ // placeholder: "Title",
553
+ // validators: ["required"],
554
+ // col: 4,
555
+ // },
556
+ type: {
557
+ hidden: !0,
558
+ type: "select",
559
+ label: e("cms.builder.scheme.type.label"),
560
+ required: !0,
561
+ placeholder: e("cms.builder.scheme.type.placeholder"),
562
+ validators: ["required"],
563
+ col: 4,
564
+ options: [
565
+ {
566
+ text: e("cms.builder.scheme.type.options.collection"),
567
+ id: "collection"
568
+ },
569
+ {
570
+ text: e("cms.builder.scheme.type.options.single"),
571
+ id: "single"
572
+ }
573
+ ]
574
+ },
575
+ status: {
576
+ hidden: !0,
577
+ type: "select",
578
+ label: e("cms.builder.scheme.status.label"),
579
+ required: !0,
580
+ placeholder: e("cms.builder.scheme.status.placeholder"),
581
+ col: 4,
582
+ options: [
583
+ {
584
+ text: e("cms.builder.scheme.status.options.published"),
585
+ id: "published"
586
+ },
587
+ {
588
+ text: e("cms.builder.scheme.status.options.draft"),
589
+ id: "draft"
590
+ },
591
+ {
592
+ text: e("cms.builder.scheme.status.options.archived"),
593
+ id: "archived"
594
+ }
595
+ ]
596
+ },
597
+ include_search: {
598
+ type: "switcher",
599
+ label: e("cms.builder.scheme.include_search.label"),
600
+ placeholder: e("cms.builder.scheme.include_search.placeholder"),
601
+ col: 3
602
+ },
603
+ description: {
604
+ type: "textarea",
605
+ label: e("cms.builder.scheme.description.label"),
606
+ required: !0,
607
+ placeholder: e("cms.builder.scheme.description.placeholder")
608
+ }
609
+ }));
610
+ return te(() => {
611
+ t.value = null;
612
+ }), (p, c) => (m(), g("div", null, [
613
+ x(w(d), {
614
+ modelValue: s.value,
615
+ "onUpdate:modelValue": c[0] || (c[0] = (o) => s.value = o),
616
+ schema: i.value,
617
+ form: t.value,
618
+ "onUpdate:form": c[1] || (c[1] = (o) => t.value = o)
619
+ }, null, 8, ["modelValue", "schema", "form"]),
620
+ x(tt, {
621
+ modelValue: s.value,
622
+ "onUpdate:modelValue": c[2] || (c[2] = (o) => s.value = o)
623
+ }, null, 8, ["modelValue"])
624
+ ]));
625
+ }
626
+ }, st = {
627
+ __name: "vs-builder-preview",
628
+ props: {
629
+ data: {},
630
+ dataModifiers: {},
631
+ form: {},
632
+ formModifiers: {}
633
+ },
634
+ emits: ["update:data", "update:form"],
635
+ setup(n) {
636
+ $["vs-input-custom-datatable"] = ge, $["vs-input-reference"] = ye, $["vs-input-texteditor"] = he, $["vs-input-mediaselect"] = z, $["vs-input-file"] = z, $["vs-input-image"] = z, $["vs-input-richtext-md"] = xe, $["vs-input-integer"] = we, $["vs-input-relation-link"] = _e;
637
+ const e = v({}), d = V(n, "data"), s = V(n, "form"), t = F(() => {
638
+ var i, p;
639
+ return ((p = (i = d.value) == null ? void 0 : i.columns) == null ? void 0 : p.map(ke)) || [];
640
+ });
641
+ return (i, p) => {
642
+ var c;
643
+ return m(), g("div", {
644
+ ref_key: "form",
645
+ ref: s
646
+ }, [
647
+ ((c = t.value) == null ? void 0 : c.length) > 0 ? (m(), U(w(Q), {
648
+ key: 0,
649
+ modelValue: e.value,
650
+ "onUpdate:modelValue": p[0] || (p[0] = (o) => e.value = o),
651
+ schema: t.value
652
+ }, null, 8, ["modelValue", "schema"])) : O("", !0)
653
+ ], 512);
654
+ };
655
+ }
656
+ }, it = {
657
+ monaco: Ce,
658
+ edit: lt,
659
+ preview: st
660
+ }, ot = { class: "mx-auto max-w-[90%]" }, rt = { class: "flex items-center justify-between mb-6" }, at = { class: "mb-2 text-2xl font-semibold text-gray-900" }, nt = { class: "lowercase" }, dt = { class: "text-gray-600" }, ct = { class: "flex items-center gap-2" }, ut = { class: "w-full" }, mt = { class: "flex items-center w-full h-10 max-w-md grid-cols-3 p-1 mb-6 bg-white border border-gray-200 rounded-md text-muted-foreground" }, pt = ["onClick"], bt = {
661
+ key: 0,
662
+ class: "mx-auto bg-white rounded-md py-4 px-2 bg-opacity-50"
663
+ }, Ct = /* @__PURE__ */ le({
664
+ __name: "EditCollectionPage",
665
+ setup(n) {
666
+ const { t: e } = I(), d = se("cms.fetchContentTypes"), s = v("edit"), t = v({ yaml: "", data: { columns: [], type: "collection" } }), i = v({}), p = v(""), c = oe(), o = re(), r = v(!1), y = F(() => [
667
+ // {
668
+ // name: "YAML",
669
+ // id: "monaco",
670
+ // },
671
+ {
672
+ name: e("cms.builder.edit"),
673
+ id: "edit"
674
+ },
675
+ {
676
+ name: e("cms.builder.preview"),
677
+ id: "preview"
678
+ }
679
+ ]), _ = F(() => {
680
+ const f = c.params.id;
681
+ return f === "edit" ? c.params.collection : f;
682
+ }), k = F(() => [
683
+ {
684
+ label: p.value || _.value,
685
+ route: `collections/${_.value}`
686
+ },
687
+ {
688
+ label: e("cms.collections.edit")
689
+ }
690
+ ]), b = (f) => {
691
+ o.push(`/${f}`);
692
+ }, C = async () => {
693
+ var f;
694
+ try {
695
+ if (!_.value)
696
+ return;
697
+ const u = await (await fetch(`/api/cms-type/${_.value}`)).json(), L = {
698
+ ...u,
699
+ columns: Array.isArray(u.columns) ? u.columns : (f = Object.entries((u == null ? void 0 : u.columns) || {})) == null ? void 0 : f.map(([N, Z]) => ({
700
+ ...Z,
701
+ name: N
702
+ }))
703
+ };
704
+ t.value = {
705
+ ...t.value,
706
+ data: L
707
+ }, p.value = L.title || L.name;
708
+ } catch (h) {
709
+ console.error(h);
710
+ } finally {
711
+ r.value = !0;
712
+ }
713
+ }, X = async () => {
714
+ var f, h;
715
+ try {
716
+ if (await i.value.validate()) {
717
+ T({
718
+ type: "warning",
719
+ title: e("cms.common.actions.warning"),
720
+ message: e("cms.builder.editFieldFailed")
721
+ });
722
+ return;
723
+ }
724
+ const L = _.value;
725
+ if (!L)
726
+ return;
727
+ const N = await fetch(
728
+ `/api/cms-type/${L}`,
729
+ {
730
+ method: "PUT",
731
+ headers: {
732
+ "Content-Type": "application/json"
733
+ },
734
+ body: JSON.stringify(s.value === "monaco" ? (f = t.value) == null ? void 0 : f.yaml : (h = t.value) == null ? void 0 : h.data)
735
+ }
736
+ );
737
+ o.back(), d && d(), T({
738
+ type: "success",
739
+ title: e("cms.common.actions.success"),
740
+ message: e("cms.collections.collectionCreated")
741
+ });
742
+ } catch (u) {
743
+ console.error(u), T({
744
+ type: "error",
745
+ title: e("cms.common.actions.error"),
746
+ message: e("cms.collections.collectionCreationFailed")
747
+ });
748
+ }
749
+ };
750
+ return P(() => {
751
+ C();
752
+ }), (f, h) => (m(), g("div", ot, [
753
+ x($e, {
754
+ items: k.value,
755
+ onNavigate: b
756
+ }, null, 8, ["items"]),
757
+ l("div", rt, [
758
+ l("div", null, [
759
+ l("h1", at, [
760
+ H(a(f.$t("cms.builder.editCollection")) + ": ", 1),
761
+ l("span", nt, ' "' + a(p.value) + '" ', 1)
762
+ ]),
763
+ l("p", dt, a(f.$t("cms.builder.editContentForYourSite")), 1)
764
+ ]),
765
+ l("div", ct, [
766
+ l("a", {
767
+ onClick: h[0] || (h[0] = (u) => w(o).back()),
768
+ class: "inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 border bg-background hover:text-accent-foreground h-10 px-4 py-2 border-gray-300 text-gray-700 hover:bg-gray-50"
769
+ }, a(f.$t("cms.common.actions.back")), 1),
770
+ l("button", {
771
+ onClick: X,
772
+ class: "inline-flex items-center justify-center gap-2 whitespace-nowrap text-white rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 text-primary-foreground h-10 px-4 py-2 bg-blue-600 hover:bg-blue-700"
773
+ }, a(f.$t("cms.common.actions.save")), 1)
774
+ ])
775
+ ]),
776
+ l("div", ut, [
777
+ l("div", mt, [
778
+ (m(!0), g(J, null, ie(y.value, (u) => (m(), g("button", {
779
+ key: u.id,
780
+ onClick: (L) => s.value = u.id,
781
+ class: Y([
782
+ "inline-flex flex-1 items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm data-[state=active]:bg-blue-50 data-[state=active]:text-blue-700 data-[state=active]:border-blue-200",
783
+ u.id === s.value ? "bg-blue-50 text-blue-700 border-blue-200" : ""
784
+ ])
785
+ }, a(u.name), 11, pt))), 128))
786
+ ])
787
+ ]),
788
+ r.value ? (m(), g("div", bt, [
789
+ (m(), U(K(w(it)[s.value]), {
790
+ yaml: t.value.yaml,
791
+ "onUpdate:yaml": h[1] || (h[1] = (u) => t.value.yaml = u),
792
+ data: t.value.data,
793
+ "onUpdate:data": h[2] || (h[2] = (u) => t.value.data = u),
794
+ form: i.value,
795
+ "onUpdate:form": h[3] || (h[3] = (u) => i.value = u)
796
+ }, null, 40, ["yaml", "data", "form"]))
797
+ ])) : O("", !0)
798
+ ]));
799
+ }
800
+ });
801
+ export {
802
+ Ct as default
803
+ };