@feedmepos/mf-report 5.5.7-beta.0 → 5.5.8-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.
@@ -1,1005 +0,0 @@
1
- import { defineComponent as H, useModel as O, computed as o, ref as F, resolveComponent as w, createElementBlock as L, openBlock as h, Fragment as W, renderSlot as G, createVNode as S, createElementVNode as k, toDisplayString as Z, unref as j, withCtx as B, createBlock as $, createCommentVNode as K, normalizeClass as le, normalizeStyle as _e, h as ge, renderList as Ce, mergeModels as Ee, watch as ae, onMounted as ze, onUnmounted as We, resolveDynamicComponent as He, withDirectives as Oe, vShow as qe } from "vue";
2
- import { W as i, v as te, R as Ue, g as je, d as Ge, q as Je } from "./v4-Dzkr7vpG.js";
3
- import { u as ie, b as xe, a as ue } from "./global-loader-BqFQzk46.js";
4
- import { d as be } from "./index-DqqTHE7n.js";
5
- import { storeToRefs as oe } from "pinia";
6
- import { _ as Ke } from "./_plugin-vue_export-helper-CHgC5LLL.js";
7
- import { _ as ye } from "./NoData.vue_vue_type_script_setup_true_lang-DI4X_DSc.js";
8
- import { useBreakpoints as Qe, useSnackbar as Ze } from "@feedmepos/ui-library";
9
- var re = /* @__PURE__ */ ((t) => (t.line = "LINE", t.bar = "BAR", t))(re || {}), M = /* @__PURE__ */ ((t) => (t.top = "TOP", t.bottom = "BOTTOM", t))(M || {});
10
- i.Circular, i.Table, i.BarChart, i.LineChart, i.StackBarChart, i.StackLineChart, i.Scorecard, i.Spacer;
11
- const Xe = [
12
- {
13
- type: i.Circular,
14
- showLabel: !1,
15
- // TODO: temporarily removed show label as it has no function
16
- showDrillDimension: !0,
17
- showRollup: !1,
18
- showSearchBar: !1
19
- },
20
- {
21
- type: i.Table,
22
- showLabel: !1,
23
- showDrillDimension: !0,
24
- showRollup: !0,
25
- showSearchBar: !0
26
- },
27
- {
28
- type: i.BarChart,
29
- showLabel: !1,
30
- // TODO: temporarily removed show label as it has no function
31
- showDrillDimension: !0,
32
- showRollup: !1,
33
- showSearchBar: !1
34
- },
35
- {
36
- type: i.LineChart,
37
- showLabel: !1,
38
- // TODO: temporarily removed show label as it has no function
39
- showDrillDimension: !0,
40
- showRollup: !0,
41
- showSearchBar: !1
42
- },
43
- {
44
- type: i.StackBarChart,
45
- showLabel: !1,
46
- // TODO: temporarily removed show label as it has no function
47
- showDrillDimension: !0,
48
- showRollup: !0,
49
- showSearchBar: !1
50
- },
51
- {
52
- type: i.StackLineChart,
53
- showLabel: !1,
54
- // TODO: temporarily removed show label as it has no function
55
- showDrillDimension: !0,
56
- showRollup: !0,
57
- showSearchBar: !1
58
- },
59
- {
60
- type: i.Scorecard,
61
- showLabel: !1,
62
- showDrillDimension: !1,
63
- showRollup: !1,
64
- showSearchBar: !1
65
- },
66
- {
67
- type: i.Spacer,
68
- showLabel: !1,
69
- showDrillDimension: !1,
70
- showRollup: !1,
71
- showSearchBar: !1
72
- }
73
- ];
74
- function se(t) {
75
- const e = [t.schemaName, t.name];
76
- return "option" in t && t.option && e.push(t.option), "aggregation" in t && t.aggregation && e.push(t.aggregation), e.push(t.label.replace(/[^a-zA-Z0-9]/g, "")), e.join("_").toLowerCase();
77
- }
78
- function Ye(t, e) {
79
- switch (t) {
80
- case i.BarChart:
81
- case i.LineChart:
82
- case i.StackBarChart:
83
- case i.StackLineChart:
84
- return Array.isArray(e == null ? void 0 : e.datasets) && Array.isArray(e == null ? void 0 : e.xAxis) && e.datasets.length > 0 && e.xAxis.length > 0;
85
- case i.Table:
86
- return Array.isArray(e == null ? void 0 : e.rows) && Array.isArray(e == null ? void 0 : e.columns) && e.rows.length > 0 && e.columns.length > 0;
87
- case i.Circular:
88
- return Array.isArray(e == null ? void 0 : e.datasets) && e.datasets.length > 0;
89
- case i.Scorecard:
90
- return !0;
91
- case i.Spacer:
92
- return !0;
93
- }
94
- }
95
- const we = [
96
- "54, 162, 235",
97
- //8CE6D7
98
- "0, 123, 167",
99
- //007BA7
100
- "255, 93, 83",
101
- //FF5D53
102
- "115, 200, 230",
103
- //73C8E6
104
- "252, 162, 62",
105
- //FCA23E
106
- "240, 155, 190",
107
- //F09BBE
108
- "255, 210, 50",
109
- //FFD232
110
- "80, 190, 155",
111
- //50BE9B
112
- "131, 88, 212",
113
- //8358D4
114
- "155, 80, 70"
115
- //9B5046
116
- ];
117
- function X({
118
- index: t,
119
- isCompare: e,
120
- opacity: n
121
- }) {
122
- let p = typeof n == "number" ? n : 1;
123
- return e && (p = p * 0.6), `rgba(${we[t % we.length]}, ${p})`;
124
- }
125
- function ke(t, e, n) {
126
- if (t === "" || e === "")
127
- return null;
128
- let p = (s) => s == null ? void 0 : s.replace(/,/g, "");
129
- n === "ID" && (p = (s) => s == null ? void 0 : s.replace(/\./g, "").replace(/,/g, "."));
130
- const g = Number(p(t)), v = Number(p(e));
131
- if (isNaN(g) || isNaN(v))
132
- return null;
133
- let u = 0;
134
- v === 0 ? g === 0 ? u = 0 : u = 1 : u = (g - v) / v;
135
- const l = ea(u);
136
- return {
137
- value: isNaN(u) ? "" : `${(u * 100).toFixed(0)}%`,
138
- icon: l
139
- };
140
- }
141
- function ea(t) {
142
- return t > 0 ? {
143
- name: "moving",
144
- color: "#1F7735",
145
- tailwind: "fm-color-system-success-100"
146
- } : t < 0 ? {
147
- name: "trending_down",
148
- color: "#99231D",
149
- tailwind: "fm-color-system-error-100"
150
- } : {
151
- name: "equal",
152
- color: "#C7C7CC",
153
- tailwind: "fm-color-neutral-gray-100"
154
- };
155
- }
156
- const aa = /* @__PURE__ */ H({
157
- __name: "WidgetBarchart",
158
- props: {
159
- modelValue: { required: !0 },
160
- modelModifiers: {}
161
- },
162
- emits: ["update:modelValue"],
163
- setup(t) {
164
- const e = O(t, "modelValue"), n = o(() => {
165
- var s;
166
- return ((s = e.value.data) == null ? void 0 : s.xAxis) ?? [];
167
- }), p = o(() => {
168
- var s;
169
- return ((s = e.value.data) == null ? void 0 : s.datasets) ?? [];
170
- }), g = o(() => e.value.isTransposed ?? void 0), v = o(() => e.value.showLabel ?? void 0), u = F(null), l = o(() => p.value.length > 0 ? [
171
- ...p.value.map((s, m) => ({
172
- label: s.name,
173
- data: s.values,
174
- dash: !!s.isCompare,
175
- backgroundColor: X({ index: m, isCompare: s.isCompare })
176
- }))
177
- ] : []);
178
- return (s, m) => {
179
- const R = w("FmBarChart");
180
- return h(), L(W, null, [
181
- G(s.$slots, "menu"),
182
- S(R, {
183
- ref_key: "chartRef",
184
- ref: u,
185
- class: "bar-chart",
186
- datasets: l.value,
187
- "x-axis": { categories: n.value },
188
- transpose: g.value,
189
- legend: {
190
- display: !1,
191
- position: "bottom",
192
- maxHeight: 54,
193
- labels: {
194
- usePointStyle: !0
195
- }
196
- },
197
- datalabels: { display: v.value, align: "end", anchor: "end" },
198
- "maintain-aspect-ratio": !1
199
- }, null, 8, ["datasets", "x-axis", "transpose", "datalabels"])
200
- ], 64);
201
- };
202
- }
203
- }), ta = /* @__PURE__ */ H({
204
- __name: "WidgetCircular",
205
- props: {
206
- modelValue: { required: !0 },
207
- modelModifiers: {}
208
- },
209
- emits: ["update:modelValue"],
210
- setup(t) {
211
- const e = O(t, "modelValue"), n = o(() => e.value.showLabel ?? void 0), p = o(() => {
212
- let g = [];
213
- return e.value.data.datasets && e.value.data.metrics && e.value.data.datasets.length > 0 && e.value.data.metrics.length > 0 && (g = [
214
- {
215
- label: e.value.data.metrics[0],
216
- data: e.value.data.datasets.map((v) => v.value),
217
- backgroundColor: e.value.data.datasets.map((v, u) => X({ index: u }))
218
- }
219
- ]), g;
220
- });
221
- return (g, v) => {
222
- const u = w("FmPieChart");
223
- return h(), L(W, null, [
224
- G(g.$slots, "menu"),
225
- S(u, {
226
- class: "circular",
227
- percentage: "70%",
228
- datasets: p.value,
229
- metrics: e.value.data.datasets.map((l) => l.name),
230
- variant: "doughnut",
231
- legend: {
232
- display: !0,
233
- position: "top",
234
- maxHeight: 54,
235
- labels: {
236
- usePointStyle: !0
237
- }
238
- },
239
- datalabels: { display: n.value, align: "end", anchor: "end" },
240
- "maintain-aspect-ratio": !1
241
- }, null, 8, ["datasets", "metrics", "datalabels"])
242
- ], 64);
243
- };
244
- }
245
- }), la = { class: "flex flex-col gap-1" }, na = { class: "fm-typo-en-title-sm-600" }, sa = { class: "flex gap-2" }, oa = { key: 0 }, ra = { key: 1 }, ia = /* @__PURE__ */ H({
246
- __name: "WidgetScorecard",
247
- props: {
248
- modelValue: { required: !0 },
249
- modelModifiers: {}
250
- },
251
- emits: ["update:modelValue"],
252
- setup(t) {
253
- const e = O(t, "modelValue"), { t: n } = ie(), { compareDateRange: p, defaultDateSetting: g } = oe(xe()), { country: v } = ue(), u = o(() => {
254
- var y;
255
- return ((y = e.value.data) == null ? void 0 : y.value) || "";
256
- }), l = o(() => {
257
- const { data: y } = e.value;
258
- return y != null && y.comparison ? ke(u.value, y.comparison, v) : null;
259
- });
260
- function s(y) {
261
- switch (y) {
262
- case re.bar:
263
- return "bar";
264
- case re.line:
265
- return "line";
266
- default:
267
- return "line";
268
- }
269
- }
270
- const m = o(() => {
271
- var y;
272
- return (y = e.value.data) == null ? void 0 : y.sparkline;
273
- }), R = o(() => m.value.datasets.map((y) => ({
274
- label: y.name,
275
- data: y.values,
276
- fill: !0,
277
- color: "#36a2eb"
278
- })));
279
- return (y, T) => {
280
- var c;
281
- const J = w("FmIcon"), I = w("FmChip"), D = w("FmTooltip"), a = w("FmLineChart");
282
- return h(), L("div", la, [
283
- G(y.$slots, "menu"),
284
- k("p", na, Z(u.value), 1),
285
- k("div", sa, [
286
- S(D, {
287
- content: `vs. ${(c = j(g).defaultCompareType) == null ? void 0 : c.split("_").join(" ")}`,
288
- placement: "right",
289
- "hide-arrow": "",
290
- variant: "plain"
291
- }, {
292
- default: B(() => [
293
- l.value ? (h(), $(I, {
294
- key: 0,
295
- icon: l.value.icon.name,
296
- class: le(`bg-${l.value.icon.tailwind}`),
297
- compact: ""
298
- }, {
299
- default: B(() => [
300
- S(J, {
301
- name: l.value.icon.name,
302
- color: l.value.icon.color
303
- }, null, 8, ["name", "color"]),
304
- k("p", {
305
- class: "fm-typo-en-body-md-600",
306
- style: _e({ color: l.value.icon.color })
307
- }, Z(l.value.value), 5)
308
- ]),
309
- _: 1
310
- }, 8, ["icon", "class"])) : K("", !0),
311
- j(p).endDate !== null && j(p).startDate !== null && l.value === null ? (h(), $(I, {
312
- key: 1,
313
- compact: ""
314
- }, {
315
- default: B(() => [
316
- S(J, {
317
- name: "arrow_upward",
318
- color: "#C7C7CC"
319
- }),
320
- T[0] || (T[0] = k("p", { class: "fm-typo-en-body-md-600 text-fm-color-typo-disabled" }, "N/A", -1))
321
- ]),
322
- _: 1
323
- })) : K("", !0)
324
- ]),
325
- _: 1
326
- }, 8, ["content"])
327
- ]),
328
- m.value ? (h(), L("div", oa, [
329
- s(m.value.type) === "line" ? (h(), $(a, {
330
- key: 0,
331
- class: "sparkline",
332
- datasets: R.value,
333
- "hide-x-axis": !0,
334
- "hide-y-axis": !0,
335
- legend: {
336
- display: !1
337
- },
338
- datalabels: { display: !1 },
339
- "x-axis": { categories: m.value.dimensions },
340
- "maintain-aspect-ratio": !1
341
- }, null, 8, ["datasets", "x-axis"])) : K("", !0)
342
- ])) : (h(), L("div", ra, T[1] || (T[1] = [
343
- k("div", { class: "sparkline" }, [
344
- k("div", { class: "flex flex-col gap-8" }, [
345
- k("div"),
346
- k("div")
347
- ]),
348
- k("div", { class: "grow" })
349
- ], -1)
350
- ])))
351
- ]);
352
- };
353
- }
354
- }), ua = {};
355
- function ca(t, e) {
356
- const n = w("FmMenuDivider");
357
- return h(), $(n);
358
- }
359
- const da = /* @__PURE__ */ Ke(ua, [["render", ca]]), ma = { class: "my-4" }, pa = {
360
- class: "border-b border-fm-color-neutral-gray-100 hover:bg-fm-color-opacity-sm",
361
- style: { backgroundColor: "#f9f9f9" }
362
- }, va = { class: "font-bold" }, fa = { class: "text-fm-color-neutral-gray-300" }, ha = /* @__PURE__ */ H({
363
- __name: "WidgetTable",
364
- props: {
365
- modelValue: { required: !0 },
366
- modelModifiers: {}
367
- },
368
- emits: ["update:modelValue"],
369
- setup(t) {
370
- const { t: e } = ie(), n = O(t, "modelValue"), { country: p } = ue(), g = F(null), v = o(() => {
371
- var a;
372
- return ((a = n.value.data) == null ? void 0 : a.columns) || [{ label: "", key: "" }];
373
- }), u = o(() => {
374
- var a;
375
- return ((a = n.value.data) == null ? void 0 : a.rows) || [];
376
- }), l = o(() => n.value.filterText), s = o(() => {
377
- var a, c;
378
- if (!(l.value && l.value.trim().length > 0 || !((a = u.value[0]) != null && a.isRollup) && !((c = u.value[u.value.length - 1]) != null && c.isRollup))) {
379
- if (n.value.rollupPosition === M.top || n.value.rollupPosition === void 0)
380
- return M.top;
381
- if (n.value.rollupPosition === M.bottom)
382
- return M.bottom;
383
- }
384
- }), m = o(() => {
385
- const d = s.value !== void 0 ? 1 : 0, x = (g.value ? g.value.$el.offsetHeight : 0) - 48;
386
- return Math.floor((x - 34.5 - 32) / 48) - d;
387
- }), R = o(() => {
388
- var c, b;
389
- let a = [];
390
- switch (s.value) {
391
- case M.top:
392
- a = [...((c = u.value[0]) == null ? void 0 : c.cells) || []].map((d, x) => {
393
- var _;
394
- return {
395
- main: d,
396
- comparison: (_ = u.value[0]) == null ? void 0 : _.comparisonCells[x],
397
- rowType: v.value[x].type
398
- };
399
- });
400
- break;
401
- case M.bottom:
402
- a = [...((b = u.value[u.value.length - 1]) == null ? void 0 : b.cells) || []].map((d, x) => {
403
- var _;
404
- return {
405
- main: d,
406
- comparison: (_ = u.value[0]) == null ? void 0 : _.comparisonCells[x],
407
- rowType: v.value[x].type
408
- };
409
- });
410
- break;
411
- }
412
- return a.length > 0 && a[0].main === "" && (a[0].main = "Grand total"), a;
413
- });
414
- function y(a) {
415
- const c = {};
416
- for (let b = 0; b < v.value.length; b++)
417
- if (v.value[b].key !== "") {
418
- const d = a.comparisonCells[b];
419
- c[v.value[b].key] = {
420
- main: a.cells[b],
421
- comparison: d
422
- }, c.isRollup = a.isRollup;
423
- }
424
- return c;
425
- }
426
- function T(a) {
427
- return [...new Array(a < 0 ? 0 : a)].map(() => {
428
- var b;
429
- const c = {};
430
- if ((b = n.value.data) != null && b.columns)
431
- for (let d = 0; d < n.value.data.columns.length; d++)
432
- c[n.value.data.columns[d].key] = void 0;
433
- return c;
434
- });
435
- }
436
- function J(a) {
437
- let c = (a == null ? void 0 : a.main) || "";
438
- return c.includes("#") && !c.startsWith("#") && (c = c.split("#")[0]), !a || a.main === "" || a.comparison === "" ? {
439
- main: c
440
- } : {
441
- main: c,
442
- comparison: a == null ? void 0 : a.comparison,
443
- difference: ke(a.main, a.comparison, p)
444
- };
445
- }
446
- const I = o(() => {
447
- var x, _, N;
448
- let a = ((x = n.value.data) == null ? void 0 : x.rows) || [];
449
- switch (s.value) {
450
- case M.bottom:
451
- a = (_ = a[a.length - 1]) != null && _.isRollup ? a.slice(0, -1) : a;
452
- break;
453
- case M.top:
454
- a = (N = a[0]) != null && N.isRollup ? a.slice(1, a.length) : a;
455
- break;
456
- }
457
- const c = a.filter((P) => !(l.value !== "" && (P.isRollup === !0 || !P.cells.some(
458
- (E) => {
459
- var q;
460
- return ((E == null ? void 0 : E.toLowerCase()) || "").includes((q = l.value) == null ? void 0 : q.toLowerCase());
461
- }
462
- )))).map((P) => y(P)), b = c.length % m.value;
463
- let d = 0;
464
- return b > 0 ? d = Math.abs(b - m.value) : c.length === 0 && (d = m.value), c.push(...T(d)), c;
465
- }), D = o(() => {
466
- var c;
467
- let a = [];
468
- return (c = n.value.data) != null && c.columns && (a = [...n.value.data.columns.map((d) => {
469
- const x = d.label;
470
- return {
471
- accessorKey: d.key,
472
- header: () => ge(
473
- "p",
474
- {
475
- class: `min-w-[110px] w-full text-nowrap ${d.type === "NUMERIC" ? "text-right" : ""}`
476
- },
477
- x
478
- ),
479
- cell: (_) => {
480
- var E, q;
481
- const N = J(_.getValue()), P = (q = (E = _ == null ? void 0 : _.row) == null ? void 0 : E.original) == null ? void 0 : q.isRollup;
482
- return ge(
483
- "div",
484
- {
485
- class: `${P ? "fm-typo-en-body-md-600 text-fm-color-typo-secondary" : "fm-typo-en-body-md-400"} ${d.type === "NUMERIC" ? "text-right" : ""} text-nowrap whitespace-pre`
486
- },
487
- [N.main]
488
- );
489
- },
490
- meta: () => ({
491
- cellClass: "subtotal-row"
492
- }),
493
- enableSorting: !1
494
- };
495
- })]), a;
496
- });
497
- return (a, c) => {
498
- const b = w("FmTable");
499
- return h(), L(W, null, [
500
- k("div", ma, [
501
- G(a.$slots, "menu")
502
- ]),
503
- S(b, {
504
- ref_key: "table",
505
- ref: g,
506
- "column-defs": D.value,
507
- "row-data": I.value,
508
- "search-value": l.value,
509
- "page-size": m.value,
510
- "shrink-at": !1,
511
- "force-mobile-footer": !0,
512
- class: "scrollbar-hide-table"
513
- }, {
514
- "pin-top": B(() => [
515
- k("tbody", null, [
516
- k("tr", pa, [
517
- (h(!0), L(W, null, Ce(R.value, (d, x) => (h(), L("td", {
518
- key: `${j(te)()}_${x}`,
519
- class: "h-[48px] text-fm-color-typo-primary px-16"
520
- }, [
521
- k("span", {
522
- class: le(`items-center text-fm-color-typo-secondary gap-2 line-clamp-2 text-ellipsis ${d.rowType === "NUMERIC" ? "text-right" : ""}`)
523
- }, [
524
- k("p", va, Z(d.main), 1),
525
- k("p", fa, Z(d.comparison ? `(${d.comparison})` : ""), 1)
526
- ], 2)
527
- ]))), 128))
528
- ])
529
- ])
530
- ]),
531
- _: 1
532
- }, 8, ["column-defs", "row-data", "search-value", "page-size"])
533
- ], 64);
534
- };
535
- }
536
- }), ga = /* @__PURE__ */ H({
537
- __name: "WidgetStackBarChart",
538
- props: {
539
- modelValue: { required: !0 },
540
- modelModifiers: {}
541
- },
542
- emits: ["update:modelValue"],
543
- setup(t) {
544
- const e = O(t, "modelValue"), n = o(() => {
545
- var m;
546
- return ((m = e.value.data) == null ? void 0 : m.xAxis) || [];
547
- }), p = o(() => {
548
- var s;
549
- return ((s = e.value.data) == null ? void 0 : s.datasets) ?? [];
550
- }), g = o(() => e.value.isTransposed ?? void 0), v = o(() => e.value.showLabel ?? void 0), u = F(null), l = o(() => p.value.length > 0 ? [
551
- ...p.value.map((s, m) => {
552
- let R = s.values;
553
- return {
554
- label: s.name,
555
- data: R,
556
- dash: !!s.isCompare,
557
- backgroundColor: X({ index: m, isCompare: s.isCompare })
558
- };
559
- })
560
- ] : []);
561
- return (s, m) => {
562
- const R = w("FmBarChart");
563
- return h(), L(W, null, [
564
- G(s.$slots, "menu"),
565
- S(R, {
566
- ref_key: "chartRef",
567
- ref: u,
568
- class: "bar-chart",
569
- datasets: l.value,
570
- "x-axis": { categories: n.value },
571
- transpose: g.value,
572
- stacked: !0,
573
- legend: {
574
- display: !1,
575
- position: "bottom",
576
- maxHeight: 54,
577
- labels: {
578
- usePointStyle: !0
579
- }
580
- },
581
- datalabels: { display: v.value, align: "end", anchor: "end", rotation: 0 },
582
- "maintain-aspect-ratio": !1
583
- }, null, 8, ["datasets", "x-axis", "transpose", "datalabels"])
584
- ], 64);
585
- };
586
- }
587
- }), ba = /* @__PURE__ */ H({
588
- __name: "WidgetStackLineChart",
589
- props: {
590
- modelValue: { required: !0 },
591
- modelModifiers: {}
592
- },
593
- emits: ["update:modelValue"],
594
- setup(t) {
595
- const e = O(t, "modelValue"), n = o(() => {
596
- var l;
597
- return ((l = e.value.data) == null ? void 0 : l.xAxis) ?? [];
598
- }), p = o(() => {
599
- var l;
600
- return ((l = e.value.data) == null ? void 0 : l.datasets) ?? [];
601
- }), g = o(() => e.value.isTransposed ?? void 0), v = o(() => e.value.showLabel ?? void 0), u = o(() => p.value.length > 0 ? [
602
- ...p.value.map((l, s) => {
603
- let m = l.values;
604
- return {
605
- label: l.name,
606
- data: m,
607
- dash: l.isCompare,
608
- fill: !1,
609
- color: X({ index: s, isCompare: l.isCompare })
610
- };
611
- })
612
- ] : []);
613
- return (l, s) => {
614
- const m = w("FmLineChart");
615
- return h(), L(W, null, [
616
- G(l.$slots, "menu"),
617
- S(m, {
618
- class: "line-chart",
619
- datasets: u.value,
620
- "x-axis": { categories: n.value },
621
- transpose: g.value,
622
- legend: {
623
- display: !1,
624
- position: "bottom",
625
- maxHeight: 54,
626
- labels: {
627
- usePointStyle: !0
628
- }
629
- },
630
- stacked: !0,
631
- datalabels: { display: v.value, align: "end", anchor: "end", rotation: 0 },
632
- "maintain-aspect-ratio": !1
633
- }, null, 8, ["datasets", "x-axis", "transpose", "datalabels"])
634
- ], 64);
635
- };
636
- }
637
- }), Q = [
638
- "col-span-1",
639
- "col-span-2",
640
- "col-span-3",
641
- "col-span-4",
642
- "col-span-5",
643
- "col-span-6",
644
- "col-span-7",
645
- "col-span-8",
646
- "col-span-9",
647
- "col-span-10",
648
- "col-span-11",
649
- "col-span-12"
650
- ];
651
- function ya(t) {
652
- return t < 12 ? Q[t - 1] : Q[11];
653
- }
654
- function wa(t) {
655
- return t < 12 ? Q[Math.min(11, t * 2 - 1)] : Q[11];
656
- }
657
- function _a(t) {
658
- return t < 12 ? Q[Math.min(11, t * 3 - 1)] : Q[11];
659
- }
660
- const Ca = /* @__PURE__ */ H({
661
- __name: "WidgetLinechart",
662
- props: {
663
- modelValue: { required: !0 },
664
- modelModifiers: {}
665
- },
666
- emits: ["update:modelValue"],
667
- setup(t) {
668
- const e = O(t, "modelValue"), n = o(() => {
669
- var l;
670
- return ((l = e.value.data) == null ? void 0 : l.xAxis) ?? [];
671
- }), p = o(() => {
672
- var l;
673
- return ((l = e.value.data) == null ? void 0 : l.datasets) ?? [];
674
- }), g = o(() => e.value.isTransposed ?? void 0), v = o(() => e.value.showLabel ?? void 0), u = o(() => p.value.length > 0 ? [
675
- ...p.value.map((l, s) => ({
676
- label: l.name,
677
- data: l.values,
678
- dash: !!l.isCompare,
679
- fill: !1,
680
- color: X({ index: s, isCompare: l.isCompare })
681
- }))
682
- ] : []);
683
- return (l, s) => {
684
- const m = w("FmLineChart");
685
- return h(), L(W, null, [
686
- G(l.$slots, "menu"),
687
- S(m, {
688
- class: "line-chart",
689
- datasets: u.value,
690
- "x-axis": { categories: n.value },
691
- transpose: g.value,
692
- legend: {
693
- display: !1,
694
- position: "bottom",
695
- maxHeight: 54,
696
- labels: {
697
- usePointStyle: !0
698
- }
699
- },
700
- datalabels: { display: v.value, align: "end", anchor: "end", rotation: 0 },
701
- "maintain-aspect-ratio": !1
702
- }, null, 8, ["datasets", "x-axis", "transpose", "datalabels"])
703
- ], 64);
704
- };
705
- }
706
- }), xa = {
707
- key: 1,
708
- class: "grow"
709
- }, ka = {
710
- key: 2,
711
- class: "flex"
712
- }, Ba = /* @__PURE__ */ H({
713
- __name: "DynamicWidget",
714
- props: /* @__PURE__ */ Ee({
715
- index: {
716
- type: Number,
717
- default: 0
718
- },
719
- hideExport: {
720
- type: Boolean,
721
- default: !1
722
- }
723
- }, {
724
- modelValue: { required: !0, default: () => {
725
- } },
726
- modelModifiers: {}
727
- }),
728
- emits: ["update:modelValue"],
729
- setup(t) {
730
- const e = F(!0), n = O(t, "modelValue"), { t: p } = ie(), g = t, v = F(null), u = F(n.value.widget.config.rollup), l = F(te()), s = F(n.value.widget.config.drillDimension), m = o(() => {
731
- if (U.value.length > 0) {
732
- const r = U.value.findIndex(
733
- (f) => f.value === s.value
734
- );
735
- return r >= 0 ? r : 0;
736
- } else
737
- return -1;
738
- }), R = o(() => m.value !== 0), y = o(
739
- () => m.value != U.value.length - 1
740
- ), T = F(n.value.widget.config.showLabel ?? !1), J = o(() => n.value.widget.config.showSearchBar), I = F(""), { breakpoints: D } = Qe(), a = F(), c = o(() => D.value.lg || D.value.md ? ya(n.value.size.width) : D.value.sm ? wa(n.value.size.width) : _a(n.value.size.width)), b = o(
741
- () => Xe.find((r) => r.type === n.value.widget.type)
742
- ), d = be(() => {
743
- var r;
744
- a.value = Le((r = v.value) == null ? void 0 : r.$el.offsetWidth), l.value = te();
745
- }), x = o(() => {
746
- if (Ye(C.value.type, _.value))
747
- switch (n.value.widget.type) {
748
- case i.BarChart:
749
- return aa;
750
- case i.StackBarChart:
751
- return ga;
752
- case i.LineChart:
753
- return Ca;
754
- case i.StackLineChart:
755
- return ba;
756
- case i.Circular:
757
- return ta;
758
- case i.Scorecard:
759
- return ia;
760
- case i.Spacer:
761
- return da;
762
- case i.Table:
763
- return ha;
764
- default:
765
- return ye;
766
- }
767
- else
768
- return ye;
769
- }), _ = F(null), { selectedLocationIds: N, dateRange: P, compareDateRange: E, timeRange: q } = oe(xe()), { businessId: Se } = oe(ue()), C = o(() => {
770
- const r = JSON.parse(JSON.stringify(n.value.widget));
771
- return {
772
- ...r,
773
- config: {
774
- ...r.config,
775
- rollup: u.value,
776
- drillDimension: s.value,
777
- showGrandTotal: !1
778
- }
779
- };
780
- }), ce = o(() => {
781
- let r, f, V, z;
782
- switch (C.value.type) {
783
- case i.Table:
784
- V = I.value, z = C.value.config.rollupPosition;
785
- break;
786
- case i.BarChart:
787
- case i.LineChart:
788
- case i.StackBarChart:
789
- case i.StackLineChart:
790
- case i.Circular:
791
- r = T.value, f = C.value.config.isTransposed;
792
- break;
793
- }
794
- return {
795
- data: _.value,
796
- showLabel: r,
797
- isTransposed: f,
798
- rollupPosition: z,
799
- filterText: V
800
- };
801
- }), de = o(() => {
802
- const { config: r } = n.value.widget;
803
- if (r.rollup != null) {
804
- const f = [...r.dimensions].filter((V) => !V.hide);
805
- return f.sort(
806
- (V, z) => (r.rowIds || []).indexOf(se(V)) - (r.rowIds || []).indexOf(se(z))
807
- ), [
808
- { label: "None", value: null },
809
- { label: "Grand Total", value: 0 },
810
- ...[...f].slice(0, f.length - 1).map((V, z) => ({ label: V.label, value: z + 1 }))
811
- ];
812
- }
813
- return [];
814
- }), U = o(() => {
815
- const { config: r } = C.value;
816
- return r.isDrillable ? r.dimensions.map((f) => ({
817
- label: f.label,
818
- value: se(f)
819
- })) : [];
820
- });
821
- ae(n.value, (r) => {
822
- u.value = r.widget.config.rollup, T.value = r.widget.config.showLabel ?? !1;
823
- }), ae([() => u.value], () => {
824
- u.value !== null && (n.value.widget.config.rollup = u.value);
825
- }), ae(
826
- [
827
- () => C.value,
828
- () => P.value,
829
- () => q.value,
830
- () => E.value,
831
- () => N.value,
832
- () => Se.value
833
- ],
834
- () => {
835
- var r;
836
- N.value && ((r = N.value) == null ? void 0 : r.length) > 0 && pe();
837
- },
838
- {
839
- deep: !0
840
- }
841
- ), ae(
842
- [() => n.value.size],
843
- () => {
844
- d();
845
- },
846
- { deep: !0 }
847
- ), ze(() => {
848
- d(), D.value.sm || D.value.md || D.value.xs ? (console.log("Ignoring resize event due to keyboard"), addEventListener("change", d)) : addEventListener("resize", d), pe();
849
- }), We(() => {
850
- D.value.sm || D.value.md || D.value.xs ? (console.log("Ignoring resize event due to keyboard"), removeEventListener("change", d)) : removeEventListener("resize", d);
851
- });
852
- const me = Ze();
853
- let Y;
854
- const pe = be(async function() {
855
- if (C.value.config.schemaNames.length <= 0 && !(C.value.config.dimensions.length <= 0 || C.value.config.metrics.length <= 0)) {
856
- me.open({
857
- message: "schema must not be empty and dimension or metrics must have at least 1 column",
858
- type: "info"
859
- }), e.value = !1;
860
- return;
861
- }
862
- try {
863
- e.value = !0, Y && Y.abort(), Y = new AbortController();
864
- const f = Y.signal;
865
- _.value = await Je(C.value, f), l.value = te(), e.value = !1;
866
- } catch (f) {
867
- _.value = null, f.code !== "ERR_CANCELED" && (me.open({ message: `Invalid chart ${C.value.type}`, type: "error" }), console.log(f), e.value = !1);
868
- }
869
- });
870
- function Le(r) {
871
- switch (n.value.widget.type) {
872
- case "SPACER":
873
- return;
874
- case "SCORECARD":
875
- return;
876
- case "TABLE":
877
- return `${n.value.size.height * 100 + (J.value ? 72 : 0) + 96.5}px`;
878
- }
879
- return `${Math.max(r / n.value.size.width, 90) * n.value.size.height}px`;
880
- }
881
- function De() {
882
- const r = m.value - 1;
883
- r >= 0 && (s.value = U.value[r].value);
884
- }
885
- function Fe() {
886
- const r = m.value + 1;
887
- r >= 0 && r < U.value.length && (s.value = U.value[r].value);
888
- }
889
- const Re = Object.values(Ue).map((r) => ({
890
- label: je(r),
891
- value: r,
892
- onClick: async () => {
893
- await Ge(r, g.index);
894
- }
895
- })), Te = C.value.type === i.Spacer ? "flat" : "outlined", $e = C.value.type === i.Spacer ? "p-0" : "p-16";
896
- return (r, f) => {
897
- const V = w("FmTooltip"), z = w("FmSearch"), Ve = w("FmCheckbox"), ne = w("FmButton"), Be = w("FmSelect"), Ae = w("FmMenuItem"), Me = w("FmMenu"), Ie = w("FmForm"), Ne = w("FmCircularProgress"), Pe = w("FmCard");
898
- return h(), $(Pe, {
899
- ref_key: "tileCard",
900
- ref: v,
901
- class: le(`${c.value} ${j($e)}`),
902
- variant: j(Te)
903
- }, {
904
- default: B(() => [
905
- e.value ? (h(), $(Ne, { key: 1 })) : (h(), L("div", {
906
- key: 0,
907
- style: _e({ height: a.value })
908
- }, [
909
- (h(), $(He(x.value), {
910
- key: l.value,
911
- modelValue: ce.value,
912
- "onUpdate:modelValue": f[3] || (f[3] = (ee) => ce.value = ee)
913
- }, {
914
- menu: B(() => [
915
- S(Ie, { class: "flex items-center gap-2" }, {
916
- default: B(() => {
917
- var ee, ve, fe, he;
918
- return [
919
- S(V, {
920
- variant: "plain",
921
- placement: "right",
922
- content: C.value.description,
923
- "hide-arrow": !0,
924
- disabled: !C.value.description
925
- }, {
926
- default: B(() => [
927
- k("p", {
928
- class: le(["fm-typo-en-body-md-400 line-clamp-1 text-fm-color-typo-secondary", `${C.value.description ? "border-b-2 border-dashed border-gray-300" : ""}`])
929
- }, Z(C.value.title || " "), 3)
930
- ]),
931
- _: 1
932
- }, 8, ["content", "disabled"]),
933
- (ee = b.value) != null && ee.showSearchBar ? (h(), $(z, {
934
- key: 0,
935
- modelValue: I.value,
936
- "onUpdate:modelValue": f[0] || (f[0] = (A) => I.value = A),
937
- class: "grow"
938
- }, null, 8, ["modelValue"])) : (h(), L("div", xa)),
939
- Oe(S(Ve, {
940
- modelValue: T.value,
941
- "onUpdate:modelValue": f[1] || (f[1] = (A) => T.value = A),
942
- label: "Label",
943
- value: !1
944
- }, null, 8, ["modelValue"]), [
945
- [qe, (ve = b.value) == null ? void 0 : ve.showLabel]
946
- ]),
947
- (fe = b.value) != null && fe.showDrillDimension && U.value.length > 0 ? (h(), L("div", ka, [
948
- S(ne, {
949
- icon: "arrow_upward",
950
- variant: "tertiary",
951
- disabled: !R.value,
952
- onClick: De
953
- }, null, 8, ["disabled"]),
954
- S(ne, {
955
- icon: "arrow_downward",
956
- variant: "tertiary",
957
- disabled: !y.value,
958
- onClick: Fe
959
- }, null, 8, ["disabled"])
960
- ])) : K("", !0),
961
- (he = b.value) != null && he.showRollup && de.value.length > 0 ? (h(), $(Be, {
962
- key: 3,
963
- modelValue: u.value,
964
- "onUpdate:modelValue": f[2] || (f[2] = (A) => u.value = A),
965
- class: "w-[150px]",
966
- items: de.value
967
- }, null, 8, ["modelValue", "items"])) : K("", !0),
968
- g.hideExport ? K("", !0) : (h(), $(Me, {
969
- key: 4,
970
- shift: !0
971
- }, {
972
- "menu-button": B(() => [
973
- S(ne, {
974
- icon: "more_vert",
975
- variant: "tertiary"
976
- })
977
- ]),
978
- default: B(() => [
979
- (h(!0), L(W, null, Ce(j(Re), (A) => (h(), $(Ae, {
980
- key: A.value,
981
- label: A.label,
982
- onClick: A.onClick
983
- }, null, 8, ["label", "onClick"]))), 128))
984
- ]),
985
- _: 1
986
- }))
987
- ];
988
- }),
989
- _: 1
990
- })
991
- ]),
992
- _: 1
993
- }, 8, ["modelValue"]))
994
- ], 4))
995
- ]),
996
- _: 1
997
- }, 8, ["class", "variant"]);
998
- };
999
- }
1000
- });
1001
- export {
1002
- M as R,
1003
- Ba as _,
1004
- se as g
1005
- };