@feedmepos/mf-report 5.3.15-rc.9 → 5.4.0-beta.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.
@@ -0,0 +1,524 @@
1
+ import { defineComponent as h, mergeModels as w, useModel as R, ref as D, computed as N, resolveComponent as m, openBlock as r, createBlock as y, withCtx as u, createTextVNode as pe, createVNode as t, normalizeClass as U, unref as l, createElementVNode as _, createElementBlock as F, Fragment as B, renderSlot as A, createCommentVNode as O, watch as ce, resolveDynamicComponent as G, isRef as Y, toDisplayString as L, renderList as z, onMounted as fe, normalizeStyle as ve } from "vue";
2
+ import { W as ge, i as _e, S as ye, D as Ce, T as be, _ as Ve } from "./TransitionFade-ryomNLIZ.js";
3
+ import { u as j, b as K, v as Q, c as ke } from "./app-eKZV2PPB.js";
4
+ import { _ as Fe } from "./HeaderTab.vue_vue_type_script_setup_true_lang-pwHzeuLE.js";
5
+ import { storeToRefs as X } from "pinia";
6
+ import { useRouter as Z, useRoute as ee } from "vue-router";
7
+ import { useBreakpoints as I, FmButtonColorThemeVariant as q, useSnackbar as xe } from "@feedmepos/ui-library";
8
+ import { _ as oe } from "./DynamicWidget.vue_vue_type_script_setup_true_lang-WNX1hHIm.js";
9
+ import { _ as te } from "./NoData.vue_vue_type_script_setup_true_lang-FeKqFs4A.js";
10
+ const we = /* @__PURE__ */ h({
11
+ __name: "WidgetDialog",
12
+ props: /* @__PURE__ */ w({
13
+ isOpen: { type: Boolean }
14
+ }, {
15
+ modelValue: {},
16
+ modelModifiers: {}
17
+ }),
18
+ emits: /* @__PURE__ */ w(["isOpen"], ["update:modelValue"]),
19
+ setup(c, { emit: n }) {
20
+ const { breakpoints: o } = I(), a = R(c, "modelValue"), s = c, C = n;
21
+ function e() {
22
+ C("isOpen", !1);
23
+ }
24
+ function f() {
25
+ v.value && (a.value = v.value, v.value = void 0, C("isOpen", !1));
26
+ }
27
+ const v = D(), i = N(() => !v.value);
28
+ return (k, b) => {
29
+ const $ = m("FmButton"), M = m("FmDialog");
30
+ return r(), y(M, {
31
+ "model-value": s.isOpen
32
+ }, {
33
+ "dialog-header": u(() => b[1] || (b[1] = [
34
+ pe("Widget Type")
35
+ ])),
36
+ default: u(() => [
37
+ t(ge, {
38
+ modelValue: v.value,
39
+ "onUpdate:modelValue": b[0] || (b[0] = (S) => v.value = S),
40
+ class: U(`grid ${l(o).lg || l(o).md ? "grid-cols-3 gap-3" : "grid-cols-2 gap-3"}`),
41
+ "child-class": "p-[8px] flex flex-col"
42
+ }, null, 8, ["modelValue", "class"])
43
+ ]),
44
+ "dialog-footer": u(() => [
45
+ b[2] || (b[2] = _("div", { class: "grow" }, null, -1)),
46
+ t($, {
47
+ label: "Cancel",
48
+ variant: "tertiary",
49
+ onClick: e
50
+ }),
51
+ t($, {
52
+ label: "Confirm",
53
+ disabled: i.value,
54
+ onClick: f
55
+ }, null, 8, ["disabled"])
56
+ ]),
57
+ _: 1
58
+ }, 8, ["model-value"]);
59
+ };
60
+ }
61
+ }), P = /* @__PURE__ */ h({
62
+ __name: "ReportEditorTabHeader",
63
+ props: /* @__PURE__ */ w({
64
+ icon: {
65
+ type: String,
66
+ required: !0
67
+ }
68
+ }, {
69
+ modelValue: { type: Boolean, required: !0, default: !1 },
70
+ modelModifiers: {}
71
+ }),
72
+ emits: ["update:modelValue"],
73
+ setup(c) {
74
+ const n = R(c, "modelValue"), o = c;
75
+ return (a, s) => {
76
+ const C = m("FmIcon");
77
+ return r(), F("div", {
78
+ class: "px-6 py-16 flex items-center gap-2 bg-fm-color-neutral-white border cursor-pointer",
79
+ onClick: s[0] || (s[0] = (e) => n.value = !n.value)
80
+ }, [
81
+ s[1] || (s[1] = _("p", { class: "fm-typo-en-body-lg-600" }, "Customize report", -1)),
82
+ s[2] || (s[2] = _("div", { class: "grow" }, null, -1)),
83
+ t(C, {
84
+ name: o.icon
85
+ }, null, 8, ["name"])
86
+ ]);
87
+ };
88
+ }
89
+ }), $e = /* @__PURE__ */ h({
90
+ __name: "ReportEditorTabDesktop",
91
+ props: {
92
+ modelValue: { required: !0, default: !1 },
93
+ modelModifiers: {}
94
+ },
95
+ emits: ["update:modelValue"],
96
+ setup(c) {
97
+ const n = R(c, "modelValue");
98
+ return (o, a) => (r(), F(B, null, [
99
+ t(P, {
100
+ modelValue: n.value,
101
+ "onUpdate:modelValue": a[0] || (a[0] = (s) => n.value = s),
102
+ icon: "keyboard_double_arrow_left"
103
+ }, null, 8, ["modelValue"]),
104
+ A(o.$slots, "default")
105
+ ], 64));
106
+ }
107
+ }), he = /* @__PURE__ */ h({
108
+ __name: "ReportEditorTabMobile",
109
+ props: {
110
+ modelValue: { required: !0, default: !1 },
111
+ modelModifiers: {}
112
+ },
113
+ emits: ["update:modelValue"],
114
+ setup(c) {
115
+ const n = R(c, "modelValue");
116
+ return (o, a) => {
117
+ const s = m("FmTopSheet"), C = m("FmCard");
118
+ return r(), y(C, { class: "fixed bottom-0 w-full" }, {
119
+ default: u(() => [
120
+ t(P, {
121
+ modelValue: n.value,
122
+ "onUpdate:modelValue": a[0] || (a[0] = (e) => n.value = e),
123
+ icon: "keyboard_double_arrow_up"
124
+ }, null, 8, ["modelValue"]),
125
+ t(s, {
126
+ modelValue: n.value,
127
+ "onUpdate:modelValue": a[2] || (a[2] = (e) => n.value = e),
128
+ "fullscreen-size": "sm"
129
+ }, {
130
+ default: u(() => [
131
+ t(P, {
132
+ modelValue: n.value,
133
+ "onUpdate:modelValue": a[1] || (a[1] = (e) => n.value = e),
134
+ icon: "keyboard_double_arrow_down"
135
+ }, null, 8, ["modelValue"]),
136
+ n.value ? A(o.$slots, "default", { key: 0 }) : O("", !0)
137
+ ]),
138
+ _: 3
139
+ }, 8, ["modelValue"])
140
+ ]),
141
+ _: 3
142
+ });
143
+ };
144
+ }
145
+ }), Se = { class: "flex flex-col gap-24 top-0 bg-fm-color-neutral-white z-10" }, Re = { class: "flex flex-col gap-24" }, Te = { class: "line-clamp-2 overflow-hidden" }, le = /* @__PURE__ */ h({
146
+ __name: "ReportEditorTab",
147
+ props: /* @__PURE__ */ w({
148
+ hideConfiguration: {
149
+ type: Boolean,
150
+ default: !1
151
+ }
152
+ }, {
153
+ modelValue: { required: !0 },
154
+ modelModifiers: {}
155
+ }),
156
+ emits: /* @__PURE__ */ w(["hideConfiguration"], ["update:modelValue"]),
157
+ setup(c, { emit: n }) {
158
+ const o = R(c, "modelValue"), { breakpoints: a } = I(), s = c, C = n, e = Z(), f = ee(), v = D(), { currentSelectWidgetType: i, categories: k, editingTile: b, editingIndex: $ } = X(j()), { promptMessage: M } = K(), S = D(!1);
159
+ ce(
160
+ () => i.value,
161
+ () => {
162
+ i.value !== void 0 && (o.value.tiles.push(_e(i.value)), $.value = o.value.tiles.length - 1, b.value = o.value.tiles[o.value.tiles.length - 1], e.push({
163
+ name: "tileEditor",
164
+ query: f.query
165
+ }));
166
+ },
167
+ { immediate: !0 }
168
+ );
169
+ const V = [
170
+ {
171
+ label: "Edit",
172
+ selected: !1,
173
+ variant: "tertiary",
174
+ onClick: (d) => {
175
+ $.value = d, b.value = JSON.parse(JSON.stringify(o.value.tiles[d])), e.push({
176
+ name: "tileEditor",
177
+ query: f.query
178
+ });
179
+ }
180
+ },
181
+ {
182
+ label: "Duplicate",
183
+ selected: !1,
184
+ variant: "tertiary",
185
+ onClick: (d) => {
186
+ o.value.tiles.push(JSON.parse(JSON.stringify(o.value.tiles[d])));
187
+ }
188
+ },
189
+ {
190
+ label: "Remove",
191
+ selected: !1,
192
+ variant: "destructive",
193
+ onClick: async (d) => {
194
+ await M({
195
+ title: "Delete widget",
196
+ message: `Are You sure you want to delete ${o.value.tiles[d].widget.title}?`
197
+ }) && (o.value.tiles = o.value.tiles.filter((T, E) => E !== d));
198
+ }
199
+ }
200
+ ], x = N(() => k.value.map((d) => ({ label: d.name, value: d.id })));
201
+ return (d, p) => {
202
+ const T = m("FmTextField"), E = m("FmSelect"), H = m("FmButton"), ne = m("FmIcon"), ae = m("FmTooltip"), re = m("FmMenuItem"), ie = m("FmMenu"), ue = m("FmListItem"), se = m("FmList"), de = m("FmForm");
203
+ return r(), y(G(l(a).lg || l(a).md ? $e : he), {
204
+ "model-value": s.hideConfiguration,
205
+ "onUpdate:modelValue": p[5] || (p[5] = (g) => C("hideConfiguration", g))
206
+ }, {
207
+ default: u(() => [
208
+ t(we, {
209
+ modelValue: l(i),
210
+ "onUpdate:modelValue": p[0] || (p[0] = (g) => Y(i) ? i.value = g : null),
211
+ "is-open": S.value,
212
+ onIsOpen: p[1] || (p[1] = (g) => S.value = g)
213
+ }, null, 8, ["modelValue", "is-open"]),
214
+ t(de, {
215
+ ref_key: "form",
216
+ ref: v,
217
+ class: "px-6 py-16 flex flex-col gap-24 overflow-y-auto overflow-x-hidden"
218
+ }, {
219
+ default: u(() => [
220
+ t(ye, { class: "border-solid" }, {
221
+ header: u(() => p[6] || (p[6] = [
222
+ _("p", null, "Report infomation", -1),
223
+ _("div", { class: "grow" }, null, -1)
224
+ ])),
225
+ content: u(() => [
226
+ _("div", Se, [
227
+ t(T, {
228
+ modelValue: o.value.name,
229
+ "onUpdate:modelValue": p[2] || (p[2] = (g) => o.value.name = g),
230
+ label: "Report title",
231
+ placeholder: "placeholder"
232
+ }, null, 8, ["modelValue"]),
233
+ t(E, {
234
+ modelValue: o.value.category,
235
+ "onUpdate:modelValue": p[3] || (p[3] = (g) => o.value.category = g),
236
+ label: "Category",
237
+ items: x.value
238
+ }, null, 8, ["modelValue", "items"])
239
+ ])
240
+ ]),
241
+ _: 1
242
+ }),
243
+ _("div", Re, [
244
+ t(H, {
245
+ label: "Add widget",
246
+ variant: "secondary",
247
+ icon: "add",
248
+ "icon-position": "prepend",
249
+ "border-color": l(q).ColorPrimary,
250
+ "text-color": l(q).ColorPrimary,
251
+ onClick: p[4] || (p[4] = (g) => S.value = !0)
252
+ }, null, 8, ["border-color", "text-color"]),
253
+ t(se, null, {
254
+ default: u(() => [
255
+ t(l(Ce), {
256
+ list: o.value.tiles,
257
+ "item-key": "id",
258
+ class: "flex flex-col gap-2 cursor-grab"
259
+ }, {
260
+ item: u(({ element: g, index: W }) => [
261
+ t(ue, { class: "!cursor-grab border rounded-md border-neutral-300" }, {
262
+ default: u(() => [
263
+ t(ne, { name: "drag_handle" }),
264
+ t(ae, {
265
+ content: g.widget.title.length <= 0 ? `Widget ${W}` : g.widget.title
266
+ }, {
267
+ default: u(() => [
268
+ _("p", Te, L(g.widget.title.length <= 0 ? `Widget ${W}` : g.widget.title), 1)
269
+ ]),
270
+ _: 2
271
+ }, 1032, ["content"]),
272
+ p[7] || (p[7] = _("div", { class: "grow" }, null, -1)),
273
+ t(ie, {
274
+ trigger: "click",
275
+ shift: !0,
276
+ "stop-click-propagation": !0
277
+ }, {
278
+ "menu-button": u(() => [
279
+ t(H, {
280
+ "append-icon": "more_vert",
281
+ variant: "tertiary"
282
+ })
283
+ ]),
284
+ default: u(() => [
285
+ (r(), F(B, null, z(V, (J, me) => t(re, {
286
+ key: me,
287
+ onClick: (Ee) => J.onClick(W)
288
+ }, {
289
+ label: u(() => [
290
+ _("p", {
291
+ class: U(
292
+ J.variant === "destructive" ? " text-fm-color-system-error-300" : ""
293
+ )
294
+ }, L(J.label), 3)
295
+ ]),
296
+ _: 2
297
+ }, 1032, ["onClick"])), 64))
298
+ ]),
299
+ _: 2
300
+ }, 1024)
301
+ ]),
302
+ _: 2
303
+ }, 1024)
304
+ ]),
305
+ _: 1
306
+ }, 8, ["list"])
307
+ ]),
308
+ _: 1
309
+ })
310
+ ])
311
+ ]),
312
+ _: 1
313
+ }, 512)
314
+ ]),
315
+ _: 1
316
+ }, 8, ["model-value"]);
317
+ };
318
+ }
319
+ }), Be = { class: "flex flex-col bg-fm-color-neutral-white w-[400px]" }, Me = { class: "flex bg-fm-color-neutral-white w-[88px]" }, Oe = { class: "w-full overflow-y-auto" }, qe = {
320
+ key: 0,
321
+ class: "w-full grid grid-cols-12 gap-[24px] p-24",
322
+ style: { backgroundColor: "#F6F8FC" }
323
+ }, De = /* @__PURE__ */ h({
324
+ __name: "ReportEditorDesktop",
325
+ props: /* @__PURE__ */ w({
326
+ hideConfiguration: { type: Boolean, required: !0, default: !1 }
327
+ }, {
328
+ modelValue: { required: !0, default: () => {
329
+ } },
330
+ modelModifiers: {}
331
+ }),
332
+ emits: /* @__PURE__ */ w(["hideConfiguration"], ["update:modelValue"]),
333
+ setup(c, { emit: n }) {
334
+ const o = R(c, "modelValue"), a = c, s = n;
335
+ return (C, e) => {
336
+ const f = m("FmCircularProgress"), v = m("FmButton");
337
+ return r(), F("div", null, [
338
+ o.value ? (r(), F(B, { key: 1 }, [
339
+ t(be, {
340
+ "model-value": !a.hideConfiguration
341
+ }, {
342
+ right: u(() => [
343
+ _("div", Be, [
344
+ o.value ? (r(), y(le, {
345
+ key: 0,
346
+ modelValue: o.value,
347
+ "onUpdate:modelValue": e[0] || (e[0] = (i) => o.value = i),
348
+ "hide-configuration": a.hideConfiguration,
349
+ onHideConfiguration: e[1] || (e[1] = (i) => {
350
+ s("hideConfiguration", i);
351
+ })
352
+ }, null, 8, ["modelValue", "hide-configuration"])) : O("", !0)
353
+ ])
354
+ ]),
355
+ left: u(() => [
356
+ _("div", Me, [
357
+ t(v, {
358
+ variant: "secondary",
359
+ icon: "keyboard_double_arrow_right",
360
+ "border-color": l(q).ColorPrimary,
361
+ "text-color": l(q).ColorPrimary,
362
+ class: "m-24 my-16",
363
+ size: "md",
364
+ onClick: e[2] || (e[2] = (i) => s("hideConfiguration", !a.hideConfiguration))
365
+ }, null, 8, ["border-color", "text-color"])
366
+ ])
367
+ ]),
368
+ _: 1
369
+ }, 8, ["model-value"]),
370
+ _("div", Oe, [
371
+ o.value.tiles.length > 0 ? (r(), F("div", qe, [
372
+ (r(!0), F(B, null, z(o.value.tiles, (i, k) => (r(), y(oe, {
373
+ key: `${l(Q)()}_${k}`,
374
+ "model-value": i,
375
+ index: k,
376
+ "hide-export": !0
377
+ }, null, 8, ["model-value", "index"]))), 128))
378
+ ])) : (r(), y(te, { key: 1 }))
379
+ ])
380
+ ], 64)) : (r(), y(f, { key: 0 }))
381
+ ]);
382
+ };
383
+ }
384
+ }), Ne = {
385
+ key: 0,
386
+ class: "grid grid-cols-12 gap-[16px]"
387
+ }, Ue = /* @__PURE__ */ h({
388
+ __name: "ReportEditorMobile",
389
+ props: /* @__PURE__ */ w({
390
+ hideConfiguration: { type: Boolean, required: !0, default: !1 }
391
+ }, {
392
+ modelValue: { required: !0, default: () => {
393
+ } },
394
+ modelModifiers: {}
395
+ }),
396
+ emits: /* @__PURE__ */ w(["hideConfiguration"], ["update:modelValue"]),
397
+ setup(c, { emit: n }) {
398
+ const o = R(c, "modelValue"), a = c, s = n;
399
+ return (C, e) => {
400
+ const f = m("FmCircularProgress"), v = m("FmCard");
401
+ return r(), F("div", null, [
402
+ o.value ? (r(), F(B, { key: 1 }, [
403
+ t(v, { class: "px-5 pb-28" }, {
404
+ default: u(() => [
405
+ o.value.tiles.length > 0 ? (r(), F("div", Ne, [
406
+ (r(!0), F(B, null, z(o.value.tiles, (i, k) => (r(), y(oe, {
407
+ key: `${l(Q)()}_${k}`,
408
+ "model-value": i,
409
+ index: k,
410
+ "hide-export": !0
411
+ }, null, 8, ["model-value", "index"]))), 128))
412
+ ])) : (r(), y(te, { key: 1 }))
413
+ ]),
414
+ _: 1
415
+ }),
416
+ o.value ? (r(), y(le, {
417
+ key: 0,
418
+ modelValue: o.value,
419
+ "onUpdate:modelValue": e[0] || (e[0] = (i) => o.value = i),
420
+ "hide-configuration": a.hideConfiguration,
421
+ onHideConfiguration: e[1] || (e[1] = (i) => {
422
+ s("hideConfiguration", i);
423
+ })
424
+ }, null, 8, ["modelValue", "hide-configuration"])) : O("", !0)
425
+ ], 64)) : (r(), y(f, { key: 0 }))
426
+ ]);
427
+ };
428
+ }
429
+ }), Ye = /* @__PURE__ */ h({
430
+ __name: "ReportEditor",
431
+ setup(c) {
432
+ const n = Z(), o = ee(), a = j(), { promptLoader: s } = ke(), { currentReport: C, editingReport: e } = X(a), { breakpoints: f } = I(), v = N(() => {
433
+ var V;
434
+ return !((V = e.value) != null && V.editable);
435
+ }), i = N(() => {
436
+ var V;
437
+ return ((V = e.value) == null ? void 0 : V.name) ?? "New Report";
438
+ }), k = xe(), { promptMessage: b } = K(), $ = D(!1);
439
+ async function M() {
440
+ if (!e.value || e.value.tiles.length === 0) {
441
+ k.open({ message: "No Widget", type: "error" });
442
+ return;
443
+ }
444
+ const V = v.value ? "clone" : "save";
445
+ if (await b({
446
+ title: "Save report",
447
+ message: `Do you really want to ${V} ${i.value} ?`
448
+ }))
449
+ try {
450
+ await s(async () => {
451
+ if (v.value) {
452
+ const d = JSON.parse(JSON.stringify(e.value));
453
+ d.editable = !0, d.id = "", d.name = `${d.name} duplicate`, await a.createOrUpdateReport(d);
454
+ } else
455
+ e.value && await a.createOrUpdateReport(e.value);
456
+ n.push({
457
+ name: "reportView",
458
+ query: o.query
459
+ });
460
+ });
461
+ } catch (d) {
462
+ console.log(d), k.open({ message: `Failed to ${V} report`, type: "error" });
463
+ }
464
+ }
465
+ async function S() {
466
+ var x;
467
+ if (!e.value)
468
+ return;
469
+ await b({
470
+ title: "Report",
471
+ message: `Report ${(x = e.value) == null ? void 0 : x.name} is not saved, are you sure you want to quit?`
472
+ }) && (e.value = JSON.parse(JSON.stringify(C.value)), n.back());
473
+ }
474
+ return fe(() => {
475
+ e.value || n.push({ name: "reports" });
476
+ }), (V, x) => {
477
+ const d = m("FmChip"), p = m("FmButton");
478
+ return r(), y(Ve, null, {
479
+ default: u(() => [
480
+ t(Fe, null, {
481
+ title: u(() => [
482
+ _("p", {
483
+ class: U(`${l(f).sm || l(f).xs ? "hidden" : ""}`)
484
+ }, L(i.value), 3),
485
+ !l(e) || l(e).tiles.length <= 0 ? (r(), y(d, {
486
+ key: 0,
487
+ label: "Draft",
488
+ icon: "hexagon",
489
+ selectable: !1
490
+ })) : O("", !0)
491
+ ]),
492
+ button: u(() => [
493
+ t(p, {
494
+ label: "Cancel",
495
+ variant: "tertiary",
496
+ "text-color": l(q).TypoSecondary,
497
+ onClick: S
498
+ }, null, 8, ["text-color"]),
499
+ t(p, {
500
+ label: `${l(C) ? "Save" : "Add"} report`,
501
+ "prepend-icon": "download",
502
+ onClick: M
503
+ }, null, 8, ["label"])
504
+ ]),
505
+ _: 1
506
+ }),
507
+ l(e) ? (r(), y(G(l(f).lg || l(f).md ? De : Ue), {
508
+ key: 0,
509
+ modelValue: l(e),
510
+ "onUpdate:modelValue": x[0] || (x[0] = (T) => Y(e) ? e.value = T : null),
511
+ class: U(`${l(f).lg || l(f).md ? "flex" : ""} w-full`),
512
+ style: ve({ height: `calc( 100% - ${l(f).lg || l(f).md ? 72 : 64}px)` }),
513
+ "hide-configuration": $.value,
514
+ onHideConfiguration: x[1] || (x[1] = (T) => $.value = T)
515
+ }, null, 40, ["modelValue", "class", "style", "hide-configuration"])) : O("", !0)
516
+ ]),
517
+ _: 1
518
+ });
519
+ };
520
+ }
521
+ });
522
+ export {
523
+ Ye as default
524
+ };