magtool 1.5.12 → 1.5.13

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.
package/README.1.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # magtool
2
2
 
3
+ 1.5.13
4
+ composition export
5
+
3
6
  1.5.12
4
7
  table footer
5
8
  echart tooltip cps
package/dist/component.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { defineComponent as P, getCurrentInstance as se, onMounted as re, reactive as H, createElementBlock as D, openBlock as p, normalizeStyle as me, unref as t, createCommentVNode as Y, createElementVNode as c, normalizeClass as K, renderSlot as W, toDisplayString as I, computed as g, watch as X, resolveComponent as N, createVNode as z, inject as pe, onBeforeMount as Te, markRaw as Ce, nextTick as fe, mergeProps as Z, withCtx as b, resolveDirective as Ae, withDirectives as De, createBlock as L, withKeys as xe, createSlots as ae, watchPostEffect as Me, Fragment as ie, renderList as de, createTextVNode as ne, defineAsyncComponent as _e, ref as he, withModifiers as ye, resolveDynamicComponent as Ie, watchEffect as ze } from "vue";
2
2
  import { _ as ue } from "./vendor.js";
3
3
  import { dayjs as Be } from "element-plus";
4
- import { l as je, u as Ye, d as Le } from "./composition.js";
4
+ import { loadImage as je, useSummary as Ye, download as Le } from "./composition.js";
5
5
  import $e from "vuedraggable";
6
6
  import { useRoute as Ee } from "vue-router";
7
7
  const Re = { class: "fw700" }, Pe = P({
@@ -1810,7 +1810,7 @@ const Re = { class: "fw700" }, Pe = P({
1810
1810
  ], 10, mo);
1811
1811
  };
1812
1812
  }
