@oneclick.dev/cms-core-modules 0.0.120 → 0.0.122

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 (61) hide show
  1. package/dist/{ContentEditor-YFnqVZrX.js → ContentEditor-CoJjsV-m.js} +43 -43
  2. package/dist/{ContentEditor-W4YrQyBW.mjs → ContentEditor-DIwqplfB.mjs} +9952 -11359
  3. package/dist/{Detail-C8wQiDcv.js → Detail-BCUUNWvp.js} +1 -1
  4. package/dist/{Detail-CtItxMX4.mjs → Detail-B_scnidb.mjs} +1 -1
  5. package/dist/Detail-Cn9Bk0u0.mjs +852 -0
  6. package/dist/Detail-DGg_xXZc.js +1 -0
  7. package/dist/Detail-Dk8E6_uF.mjs +3731 -0
  8. package/dist/Detail-Sc2qZdxj.js +1 -0
  9. package/dist/EditLayout.vue_vue_type_script_setup_true_lang-4_t0PPqM.mjs +78 -0
  10. package/dist/EditLayout.vue_vue_type_script_setup_true_lang-D1b9_iiN.js +1 -0
  11. package/dist/Overview-CVgViW3c.mjs +852 -0
  12. package/dist/Overview-DEF-z7Yb.js +1 -0
  13. package/dist/SendPush-CgSBEex2.js +1 -0
  14. package/dist/SendPush-CmbjcQBL.mjs +680 -0
  15. package/dist/{agenda-BusN9-XG.js → agenda-B54F8cEr.js} +1 -1
  16. package/dist/{agenda-CJXKaIo0.mjs → agenda-BCKDYOeF.mjs} +1 -1
  17. package/dist/{availability-UUKdgidr.js → availability-C4v46rha.js} +1 -1
  18. package/dist/{availability-BP6GACqo.mjs → availability-DVT1Mdxq.mjs} +1 -1
  19. package/dist/{booking-data-BHfLyOlu.js → booking-data-A5JrLY4j.js} +1 -1
  20. package/dist/{booking-data-WCBcpOOo.mjs → booking-data-lZvSYna2.mjs} +1 -1
  21. package/dist/{exceptions-B8r2psu2.mjs → exceptions-DJHfvADv.mjs} +1 -1
  22. package/dist/{exceptions-BazAiy2s.js → exceptions-DKc8fO1S.js} +1 -1
  23. package/dist/{index-BiKWKrEs.js → index-Bk3yLv_G.js} +1 -1
  24. package/dist/{index-Dnn2SCSl.js → index-CZau1wR8.js} +1 -1
  25. package/dist/{index-DRqJOqUR.mjs → index-DE8rdSjd.mjs} +0 -22
  26. package/dist/{index-DJxex3Dt.mjs → index-DU3Ib10Z.mjs} +1 -1
  27. package/dist/index.cjs.js +1 -1
  28. package/dist/index.mjs +50 -37
  29. package/dist/languages-C_8yMQOH.mjs +4 -0
  30. package/dist/languages-Dqvk3X8G.js +1 -0
  31. package/dist/{orders-CAAuDhkQ.js → orders-BMosTk6r.js} +1 -1
  32. package/dist/{orders-B8C6u4iF.mjs → orders-CElKNc1v.mjs} +1 -1
  33. package/dist/{payment-BOOJ1O6M.mjs → payment-DSQ_2FIT.mjs} +1 -1
  34. package/dist/{payment-IxA9qiCV.js → payment-DlgYuea2.js} +1 -1
  35. package/dist/{refunds-CqGKm1NG.js → refunds-Cvw9N--u.js} +1 -1
  36. package/dist/{refunds-CI0qpJC0.mjs → refunds-xR936Ted.mjs} +1 -1
  37. package/dist/reports-BQT_GZzU.js +158 -0
  38. package/dist/reports-DksZCTOw.mjs +837 -0
  39. package/dist/{resources-dIZDh4Sz.mjs → resources-C-5BU9Ux.mjs} +1 -1
  40. package/dist/{resources-B75nXreU.js → resources-D04yKKVN.js} +1 -1
  41. package/dist/src/productCollections/components/detail/Subcollections.vue.d.ts +2 -0
  42. package/dist/src/productCollections/types.d.ts +1 -4
  43. package/dist/src/products/components/detail/variants/VariantList.vue.d.ts +48 -6
  44. package/dist/src/products/components/detail/variants/dialogs/VariantDialog.vue.d.ts +4 -0
  45. package/dist/src/push-notifications/config.d.ts +22 -0
  46. package/dist/src/push-notifications/index.d.ts +22 -0
  47. package/dist/src/push-notifications/types.d.ts +5 -0
  48. package/dist/{vee-validate-zod-CcOwoF6y.mjs → vee-validate-zod-SjDT8X35.mjs} +92 -90
  49. package/dist/{vee-validate-zod-ByykgYKJ.js → vee-validate-zod-VCmLnrtQ.js} +1 -1
  50. package/package.json +2 -2
  51. package/dist/Detail-C1Blq61w.mjs +0 -585
  52. package/dist/Detail-CPqug27l.js +0 -1
  53. package/dist/Detail-CjuhjPby.js +0 -1
  54. package/dist/Detail-Dnpnmy4-.mjs +0 -3477
  55. package/dist/EditLayout.vue_vue_type_script_setup_true_lang-BXVf9gZW.mjs +0 -77
  56. package/dist/EditLayout.vue_vue_type_script_setup_true_lang-CFFZ6r8i.js +0 -1
  57. package/dist/Overview-BWLxUksJ.mjs +0 -860
  58. package/dist/Overview-DAxCu9XC.js +0 -1
  59. package/dist/SendPush-COns44j7.js +0 -1
  60. package/dist/SendPush-CPIOjVX4.mjs +0 -184
  61. /package/dist/src/{productCollections/components/detail/SEO.vue.d.ts → appointments/pages/edit/reports.vue.d.ts} +0 -0
@@ -0,0 +1,852 @@
1
+ import { defineComponent as W, inject as N, openBlock as r, createElementBlock as _, createElementVNode as u, Fragment as E, renderList as Y, withModifiers as se, normalizeClass as J, unref as d, createCommentVNode as T, toDisplayString as $, createTextVNode as p, resolveComponent as n, createBlock as P, withCtx as o, createVNode as t, computed as O, renderSlot as ve, ref as K, useTemplateRef as ge, withAsyncContext as be, watch as _e, onMounted as xe, onUnmounted as Ce, provide as Q, withKeys as ye } from "vue";
2
+ import { Filter as we, ChevronsUpDown as ke, CornerDownRight as he, Check as Pe, RotateCcw as Se, ExternalLink as $e, Search as Me, Plus as Ve, LayoutGrid as Te, List as Ae } from "lucide-vue-next";
3
+ import { useModuleRoute as Z, useModulePermissions as ee, useFirebaseIntegration as te, useConfirmation as ze, useModuleBreadcrumbs as Ie } from "@oneclick.dev/cms-kit";
4
+ import { a as Le } from "./index-hMp4p5qA.mjs";
5
+ import { c as Ee } from "./utils-CanmrIWO.mjs";
6
+ import { t as L } from "./index-RLz1QPrf.mjs";
7
+ const De = { class: "grid @md:grid-cols-2 @2xl:grid-cols-3 @3xl:grid-cols-4 @4xl:grid-cols-5 @5xl:grid-cols-6 gap-6" }, Fe = ["onClick", "onContextmenu"], Be = ["src"], Ue = { class: "font-semibold" }, Re = { class: "text-sm text-muted-foreground flex items-center gap-2" }, je = { class: "flex items-center gap-2" }, Ke = { key: 0 }, Ne = /* @__PURE__ */ W({
8
+ __name: "GridView",
9
+ props: {
10
+ products: {
11
+ type: Array,
12
+ required: !0
13
+ }
14
+ },
15
+ setup(U) {
16
+ const s = N("selection"), { navigateTo: A } = Z(), { hasPermission: S } = ee(), f = (a, l) => {
17
+ const m = l.ctrlKey || l.metaKey;
18
+ if (!l.shiftKey) if (m || s.value.length > 0) {
19
+ const k = s.value.indexOf(a.id);
20
+ k > -1 ? s.value.splice(k, 1) : s.value.push(a.id);
21
+ } else
22
+ s.value = [], A(a.id);
23
+ }, y = (a) => {
24
+ a.target.closest(".GRID_ITEM") || (s.value = []);
25
+ }, x = (a, l) => {
26
+ l.ctrlKey || l.metaKey ? s.value.includes(a.id) ? s.value.splice(s.value.indexOf(a.id), 1) : s.value.push(a.id) : s.value.includes(a.id) || (s.value = [a.id]);
27
+ };
28
+ return (a, l) => (r(), _("div", {
29
+ class: "@container mb-4 flex-1 select-none",
30
+ onClick: l[0] || (l[0] = (m) => s.value = []),
31
+ onContextmenu: y
32
+ }, [
33
+ u("div", De, [
34
+ (r(!0), _(E, null, Y(U.products, (m) => (r(), _("div", {
35
+ key: m.id,
36
+ onClick: se((w) => f(m, w), ["stop"]),
37
+ onContextmenu: (w) => x(m, w),
38
+ class: "GRID_ITEM cursor-pointer"
39
+ }, [
40
+ u("div", {
41
+ class: J(["aspect-square bg-muted rounded-xl overflow-hidden mb-2 transition-all duration-200", { "outline outline-4 outline-primary/50": d(s).includes(m.id) }])
42
+ }, [
43
+ m.featuredMedia ? (r(), _("img", {
44
+ key: 0,
45
+ src: m.featuredMedia,
46
+ class: "w-full h-full object-cover pointer-events-none",
47
+ draggable: "false"
48
+ }, null, 8, Be)) : T("", !0)
49
+ ], 2),
50
+ u("div", null, [
51
+ u("p", Ue, $(m.title), 1),
52
+ u("p", Re, [
53
+ u("span", je, [
54
+ m.status === "published" ? (r(), _(E, { key: 0 }, [
55
+ l[1] || (l[1] = u("span", { class: "block shrink-0 size-3 rounded-full bg-green-500" }, null, -1)),
56
+ l[2] || (l[2] = p(" Published ", -1))
57
+ ], 64)) : m.status === "draft" ? (r(), _(E, { key: 1 }, [
58
+ l[3] || (l[3] = u("span", { class: "block shrink-0 size-3 rounded-full bg-blue-500" }, null, -1)),
59
+ l[4] || (l[4] = p(" Draft ", -1))
60
+ ], 64)) : (r(), _(E, { key: 2 }, [
61
+ l[5] || (l[5] = u("span", { class: "block shrink-0 size-3 rounded-full bg-gray-300" }, null, -1)),
62
+ l[6] || (l[6] = p(" Archived ", -1))
63
+ ], 64))
64
+ ]),
65
+ m.variantsTotal > 1 ? (r(), _("span", Ke, "| " + $(m.variantsTotal) + " variants", 1)) : T("", !0)
66
+ ])
67
+ ])
68
+ ], 40, Fe))), 128))
69
+ ])
70
+ ], 32));
71
+ }
72
+ }), Ge = { class: "flex items-center gap-2" }, Oe = {
73
+ key: 0,
74
+ class: "bg-green-500 text-green-950 px-2 py-1 rounded-lg text-xs"
75
+ }, He = {
76
+ key: 1,
77
+ class: "bg-blue-500 text-blue-950 px-2 py-1 rounded-lg text-xs"
78
+ }, qe = {
79
+ key: 2,
80
+ class: "bg-gray-500 text-gray-950 px-2 py-1 rounded-lg text-xs"
81
+ }, Qe = /* @__PURE__ */ W({
82
+ __name: "ListView",
83
+ props: {
84
+ products: {
85
+ type: Array,
86
+ required: !0
87
+ }
88
+ },
89
+ setup(U) {
90
+ const s = N("selection"), { navigateTo: A } = Z(), { hasPermission: S } = ee(), f = (y, x) => {
91
+ y ? s.value.push(x) : s.value = s.value.filter((a) => a !== x);
92
+ };
93
+ return (y, x) => {
94
+ const a = n("TableHead"), l = n("TableRow"), m = n("TableHeader"), w = n("Checkbox"), k = n("TableCell"), b = n("AvatarImage"), e = n("AvatarFallback"), C = n("Avatar"), h = n("TableBody"), M = n("Table"), V = n("Card");
95
+ return r(), P(V, { class: "w-full py-4 px-4" }, {
96
+ default: o(() => [
97
+ t(M, { class: "rounded overflow-hidden" }, {
98
+ default: o(() => [
99
+ t(m, null, {
100
+ default: o(() => [
101
+ t(l, null, {
102
+ default: o(() => [
103
+ d(s)?.length > 0 ? (r(), P(a, { key: 0 })) : T("", !0),
104
+ t(a, null, {
105
+ default: o(() => [...x[1] || (x[1] = [
106
+ p("Title", -1)
107
+ ])]),
108
+ _: 1
109
+ }),
110
+ t(a, null, {
111
+ default: o(() => [...x[2] || (x[2] = [
112
+ p("Status", -1)
113
+ ])]),
114
+ _: 1
115
+ }),
116
+ t(a, null, {
117
+ default: o(() => [...x[3] || (x[3] = [
118
+ p(" Variants", -1)
119
+ ])]),
120
+ _: 1
121
+ }),
122
+ t(a, null, {
123
+ default: o(() => [...x[4] || (x[4] = [
124
+ p("Price", -1)
125
+ ])]),
126
+ _: 1
127
+ })
128
+ ]),
129
+ _: 1
130
+ })
131
+ ]),
132
+ _: 1
133
+ }),
134
+ t(h, null, {
135
+ default: o(() => [
136
+ (r(!0), _(E, null, Y(U.products, (g) => (r(), P(l, {
137
+ key: g.id,
138
+ onClick: (z) => d(A)(g.id),
139
+ class: "cursor-pointer"
140
+ }, {
141
+ default: o(() => [
142
+ d(s)?.length > 0 ? (r(), P(k, { key: 0 }, {
143
+ default: o(() => [
144
+ t(w, {
145
+ "model-value": d(s)?.includes(g.id),
146
+ "onUpdate:modelValue": (z) => f(z, g.id),
147
+ onClick: x[0] || (x[0] = se(() => {
148
+ }, ["prevent", "stop"]))
149
+ }, null, 8, ["model-value", "onUpdate:modelValue"])
150
+ ]),
151
+ _: 2
152
+ }, 1024)) : T("", !0),
153
+ t(k, { class: "font-medium" }, {
154
+ default: o(() => [
155
+ u("div", Ge, [
156
+ t(C, { class: "size-12 rounded-xl" }, {
157
+ default: o(() => [
158
+ t(b, {
159
+ src: g.media?.[0],
160
+ class: "object-cover"
161
+ }, null, 8, ["src"]),
162
+ t(e, { class: "rounded-xl" })
163
+ ]),
164
+ _: 2
165
+ }, 1024),
166
+ u("span", null, $(g.title), 1)
167
+ ])
168
+ ]),
169
+ _: 2
170
+ }, 1024),
171
+ t(k, null, {
172
+ default: o(() => [
173
+ g.status === "published" ? (r(), _("span", Oe, "Published")) : g.status === "draft" ? (r(), _("span", He, "Draft")) : g.status === "archived" ? (r(), _("span", qe, "Archived")) : T("", !0)
174
+ ]),
175
+ _: 2
176
+ }, 1024),
177
+ t(k, null, {
178
+ default: o(() => [
179
+ p($(g.variantsTotal), 1)
180
+ ]),
181
+ _: 2
182
+ }, 1024),
183
+ t(k, { class: "text-right" }, {
184
+ default: o(() => [
185
+ p(" € " + $(g.price || 0), 1)
186
+ ]),
187
+ _: 2
188
+ }, 1024)
189
+ ]),
190
+ _: 2
191
+ }, 1032, ["onClick"]))), 128))
192
+ ]),
193
+ _: 1
194
+ })
195
+ ]),
196
+ _: 1
197
+ })
198
+ ]),
199
+ _: 1
200
+ });
201
+ };
202
+ }
203
+ }), We = { class: "truncate" }, Xe = { key: 0 }, Je = { key: 1 }, Ye = { key: 2 }, Ze = { key: 3 }, et = { class: "relative w-full max-w-sm items-center" }, tt = { class: "truncate" }, lt = { class: "flex items-center space-x-2 mb-4" }, ot = { class: "flex items-center space-x-2 mb-4" }, nt = { class: "flex items-center space-x-2 mb-4" }, st = /* @__PURE__ */ W({
204
+ __name: "FilterPopover",
205
+ setup(U) {
206
+ const s = N("filter"), A = N("collections"), S = O(() => (d(A) || []).flatMap((a) => {
207
+ const l = a.status || "draft", m = [
208
+ {
209
+ id: a.id,
210
+ title: a.title,
211
+ status: l,
212
+ isSubcollection: !1
213
+ }
214
+ ];
215
+ return Array.isArray(a.subcollections) && m.push(...a.subcollections.map((w) => ({
216
+ id: w.id,
217
+ title: w.title,
218
+ status: l === "published" && w.status || l,
219
+ isSubcollection: !0,
220
+ parentTitle: a.title
221
+ }))), m;
222
+ })), f = O(() => Array.isArray(s.value.collections) ? s.value.collections.map((a) => S.value.find((l) => l.id === a)).filter(Boolean) : []), y = (a) => a.isSubcollection ? `${a.parentTitle} / ${a.title}` : a.title, x = () => {
223
+ s.value = {
224
+ collections: [],
225
+ published: !0,
226
+ draft: !0,
227
+ archived: !1
228
+ };
229
+ };
230
+ return (a, l) => {
231
+ const m = n("Button"), w = n("PopoverTrigger"), k = n("ComboboxTrigger"), b = n("ComboboxAnchor"), e = n("ComboboxInput"), C = n("ComboboxEmpty"), h = n("ComboboxItemIndicator"), M = n("ComboboxItem"), V = n("ScrollArea"), g = n("ComboboxGroup"), z = n("ComboboxList"), I = n("Combobox"), F = n("Checkbox"), R = n("PopoverContent"), H = n("Popover");
232
+ return r(), P(H, null, {
233
+ default: o(() => [
234
+ t(w, { asChild: "" }, {
235
+ default: o(() => [
236
+ t(m, { variant: "outline" }, {
237
+ default: o(() => [
238
+ t(d(we), { class: "size-4" }),
239
+ l[4] || (l[4] = p(" Filter ", -1))
240
+ ]),
241
+ _: 1
242
+ })
243
+ ]),
244
+ _: 1
245
+ }),
246
+ t(R, { class: "w-64" }, {
247
+ default: o(() => [
248
+ l[10] || (l[10] = u("p", { class: "text-sm font-medium text-muted-foreground mb-4" }, " Filter by Collection ", -1)),
249
+ t(I, {
250
+ modelValue: d(s).collections,
251
+ "onUpdate:modelValue": l[0] || (l[0] = (v) => d(s).collections = v),
252
+ by: "id",
253
+ multiple: !0,
254
+ class: "mb-6"
255
+ }, {
256
+ default: o(() => [
257
+ t(b, { "as-child": "" }, {
258
+ default: o(() => [
259
+ t(k, { "as-child": "" }, {
260
+ default: o(() => [
261
+ t(m, {
262
+ variant: "outline",
263
+ class: "justify-between w-full"
264
+ }, {
265
+ default: o(() => [
266
+ u("span", We, [
267
+ f.value.length === 1 ? (r(), _("span", Xe, $(y(f.value[0])), 1)) : f.value.length === 2 ? (r(), _("span", Je, $(y(f.value[0])) + ", " + $(y(f.value[1])), 1)) : f.value.length > 2 ? (r(), _("span", Ye, $(y(f.value[0])) + ", " + $(y(f.value[1])) + " + " + $(f.value.length - 2), 1)) : (r(), _("span", Ze, "Select collection"))
268
+ ]),
269
+ t(d(ke), { class: "ml-2 size-4 shrink-0 opacity-50" })
270
+ ]),
271
+ _: 1
272
+ })
273
+ ]),
274
+ _: 1
275
+ })
276
+ ]),
277
+ _: 1
278
+ }),
279
+ t(z, null, {
280
+ default: o(() => [
281
+ u("div", et, [
282
+ t(e, { placeholder: "Select collection..." })
283
+ ]),
284
+ t(C, null, {
285
+ default: o(() => [...l[5] || (l[5] = [
286
+ p(" No collection found. ", -1)
287
+ ])]),
288
+ _: 1
289
+ }),
290
+ t(g, null, {
291
+ default: o(() => [
292
+ t(V, { class: "max-h-[200px] overflow-y-auto" }, {
293
+ default: o(() => [
294
+ (r(!0), _(E, null, Y(S.value, (v) => (r(), P(M, {
295
+ key: v.id,
296
+ value: v.id
297
+ }, {
298
+ default: o(() => [
299
+ u("div", {
300
+ class: J(["flex min-w-0 items-center gap-2", { "pl-4": v.isSubcollection }])
301
+ }, [
302
+ v.isSubcollection ? (r(), P(d(he), {
303
+ key: 0,
304
+ class: "size-4 shrink-0 text-muted-foreground"
305
+ })) : T("", !0),
306
+ u("div", {
307
+ class: J(["size-2 rounded-full shrink-0", v.status === "published" ? "bg-green-500" : "bg-blue-500"])
308
+ }, null, 2),
309
+ u("span", tt, $(v.title), 1)
310
+ ], 2),
311
+ t(h, null, {
312
+ default: o(() => [
313
+ t(d(Pe), {
314
+ class: J(d(Ee)("ml-auto size-4"))
315
+ }, null, 8, ["class"])
316
+ ]),
317
+ _: 1
318
+ })
319
+ ]),
320
+ _: 2
321
+ }, 1032, ["value"]))), 128))
322
+ ]),
323
+ _: 1
324
+ })
325
+ ]),
326
+ _: 1
327
+ })
328
+ ]),
329
+ _: 1
330
+ })
331
+ ]),
332
+ _: 1
333
+ }, 8, ["modelValue"]),
334
+ l[11] || (l[11] = u("p", { class: "text-sm font-medium text-muted-foreground mb-4" }, " Filter by Status ", -1)),
335
+ u("div", lt, [
336
+ t(F, {
337
+ id: "chk_published_products",
338
+ modelValue: d(s).published,
339
+ "onUpdate:modelValue": l[1] || (l[1] = (v) => d(s).published = v)
340
+ }, null, 8, ["modelValue"]),
341
+ l[6] || (l[6] = u("label", {
342
+ for: "chk_published_products",
343
+ class: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
344
+ }, " Show published products ", -1))
345
+ ]),
346
+ u("div", ot, [
347
+ t(F, {
348
+ id: "chk_draft_products",
349
+ modelValue: d(s).draft,
350
+ "onUpdate:modelValue": l[2] || (l[2] = (v) => d(s).draft = v)
351
+ }, null, 8, ["modelValue"]),
352
+ l[7] || (l[7] = u("label", {
353
+ for: "chk_draft_products",
354
+ class: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
355
+ }, " Show draft products ", -1))
356
+ ]),
357
+ u("div", nt, [
358
+ t(F, {
359
+ id: "chk_archived_products",
360
+ modelValue: d(s).archived,
361
+ "onUpdate:modelValue": l[3] || (l[3] = (v) => d(s).archived = v)
362
+ }, null, 8, ["modelValue"]),
363
+ l[8] || (l[8] = u("label", {
364
+ for: "chk_archived_products",
365
+ class: "text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
366
+ }, " Show archived products ", -1))
367
+ ]),
368
+ d(s).collections.length > 0 || !d(s).published || !d(s).draft || d(s).archived ? (r(), P(m, {
369
+ key: 0,
370
+ variant: "secondary",
371
+ class: "ml-auto my-2",
372
+ size: "sm",
373
+ onClick: x
374
+ }, {
375
+ default: o(() => [
376
+ t(d(Se), { class: "size-3" }),
377
+ l[9] || (l[9] = u("span", { class: "ml-0.5 text-xs" }, "Reset filters", -1))
378
+ ]),
379
+ _: 1
380
+ })) : T("", !0)
381
+ ]),
382
+ _: 1
383
+ })
384
+ ]),
385
+ _: 1
386
+ });
387
+ };
388
+ }
389
+ }), at = /* @__PURE__ */ W({
390
+ __name: "ProductContextMenu",
391
+ emits: ["selectAll", "duplicateProduct", "deleteProduct", "deleteSelection"],
392
+ setup(U, { emit: s }) {
393
+ const A = s, S = N("products"), f = N("selection"), y = N("config"), { hasPermission: x } = ee(), { navigateTo: a } = Z(), l = O(() => f.value?.length !== 1 ? null : S.value?.find((b) => b.id === f.value[0])), m = (b) => {
394
+ let e = y.previewUrl;
395
+ e = e.replace("{{ id", "{{id"), e = e.replace("id }}", "id}}"), e = e.replace("{{id}}", b.id), e = e.replace("{{ slug", "{{slug"), e = e.replace("slug }}", "slug}}"), e = e.replace("{{slug}}", b.slug), window.open(e, "_blank");
396
+ }, w = async (b, e) => {
397
+ try {
398
+ if (!["draft", "published", "archived"].includes(e)) return;
399
+ await te(y.project).update(y.productCollection, b.id, { status: e }), b.status = e, L.success("Product status changed");
400
+ } catch {
401
+ L.error("Failed to change product status");
402
+ }
403
+ }, k = async (b) => {
404
+ try {
405
+ if (!["draft", "published", "archived"].includes(b)) return;
406
+ const e = te(y.project), C = [];
407
+ f.value.forEach(async (h) => {
408
+ C.push(e.update(y.productCollection, h, { status: b }));
409
+ }), L.promise(Promise.all(C), {
410
+ loading: `Changing status of ${f.value.length} products...`,
411
+ success: () => {
412
+ const h = f.value.length;
413
+ return f.value.forEach((M) => {
414
+ S.value.find((V) => V.id == M).status = b;
415
+ }), f.value = [], `Product status changed for ${h} products`;
416
+ },
417
+ error: (h) => "Failed to change product status"
418
+ });
419
+ } catch {
420
+ L.error("Failed to change product status");
421
+ }
422
+ };
423
+ return (b, e) => {
424
+ const C = n("ContextMenuTrigger"), h = n("ContextMenuShortcut"), M = n("ContextMenuItem"), V = n("ContextMenuContent"), g = n("ContextMenuSeparator"), z = n("ContextMenuSubTrigger"), I = n("ContextMenuCheckboxItem"), F = n("ContextMenuSubContent"), R = n("ContextMenuSub"), H = n("ContextMenu");
425
+ return r(), P(H, null, {
426
+ default: o(() => [
427
+ t(C, { class: "flex flex-1" }, {
428
+ default: o(() => [
429
+ ve(b.$slots, "default")
430
+ ]),
431
+ _: 3
432
+ }),
433
+ d(f).length === 0 ? (r(), P(V, {
434
+ key: 0,
435
+ class: "w-64"
436
+ }, {
437
+ default: o(() => [
438
+ t(M, {
439
+ inset: "",
440
+ onClick: e[0] || (e[0] = (v) => A("selectAll"))
441
+ }, {
442
+ default: o(() => [
443
+ e[13] || (e[13] = p(" Select all ", -1)),
444
+ t(h, null, {
445
+ default: o(() => [...e[12] || (e[12] = [
446
+ p("⌘ + A", -1)
447
+ ])]),
448
+ _: 1
449
+ })
450
+ ]),
451
+ _: 1
452
+ })
453
+ ]),
454
+ _: 1
455
+ })) : T("", !0),
456
+ d(f).length === 1 && l.value ? (r(), P(V, {
457
+ key: 1,
458
+ class: "w-64"
459
+ }, {
460
+ default: o(() => [
461
+ t(M, {
462
+ inset: "",
463
+ onClick: e[1] || (e[1] = (v) => d(a)(l.value.id))
464
+ }, {
465
+ default: o(() => [...e[14] || (e[14] = [
466
+ p(" Edit product ", -1)
467
+ ])]),
468
+ _: 1
469
+ }),
470
+ t(g),
471
+ d(y).previewUrl ? (r(), _(E, { key: 0 }, [
472
+ t(M, {
473
+ inset: "",
474
+ onClick: e[2] || (e[2] = (v) => m(l.value))
475
+ }, {
476
+ default: o(() => [
477
+ e[15] || (e[15] = p(" Preview product ", -1)),
478
+ t(h, null, {
479
+ default: o(() => [
480
+ t(d($e), { class: "size-4" })
481
+ ]),
482
+ _: 1
483
+ })
484
+ ]),
485
+ _: 1
486
+ }),
487
+ t(g)
488
+ ], 64)) : T("", !0),
489
+ t(M, {
490
+ inset: "",
491
+ onClick: e[3] || (e[3] = (v) => A("duplicateProduct", l.value))
492
+ }, {
493
+ default: o(() => [...e[16] || (e[16] = [
494
+ p(" Duplicate product ", -1)
495
+ ])]),
496
+ _: 1
497
+ }),
498
+ t(R, null, {
499
+ default: o(() => [
500
+ t(z, { inset: "" }, {
501
+ default: o(() => [...e[17] || (e[17] = [
502
+ p(" Change status ", -1)
503
+ ])]),
504
+ _: 1
505
+ }),
506
+ t(F, { class: "w-48" }, {
507
+ default: o(() => [
508
+ t(I, {
509
+ onClick: e[4] || (e[4] = (v) => w(l.value, "draft")),
510
+ modelValue: l.value.status === "draft"
511
+ }, {
512
+ default: o(() => [...e[18] || (e[18] = [
513
+ u("span", { class: "size-2 rounded-full bg-blue-500" }, null, -1),
514
+ p(" Draft ", -1)
515
+ ])]),
516
+ _: 1
517
+ }, 8, ["modelValue"]),
518
+ t(I, {
519
+ onClick: e[5] || (e[5] = (v) => w(l.value, "published")),
520
+ modelValue: l.value.status === "published"
521
+ }, {
522
+ default: o(() => [...e[19] || (e[19] = [
523
+ u("span", { class: "size-2 rounded-full bg-green-500" }, null, -1),
524
+ p(" Published ", -1)
525
+ ])]),
526
+ _: 1
527
+ }, 8, ["modelValue"]),
528
+ t(I, {
529
+ onClick: e[6] || (e[6] = (v) => w(l.value, "archived")),
530
+ modelValue: l.value.status === "archived"
531
+ }, {
532
+ default: o(() => [...e[20] || (e[20] = [
533
+ u("span", { class: "size-2 rounded-full bg-gray-300" }, null, -1),
534
+ p(" Archived ", -1)
535
+ ])]),
536
+ _: 1
537
+ }, 8, ["modelValue"])
538
+ ]),
539
+ _: 1
540
+ })
541
+ ]),
542
+ _: 1
543
+ }),
544
+ t(M, {
545
+ inset: "",
546
+ variant: "destructive",
547
+ onClick: e[7] || (e[7] = (v) => A("deleteProduct", l.value))
548
+ }, {
549
+ default: o(() => [...e[21] || (e[21] = [
550
+ p(" Delete product ", -1)
551
+ ])]),
552
+ _: 1
553
+ })
554
+ ]),
555
+ _: 1
556
+ })) : T("", !0),
557
+ d(f).length > 1 ? (r(), P(V, {
558
+ key: 2,
559
+ class: "w-64"
560
+ }, {
561
+ default: o(() => [
562
+ t(R, null, {
563
+ default: o(() => [
564
+ t(z, { inset: "" }, {
565
+ default: o(() => [
566
+ p(" Change status (" + $(d(f).length) + ") ", 1)
567
+ ]),
568
+ _: 1
569
+ }),
570
+ t(F, { class: "w-48" }, {
571
+ default: o(() => [
572
+ t(I, {
573
+ onClick: e[8] || (e[8] = (v) => k("draft"))
574
+ }, {
575
+ default: o(() => [...e[22] || (e[22] = [
576
+ u("span", { class: "size-2 rounded-full bg-blue-500" }, null, -1),
577
+ p(" Draft ", -1)
578
+ ])]),
579
+ _: 1
580
+ }),
581
+ t(I, {
582
+ onClick: e[9] || (e[9] = (v) => k("published"))
583
+ }, {
584
+ default: o(() => [...e[23] || (e[23] = [
585
+ u("span", { class: "size-2 rounded-full bg-green-500" }, null, -1),
586
+ p(" Published ", -1)
587
+ ])]),
588
+ _: 1
589
+ }),
590
+ t(I, {
591
+ onClick: e[10] || (e[10] = (v) => k("archived"))
592
+ }, {
593
+ default: o(() => [...e[24] || (e[24] = [
594
+ u("span", { class: "size-2 rounded-full bg-gray-300" }, null, -1),
595
+ p(" Archived ", -1)
596
+ ])]),
597
+ _: 1
598
+ })
599
+ ]),
600
+ _: 1
601
+ })
602
+ ]),
603
+ _: 1
604
+ }),
605
+ t(M, {
606
+ inset: "",
607
+ variant: "destructive",
608
+ onClick: e[11] || (e[11] = (v) => A("deleteSelection"))
609
+ }, {
610
+ default: o(() => [
611
+ p(" Delete products (" + $(d(f).length) + ") ", 1)
612
+ ]),
613
+ _: 1
614
+ })
615
+ ]),
616
+ _: 1
617
+ })) : T("", !0)
618
+ ]),
619
+ _: 3
620
+ });
621
+ };
622
+ }
623
+ }), ut = { class: "relative flex flex-col flex-1" }, it = {
624
+ ref: "container",
625
+ class: "flex items-center justify-between gap-4 w-full mt-12 mb-8"
626
+ }, rt = { class: "flex items-center gap-4" }, dt = { class: "text-lg whitespace-nowrap" }, ct = { class: "relative w-full max-w-sm items-center" }, pt = { class: "absolute start-0 inset-y-0 flex items-center justify-center px-2" }, ft = { class: "flex items-center gap-4" }, mt = { class: "flex flex-1" }, yt = /* @__PURE__ */ W({
627
+ __name: "Overview",
628
+ props: {
629
+ config: {
630
+ type: Object,
631
+ required: !0
632
+ }
633
+ },
634
+ async setup(U) {
635
+ let s, A;
636
+ const S = U, { hasPermission: f } = ee(), { navigateTo: y } = Z(), { confirm: x } = ze();
637
+ Ie(() => []);
638
+ const a = te(S.config.project), l = K([]), m = async () => {
639
+ const c = await a.find(S.config.productCollection);
640
+ l.value = c || [];
641
+ }, w = ge("container"), { width: k } = Le(w), b = K("grid"), e = K(1), C = K([]), h = K(""), M = K([]);
642
+ M.value = ([s, A] = be(() => I()), s = await s, A(), s);
643
+ const V = O(() => b.value === "grid" ? k.value < 768 ? 6 : k.value < 896 ? 8 : k.value < 1024 ? 10 : 12 : 10), g = O(() => l.value.filter((c) => !(j.value.collections.length > 0 && !c.collections?.some((i) => j.value.collections.includes(i)) || !j.value.published && c.status === "published" || !j.value.draft && c.status === "draft" || !j.value.archived && c.status === "archived")).filter((c) => c.title.toLowerCase().includes(h.value.toLowerCase()) || c.slug.toLowerCase().includes(h.value.toLowerCase()) || c.id.toLowerCase().includes(h.value.toLowerCase()))), z = O(() => {
644
+ if (g.value.length <= V.value)
645
+ return g.value;
646
+ const c = (e.value - 1) * V.value, i = c + V.value;
647
+ return g.value.slice(c, i);
648
+ });
649
+ async function I() {
650
+ if (!S.config.collectionsCollection) return [];
651
+ const c = S.config.collectionsCollection.split(":");
652
+ return c.length !== 2 ? [] : (await a.get(c[0]))?.[c[1]] || [];
653
+ }
654
+ async function F(c) {
655
+ return (await a.find(S.config.productCollection, {
656
+ filters: [
657
+ {
658
+ field: "slug",
659
+ operator: "==",
660
+ value: c
661
+ }
662
+ ]
663
+ })).length > 0;
664
+ }
665
+ const R = () => {
666
+ C.value = z.value.map((c) => c.id);
667
+ }, H = async (c) => {
668
+ try {
669
+ let i = { ...c }, B = i.slug + "-copy", G = 2;
670
+ for (; await F(B); )
671
+ B = i.slug + "-copy-" + G, G++;
672
+ i.id = void 0, i.createdAt = /* @__PURE__ */ new Date(), i.updatedAt = /* @__PURE__ */ new Date(), i.slug = B, i.status = "draft", i.title = i.title + " (copy)";
673
+ const X = await a.add(S.config.productCollection, i);
674
+ y(X.id), L.success("Product duplicated");
675
+ } catch {
676
+ L.error("Failed to duplicate product");
677
+ }
678
+ }, v = async (c) => {
679
+ if (await x(`Are you sure you want to delete "${c.title}"?`))
680
+ try {
681
+ await a.remove(S.config.productCollection, c.id), l.value = l.value.filter((B) => B.id !== c.id), C.value = [], L.success("Product deleted");
682
+ } catch {
683
+ L.error("Failed to delete product");
684
+ }
685
+ }, le = async () => {
686
+ if (await x(`Are you sure you want to delete all selected products (${C.value.length})?`))
687
+ try {
688
+ C.value.forEach(async (i) => {
689
+ await a.remove(S.config.productCollection, i);
690
+ }), l.value = l.value.filter((i) => !C.value.includes(i.id)), C.value = [], L.success("Products deleted");
691
+ } catch {
692
+ L.error("Failed to delete products");
693
+ }
694
+ }, j = K({
695
+ collections: [],
696
+ published: !0,
697
+ draft: !0,
698
+ archived: !1
699
+ });
700
+ _e(j, () => {
701
+ e.value = 1;
702
+ });
703
+ const oe = (c) => {
704
+ c.target?.matches("input, textarea") || c.target?.isContentEditable || (c.key === "Escape" && (C.value = []), (c.metaKey || c.ctrlKey) && c.key.toLowerCase() === "a" && (c.preventDefault(), R()));
705
+ };
706
+ return xe(() => {
707
+ m(), window.addEventListener("keydown", oe);
708
+ }), Ce(() => {
709
+ window.removeEventListener("keydown", oe);
710
+ }), Q("config", S.config), Q("filter", j), Q("products", l), Q("collections", M), Q("selection", C), (c, i) => {
711
+ const B = n("Input"), G = n("Button"), X = n("SegmentedControlButton"), ae = n("SegmentedControl"), ue = n("PaginationFirst"), ie = n("PaginationPrev"), re = n("PaginationListItem"), de = n("PaginationEllipsis"), ce = n("PaginationNext"), pe = n("PaginationLast"), fe = n("PaginationList"), me = n("Pagination");
712
+ return r(), _("div", ut, [
713
+ u("div", it, [
714
+ u("div", rt, [
715
+ u("p", dt, $(g.value?.length) + " products", 1),
716
+ u("div", ct, [
717
+ t(B, {
718
+ id: "search",
719
+ type: "text",
720
+ placeholder: "Search...",
721
+ class: "pl-8",
722
+ onKeydown: i[0] || (i[0] = ye((D) => h.value = "", ["escape"])),
723
+ modelValue: h.value,
724
+ "onUpdate:modelValue": i[1] || (i[1] = (D) => h.value = D)
725
+ }, null, 8, ["modelValue"]),
726
+ u("span", pt, [
727
+ t(d(Me), { class: "size-4 text-muted-foreground" })
728
+ ])
729
+ ])
730
+ ]),
731
+ u("div", ft, [
732
+ C.value.length > 0 ? (r(), P(G, {
733
+ key: 0,
734
+ variant: "destructive",
735
+ onClick: le
736
+ }, {
737
+ default: o(() => [
738
+ p(" Delete Selection (" + $(C.value.length) + ") ", 1)
739
+ ]),
740
+ _: 1
741
+ })) : T("", !0),
742
+ d(f)("create-product") ? (r(), _(E, { key: 1 }, [
743
+ t(G, {
744
+ variant: "outline",
745
+ onClick: i[2] || (i[2] = (D) => d(y)("new"))
746
+ }, {
747
+ default: o(() => [
748
+ t(d(Ve), { class: "size-4" }),
749
+ i[5] || (i[5] = p(" New Product ", -1))
750
+ ]),
751
+ _: 1
752
+ }),
753
+ i[6] || (i[6] = u("div", { class: "w-[1px] h-8 bg-border" }, null, -1))
754
+ ], 64)) : T("", !0),
755
+ t(st),
756
+ i[7] || (i[7] = u("div", { class: "w-[1px] h-8 bg-border" }, null, -1)),
757
+ u("div", null, [
758
+ t(ae, {
759
+ modelValue: b.value,
760
+ "onUpdate:modelValue": i[3] || (i[3] = (D) => b.value = D),
761
+ "aria-label": "View mode"
762
+ }, {
763
+ default: o(() => [
764
+ t(X, { value: "grid" }, {
765
+ default: o(() => [
766
+ t(d(Te), { class: "size-4" })
767
+ ]),
768
+ _: 1
769
+ }),
770
+ t(X, { value: "list" }, {
771
+ default: o(() => [
772
+ t(d(Ae), { class: "size-4" })
773
+ ]),
774
+ _: 1
775
+ })
776
+ ]),
777
+ _: 1
778
+ }, 8, ["modelValue"])
779
+ ])
780
+ ])
781
+ ], 512),
782
+ u("div", mt, [
783
+ t(at, {
784
+ onSelectAll: R,
785
+ onDuplicateProduct: H,
786
+ onDeleteProduct: v,
787
+ onDeleteSelection: le
788
+ }, {
789
+ default: o(() => [
790
+ b.value === "grid" ? (r(), P(Ne, {
791
+ key: 0,
792
+ products: z.value
793
+ }, null, 8, ["products"])) : (r(), P(Qe, {
794
+ key: 1,
795
+ products: z.value
796
+ }, null, 8, ["products"]))
797
+ ]),
798
+ _: 1
799
+ })
800
+ ]),
801
+ g.value?.length > V.value ? (r(), P(me, {
802
+ key: 0,
803
+ page: e.value,
804
+ "onUpdate:page": i[4] || (i[4] = (D) => e.value = D),
805
+ "items-per-page": V.value,
806
+ total: g.value?.length,
807
+ "sibling-count": 1,
808
+ "show-edges": ""
809
+ }, {
810
+ default: o(() => [
811
+ t(fe, { class: "flex items-center gap-1" }, {
812
+ default: o(({ items: D }) => [
813
+ t(ue),
814
+ t(ie),
815
+ (r(!0), _(E, null, Y(D, (q, ne) => (r(), _(E, null, [
816
+ q.type === "page" ? (r(), P(re, {
817
+ key: ne,
818
+ value: q.value,
819
+ "as-child": ""
820
+ }, {
821
+ default: o(() => [
822
+ t(G, {
823
+ class: "size-10 p-0",
824
+ variant: q.value === e.value ? "default" : "outline"
825
+ }, {
826
+ default: o(() => [
827
+ p($(q.value), 1)
828
+ ]),
829
+ _: 2
830
+ }, 1032, ["variant"])
831
+ ]),
832
+ _: 2
833
+ }, 1032, ["value"])) : (r(), P(de, {
834
+ key: q.type,
835
+ index: ne
836
+ }, null, 8, ["index"]))
837
+ ], 64))), 256)),
838
+ t(ce),
839
+ t(pe)
840
+ ]),
841
+ _: 1
842
+ })
843
+ ]),
844
+ _: 1
845
+ }, 8, ["page", "items-per-page", "total"])) : T("", !0)
846
+ ]);
847
+ };
848
+ }
849
+ });
850
+ export {
851
+ yt as default
852
+ };