1813
- }), yo = /* @__PURE__ */ ue(go, [["__scopeId", "data-v-4ad79842"]]), ho = P({
1813
+ }), yo = /* @__PURE__ */ ue(go, [["__scopeId", "data-v-b05a08f4"]]), ho = P({
1814
1814
  name: "Table",
1815
1815
  inheritAttrs: !1
1816
1816
  }), _o = /* @__PURE__ */ Object.assign(ho, {
@@ -1,54 +1,118 @@
1
- const g = (n) => new Promise((l, p) => {
2
- const s = new Image();
3
- s.src = window.$getType(n) === "String" ? n : URL.createObjectURL(n), s.onload = () => l(s), s.onerror = () => p(new Error("Could not load image"));
4
- }), $ = ({ type: n = "csv", data: l, name: p }) => {
5
- let s = document.createElement("a");
6
- if (n === "csv") {
7
- const a = new Blob(["\uFEFF" + l], {
1
+ const v = (t) => {
2
+ const { age: e } = t || {};
3
+ let n, l;
4
+ if (e != null && e.included) {
5
+ const { minAge: o, maxAge: r } = e.included[0] || {};
6
+ o ? n = o : n = "all", r ? l = r : l = "all";
7
+ }
8
+ return l === "all" ? n === "all" ? "All" : `${n}~65+` : `${n}~${l}`;
9
+ }, S = (t, e) => t === "all" ? null : e === 65 ? {
10
+ included: [
11
+ {
12
+ minAge: t
13
+ }
14
+ ]
15
+ } : {
16
+ included: [
17
+ {
18
+ minAge: t,
19
+ maxAge: e
20
+ }
21
+ ]
22
+ }, _ = (t) => {
23
+ const { gender: e } = t || {};
24
+ return e != null && e.included ? e.included[0] : null;
25
+ }, M = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
26
+ __proto__: null,
27
+ useAgeFormat: v,
28
+ useAgeValue: S,
29
+ useGenderFormat: _
30
+ }, Symbol.toStringTag, { value: "Module" })), A = (t) => new Promise((e, n) => {
31
+ const l = new Image();
32
+ l.src = window.$getType(t) === "String" ? t : URL.createObjectURL(t), l.onload = () => e(l), l.onerror = () => n(new Error("Could not load image"));
33
+ }), O = (t) => new Promise((e, n) => {
34
+ const l = document.createElement("video");
35
+ l.preload = "metadata", window.$getType(t) === "String" ? l.src = t : l.src = URL.createObjectURL(t), l.onloadedmetadata = () => {
36
+ window.URL.revokeObjectURL(t), e(l);
37
+ };
38
+ }), j = ({ type: t = "csv", data: e, name: n }) => {
39
+ let l = document.createElement("a");
40
+ if (t === "csv") {
41
+ const r = new Blob(["\uFEFF" + e], {
8
42
  type: "text/csv,charset=UTF-8"
9
43
  });
10
- s.href = URL.createObjectURL(a);
44
+ l.href = URL.createObjectURL(r);
11
45
  }
12
- let t = new MouseEvent("click");
13
- s.download = p || "download", s.dispatchEvent(t), (n === "csv" || n === "video") && URL.revokeObjectURL(s.url), s = null, t = null;
14
- }, C = ({ columns: n, data: l, currency: p = "", channel: s = "" }) => {
15
- if (!l.length || !n.length)
46
+ let o = new MouseEvent("click");
47
+ l.download = n || "download", l.dispatchEvent(o), (t === "csv" || t === "video") && URL.revokeObjectURL(l.url), l = null, o = null;
48
+ }, C = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
49
+ __proto__: null,
50
+ download: j,
51
+ loadImage: A,
52
+ loadVideo: O
53
+ }, Symbol.toStringTag, { value: "Module" })), E = ({ table: t, key: e, form: n, value: l, cb: o = () => {
54
+ } }) => {
55
+ const r = t.getSelectionRows();
56
+ r.length > 1 ? (t.clearSelection(), t.toggleRowSelection(r[1], "selected"), n[l] = r[1][e]) : r.length === 1 && (n[l] = r[0][e]), o();
57
+ }, I = (t = {}) => {
58
+ let { sortable: e = !0, empty: n = !1, mmp: l = !1 } = t, o = window.$map.asa.asaMetric.all;
59
+ l && (o = o.concat(window.$map.asa.mmpMetric.all));
60
+ const r = o.map((a, i) => ({
61
+ label: a.label,
62
+ prop: a.value,
63
+ width: a.width,
64
+ sortable: e,
65
+ type: a.type,
66
+ align: a.align,
67
+ visible: a.visible,
68
+ formatter: a.formatter
69
+ }));
70
+ return r.unshift({
71
+ label: "Currency",
72
+ prop: "currency",
73
+ width: 80,
74
+ align: "right"
75
+ }), r;
76
+ }, L = () => ({
77
+ label: "-"
78
+ }), R = ({ columns: t, data: e, currency: n = "", channel: l = "" }) => {
79
+ if (!e.length || !t.length)
16
80
  return [];
17
- const t = {
81
+ const o = {
18
82
  spend: {
19
83
  prop: "spend",
20
- prefix: p,
21
- format: (o) => window.$fa(o, 2)
84
+ prefix: n,
85
+ format: (s) => window.$fa(s, 2)
22
86
  },
23
87
  taps: {
24
88
  prop: "taps",
25
- format: (o) => window.$fa(o, 0)
89
+ format: (s) => window.$fa(s, 0)
26
90
  },
27
91
  installs: {
28
92
  prop: "installs",
29
- format: (o) => window.$fa(o, 0)
93
+ format: (s) => window.$fa(s, 0)
30
94
  },
31
95
  impressions: {
32
96
  prop: "impressions",
33
- format: (o) => window.$fa(o, 0)
97
+ format: (s) => window.$fa(s, 0)
34
98
  },
35
99
  mmpInstalls: {
36
100
  prop: "mmpInstalls",
37
- format: (o) => window.$fa(o, 0)
101
+ format: (s) => window.$fa(s, 0)
38
102
  },
39
103
  mmpCPI: {
40
104
  prop: "mmpCPI",
41
- format: (o) => window.$fa(o, 2)
105
+ format: (s) => window.$fa(s, 2)
42
106
  },
43
107
  IPM: {
44
108
  prop: "IPM",
45
- format: (o) => window.$fa(o, 2)
109
+ format: (s) => window.$fa(s, 2)
46
110
  },
47
111
  revenue: {
48
112
  prop: "revenue",
49
- format: (o) => window.$fa(o, 2)
113
+ format: (s) => window.$fa(s, 2)
50
114
  }
51
- }, a = [], r = {
115
+ }, r = [], a = {
52
116
  avgCPT: {},
53
117
  avgCPA: {},
54
118
  avgCPM: {},
@@ -58,37 +122,207 @@ const g = (n) => new Promise((l, p) => {
58
122
  mmpInstalls: {},
59
123
  mmpCPI: {}
60
124
  };
61
- n.forEach((o, e) => {
62
- r[o.property] && (r[o.property].i = e);
63
- const c = t[o.property];
64
- if (c) {
65
- c.i = e;
66
- let i = window.$bn(0);
67
- l.forEach((v) => {
68
- i = i.plus(v[o.property] || 0);
69
- }), i = i.toNumber(), c.total = i, a.push(i);
125
+ t.forEach((s, d) => {
126
+ a[s.property] && (a[s.property].i = d);
127
+ const m = o[s.property];
128
+ if (m) {
129
+ m.i = d;
130
+ let g = window.$bn(0);
131
+ e.forEach((w) => {
132
+ g = g.plus(w[s.property] || 0);
133
+ }), g = g.toNumber(), m.total = g, r.push(g);
70
134
  } else
71
- a.push("");
72
- }), Object.keys(t).forEach((o) => {
73
- const e = t[o];
74
- e.format && a[e.i] && (a[e.i] = e.format(a[e.i]));
135
+ r.push("");
136
+ }), Object.keys(o).forEach((s) => {
137
+ const d = o[s];
138
+ d.format && r[d.i] && (r[d.i] = d.format(r[d.i]));
139
+ });
140
+ const c = o.taps.total ? window.$fa(o.spend.total / o.taps.total) : "0.00";
141
+ r[a.avgCPT.i] = c;
142
+ const f = o.installs.total ? window.$fa(o.spend.total / o.installs.total) : "0.00";
143
+ if (r[a.avgCPA.i] = f, a.avgCPM.i !== void 0) {
144
+ const s = o.impressions.total ? window.$fa(o.spend.total / (o.impressions.total / 1e3)) : "0.00";
145
+ r[a.avgCPM.i] = s;
146
+ }
147
+ const p = o.taps.total ? window.$fa(o.installs.total / o.taps.total * 100) : "0.00";
148
+ r[a.cr.i] = p;
149
+ const h = o.impressions.total ? window.$fa(o.taps.total / o.impressions.total * 100) : "0.00";
150
+ r[a.ttr.i] = h;
151
+ const b = o.impressions.total ? window.$fa(o.installs.total * 1e3 / o.impressions.total) : "0.00";
152
+ return r[a.IPM.i] = b, r;
153
+ }, U = (t) => {
154
+ const e = window.$map.asa.allMetric.obj;
155
+ return Object.keys(t).forEach((n) => {
156
+ const l = t[n];
157
+ e[n] && (t[`${n}Format`] = window.$fu({ prop: n, value: l, currency: !1, obj: e }));
158
+ }), t;
159
+ }, F = ({ columns: t, data: e }, n) => t.length && e.length ? t.map((o) => {
160
+ let r = n[o.property] === void 0 ? "" : n[o.property];
161
+ if (r !== "")
162
+ try {
163
+ r = window.$fa(r, window.$map.asa.allMetric.obj[o.property].precision);
164
+ } catch {
165
+ }
166
+ return r;
167
+ }) : [], H = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
168
+ __proto__: null,
169
+ useColumn: I,
170
+ useEmptyColumn: L,
171
+ useFormat: U,
172
+ useRemoteSummary: F,
173
+ useSingleSelect: E,
174
+ useSummary: R
175
+ }, Symbol.toStringTag, { value: "Module" })), B = (t, e = 88) => {
176
+ const n = document.querySelector("html"), { scrollTop: l } = n, o = t.getBoundingClientRect();
177
+ n.scrollTo({
178
+ top: l + o.y - e,
179
+ behavior: "smooth"
75
180
  });
76
- const m = t.taps.total ? window.$fa(t.spend.total / t.taps.total) : "0.00";
77
- a[r.avgCPT.i] = m;
78
- const f = t.installs.total ? window.$fa(t.spend.total / t.installs.total) : "0.00";
79
- if (a[r.avgCPA.i] = f, r.avgCPM.i !== void 0) {
80
- const o = t.impressions.total ? window.$fa(t.spend.total / (t.impressions.total / 1e3)) : "0.00";
81
- a[r.avgCPM.i] = o;
181
+ }, T = async ({ app: t, langs: e, langObj: n }) => new Promise((l) => {
182
+ const o = [];
183
+ e.forEach((i) => {
184
+ i.use && o.push(i);
185
+ }), globalThis.$langs = o;
186
+ let r = {};
187
+ globalThis.$getType(n) === "Object" ? r = n : globalThis.$getType(n) === "String" && (globalThis.$store.common()[n] ? r = globalThis.$store.common()[n] : console.warn(
188
+ `Language object "${n}" not found in store.common()`
189
+ ));
190
+ const a = (i, c) => {
191
+ if (i)
192
+ if (c && globalThis.$getType(c) === "Object") {
193
+ let f = r[i] || i;
194
+ return Object.keys(c).forEach((p) => {
195
+ f[`$${p}$`] = c[p];
196
+ }), f;
197
+ } else
198
+ return r[i] || i;
199
+ else
200
+ return i;
201
+ };
202
+ String.prototype.$l = function() {
203
+ return a(this);
204
+ }, globalThis.$l = a, t.config.globalProperties.$l = a, l();
205
+ }), k = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
206
+ __proto__: null,
207
+ pageScrollTo: B,
208
+ useLang: T
209
+ }, Symbol.toStringTag, { value: "Module" })), u = [];
210
+ let y = 0;
211
+ const $ = function(t) {
212
+ u.forEach((e) => {
213
+ if (e.time === void 0 || e.lastTime === 0 || t - e.lastTime >= e.time) {
214
+ e.cb(t), e.lastTime = t;
215
+ return;
216
+ }
217
+ }), u.length && window.requestAnimationFrame($);
218
+ }, z = function(t, e = 1e3) {
219
+ return y++, u.push({
220
+ cb: t,
221
+ time: e,
222
+ lastTime: 0,
223
+ id: y
224
+ }), u.length === 1 && window.requestAnimationFrame($), y;
225
+ }, q = function(t) {
226
+ for (let e = 0; e < u.length; e++)
227
+ if (u[e].id === t) {
228
+ u.splice(e, 1);
229
+ break;
230
+ }
231
+ }, x = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
232
+ __proto__: null,
233
+ clearRaf: q,
234
+ useRaf: z
235
+ }, Symbol.toStringTag, { value: "Module" })), W = async (t) => {
236
+ if (!document.getElementById("colorfulIcon"))
237
+ return new Promise((e) => {
238
+ const n = document.createElement("script");
239
+ n.id = "colorfulIcon", n.type = "text/javascript", n.src = t || globalThis.config.colorfulIcon, document.head.appendChild(n), e();
240
+ });
241
+ }, G = async (t = {}) => {
242
+ if (!globalThis.$langs)
243
+ return new Promise(async (e) => {
244
+ const { theme: n = "light", currentLang: l, app: o } = t, r = document.documentElement, a = l || localStorage.getItem("lang") || globalThis.config.lang || "en_us";
245
+ r.classList.add(a);
246
+ const i = a.split("_");
247
+ r.setAttribute("lang", `${i[0]}-${i[1].toUpperCase()}`);
248
+ const c = i.includes("ar") ? "rtl" : "ltr";
249
+ if (r.setAttribute("dir", c), r.classList.add(localStorage.getItem("theme") || n), o)
250
+ await T({ app: o, langs: globalThis.config.langs || [] });
251
+ else
252
+ throw new Error(
253
+ "app is not defined, please check your vue app create from createApp() function"
254
+ );
255
+ e();
256
+ });
257
+ }, N = () => {
258
+ if (!globalThis.config)
259
+ throw new Error(
260
+ "globalThis.config is not defined, please create globalThis.config frist"
261
+ );
262
+ const { availWidth: t, availHeight: e } = globalThis.screen, { clientHeight: n } = globalThis.document.body, l = globalThis.config.page.paddingLeft || 32, o = globalThis.config.page.paddingRight || 32, r = t - l - o, a = globalThis.config.page.frameHeader || 82, i = globalThis.config.page.frameFooter || 36, c = n - a - i, f = globalThis.config.page.contentPaddingLeft || 16, p = globalThis.config.page.contentPaddingLeft || 16, h = r - f - p, b = globalThis.config.page.tableHeader || 56, s = globalThis.config.page.tableFooter || 56, d = n - a - b - s, m = globalThis.config.page.drawerHeader || 64, g = n - m, w = globalThis.navigator.userAgent.match(
263
+ /(phone|pad|pod|iPhone|iPod|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
264
+ ) ? "h5" : "pc", P = /iPhone|iPad|iPod/i.test(globalThis.navigator.userAgent);
265
+ return globalThis.config.options = {
266
+ screenWidth: t,
267
+ screenHeight: e,
268
+ pageWidth: r,
269
+ pageHeight: c,
270
+ contentWidth: h,
271
+ tableHeight: d,
272
+ drawerHeight: g,
273
+ device: w,
274
+ isIOS: P
275
+ }, globalThis.config.options;
276
+ }, Q = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
277
+ __proto__: null,
278
+ initColorfulIcon: W,
279
+ initLang: G,
280
+ initOptions: N
281
+ }, Symbol.toStringTag, { value: "Module" })), V = () => {
282
+ const t = document.querySelectorAll(".echart-tooltip");
283
+ t != null && t.length && t.forEach((e) => e.remove());
284
+ }, J = (t) => {
285
+ if (t) {
286
+ const e = document.querySelector(`#${t}`);
287
+ e && (e.style.display = "none");
288
+ } else {
289
+ const e = document.querySelectorAll(".echart-tooltip");
290
+ e != null && e.length && e.forEach((n) => n.remove());
82
291
  }
83
- const w = t.taps.total ? window.$fa(t.installs.total / t.taps.total * 100) : "0.00";
84
- a[r.cr.i] = w;
85
- const d = t.impressions.total ? window.$fa(t.taps.total / t.impressions.total * 100) : "0.00";
86
- a[r.ttr.i] = d;
87
- const u = t.impressions.total ? window.$fa(t.installs.total * 1e3 / t.impressions.total) : "0.00";
88
- return a[r.IPM.i] = u, a;
292
+ }, K = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
293
+ __proto__: null,
294
+ clearEchartTooltip: V,
295
+ hideEchartTooltip: J
296
+ }, Symbol.toStringTag, { value: "Module" })), X = {
297
+ ...M,
298
+ ...C,
299
+ ...H,
300
+ ...k,
301
+ ...x,
302
+ ...Q,
303
+ ...K
89
304
  };
90
305
  export {
91
- $ as d,
92
- g as l,
93
- C as u
306
+ V as clearEchartTooltip,
307
+ q as clearRaf,
308
+ X as default,
309
+ j as download,
310
+ J as hideEchartTooltip,
311
+ W as initColorfulIcon,
312
+ G as initLang,
313
+ N as initOptions,
314
+ A as loadImage,
315
+ O as loadVideo,
316
+ B as pageScrollTo,
317
+ v as useAgeFormat,
318
+ S as useAgeValue,
319
+ I as useColumn,
320
+ L as useEmptyColumn,
321
+ U as useFormat,
322
+ _ as useGenderFormat,
323
+ T as useLang,
324
+ z as useRaf,
325
+ F as useRemoteSummary,
326
+ E as useSingleSelect,
327
+ R as useSummary
94
328
  };