magtool 1.5.29 → 1.5.31

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,11 +1,11 @@
1
1
  const v = (t) => {
2
2
  const { age: e } = t || {};
3
- let o, l;
3
+ let o, a;
4
4
  if (e != null && e.included) {
5
5
  const { minAge: n, maxAge: r } = e.included[0] || {};
6
- n ? o = n : o = "all", r ? l = r : l = "all";
6
+ n ? o = n : o = "all", r ? a = r : a = "all";
7
7
  }
8
- return l === "all" ? o === "all" ? "All" : `${o}~65+` : `${o}~${l}`;
8
+ return a === "all" ? o === "all" ? "All" : `${o}~65+` : `${o}~${a}`;
9
9
  }, S = (t, e) => t === "all" ? null : e === 65 ? {
10
10
  included: [
11
11
  {
@@ -28,61 +28,64 @@ const v = (t) => {
28
28
  useAgeValue: S,
29
29
  useGenderFormat: _
30
30
  }, Symbol.toStringTag, { value: "Module" })), M = (t) => new Promise((e, o) => {
31
- const l = new Image();
32
- l.src = window.$getType(t) === "String" ? t : URL.createObjectURL(t), l.onload = () => e(l), l.onerror = () => o(new Error("Could not load image"));
31
+ const a = new Image();
32
+ a.src = window.$getType(t) === "String" ? t : URL.createObjectURL(t), a.onload = () => e(a), a.onerror = () => o(new Error("Could not load image"));
33
33
  }), O = (t) => new Promise((e, o) => {
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);
34
+ const a = document.createElement("video");
35
+ a.preload = "metadata", window.$getType(t) === "String" ? a.src = t : a.src = URL.createObjectURL(t), a.onloadedmetadata = () => {
36
+ window.URL.revokeObjectURL(t), e(a);
37
37
  };
38
38
  }), j = async ({
39
39
  type: t,
40
40
  url: e,
41
41
  headers: o,
42
- data: l,
42
+ data: a,
43
43
  name: n,
44
44
  error: r = () => {
45
45
  }
46
46
  }) => {
47
- let a = document.createElement("a");
48
- if (t === "csv") {
49
- if (!l)
50
- throw r(), new Error("data is null");
51
- const c = new Blob(["\uFEFF" + l], {
52
- type: "text/csv,charset=UTF-8"
53
- });
54
- a.href = URL.createObjectURL(c);
55
- } else if (t === "excel") {
56
- const c = await fetch(e, {
57
- headers: o
58
- }).then((g) => g.blob());
59
- if (!(c != null && c.type.includes("sheet")))
60
- throw r(), new Error("excel does not exist");
61
- a.href = URL.createObjectURL(c);
47
+ let l = document.createElement("a"), i = null;
48
+ try {
49
+ if (t === "csv") {
50
+ if (!a)
51
+ throw r(), new Error("data is null");
52
+ const c = new Blob(["\uFEFF" + a], {
53
+ type: "text/csv,charset=UTF-8"
54
+ });
55
+ l.href = URL.createObjectURL(c);
56
+ } else if (t === "excel") {
57
+ const c = await fetch(e, {
58
+ headers: o
59
+ }).then((g) => g.blob());
60
+ if (!(c != null && c.type.includes("sheet")))
61
+ throw r(), new Error("excel does not exist");
62
+ l.href = URL.createObjectURL(c);
63
+ }
64
+ i = new MouseEvent("click"), l.download = n || "download", l.dispatchEvent(i), URL.revokeObjectURL(l.url);
65
+ } finally {
66
+ l && l.parentNode && l.parentNode.removeChild(l), l = null, i = null;
62
67
  }
63
- let i = new MouseEvent("click");
64
- a.download = n || "download", a.dispatchEvent(i), URL.revokeObjectURL(a.url), a = null, i = null;
65
68
  }, A = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
66
69
  __proto__: null,
67
70
  download: j,
68
71
  loadImage: M,
69
72
  loadVideo: O
70
- }, Symbol.toStringTag, { value: "Module" })), L = ({ table: t, key: e, form: o, value: l, cb: n = () => {
73
+ }, Symbol.toStringTag, { value: "Module" })), C = ({ table: t, key: e, form: o, value: a, cb: n = () => {
71
74
  } }) => {
72
75
  const r = t.getSelectionRows();
73
- r.length > 1 ? (t.clearSelection(), t.toggleRowSelection(r[1], "selected"), o[l] = r[1][e]) : r.length === 1 && (o[l] = r[0][e]), n();
74
- }, C = (t = {}) => {
75
- let { sortable: e = !0, empty: o = !1, mmp: l = !1 } = t, n = window.$map.asa.asaMetric.all;
76
- l && (n = n.concat(window.$map.asa.mmpMetric.all));
77
- const r = n.map((a, i) => ({
78
- label: a.label,
79
- prop: a.value,
80
- width: a.width,
76
+ r.length > 1 ? (t.clearSelection(), t.toggleRowSelection(r[1], "selected"), o[a] = r[1][e]) : r.length === 1 && (o[a] = r[0][e]), n();
77
+ }, L = (t = {}) => {
78
+ let { sortable: e = !0, empty: o = !1, mmp: a = !1 } = t, n = window.$map.asa.asaMetric.all;
79
+ a && (n = n.concat(window.$map.asa.mmpMetric.all));
80
+ const r = n.map((l, i) => ({
81
+ label: l.label,
82
+ prop: l.value,
83
+ width: l.width,
81
84
  sortable: e,
82
- type: a.type,
83
- align: a.align,
84
- visible: a.visible,
85
- formatter: a.formatter
85
+ type: l.type,
86
+ align: l.align,
87
+ visible: l.visible,
88
+ formatter: l.formatter
86
89
  }));
87
90
  return r.unshift({
88
91
  label: "Currency",
@@ -92,7 +95,7 @@ const v = (t) => {
92
95
  }), r;
93
96
  }, I = () => ({
94
97
  label: "-"
95
- }), R = ({ columns: t, data: e, currency: o = "", channel: l = "" }) => {
98
+ }), R = ({ columns: t, data: e, currency: o = "", channel: a = "" }) => {
96
99
  if (!e.length || !t.length)
97
100
  return [];
98
101
  const n = {
@@ -129,7 +132,7 @@ const v = (t) => {
129
132
  prop: "revenue",
130
133
  format: (s) => window.$fa(s, 2)
131
134
  }
132
- }, r = [], a = {
135
+ }, r = [], l = {
133
136
  avgCPT: {},
134
137
  avgCPA: {},
135
138
  avgCPM: {},
@@ -140,7 +143,7 @@ const v = (t) => {
140
143
  mmpCPI: {}
141
144
  };
142
145
  t.forEach((s, d) => {
143
- a[s.property] && (a[s.property].i = d);
146
+ l[s.property] && (l[s.property].i = d);
144
147
  const m = n[s.property];
145
148
  if (m) {
146
149
  m.i = d;
@@ -155,23 +158,23 @@ const v = (t) => {
155
158
  d.format && r[d.i] && (r[d.i] = d.format(r[d.i]));
156
159
  });
157
160
  const c = n.taps.total ? window.$fa(n.spend.total / n.taps.total) : "0.00";
158
- r[a.avgCPT.i] = c;
161
+ r[l.avgCPT.i] = c;
159
162
  const g = n.installs.total ? window.$fa(n.spend.total / n.installs.total) : "0.00";
160
- if (r[a.avgCPA.i] = g, a.avgCPM.i !== void 0) {
163
+ if (r[l.avgCPA.i] = g, l.avgCPM.i !== void 0) {
161
164
  const s = n.impressions.total ? window.$fa(n.spend.total / (n.impressions.total / 1e3)) : "0.00";
162
- r[a.avgCPM.i] = s;
165
+ r[l.avgCPM.i] = s;
163
166
  }
164
167
  const p = n.taps.total ? window.$fa(n.installs.total / n.taps.total * 100) : "0.00";
165
- r[a.cr.i] = p;
168
+ r[l.cr.i] = p;
166
169
  const h = n.impressions.total ? window.$fa(n.taps.total / n.impressions.total * 100) : "0.00";
167
- r[a.ttr.i] = h;
170
+ r[l.ttr.i] = h;
168
171
  const w = n.impressions.total ? window.$fa(n.installs.total * 1e3 / n.impressions.total) : "0.00";
169
- return r[a.IPM.i] = w, r;
172
+ return r[l.IPM.i] = w, r;
170
173
  }, U = (t) => {
171
174
  const e = window.$map.asa.allMetric.obj;
172
175
  return Object.keys(t).forEach((o) => {
173
- const l = t[o];
174
- e[o] && (t[`${o}Format`] = window.$fu({ prop: o, value: l, currency: !1, obj: e }));
176
+ const a = t[o];
177
+ e[o] && (t[`${o}Format`] = window.$fu({ prop: o, value: a, currency: !1, obj: e }));
175
178
  }), t;
176
179
  }, F = ({ columns: t, data: e }, o) => t.length && e.length ? t.map((n) => {
177
180
  let r = o[n.property] === void 0 ? "" : o[n.property];
@@ -183,19 +186,19 @@ const v = (t) => {
183
186
  return r;
184
187
  }) : [], H = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
185
188
  __proto__: null,
186
- useColumn: C,
189
+ useColumn: L,
187
190
  useEmptyColumn: I,
188
191
  useFormat: U,
189
192
  useRemoteSummary: F,
190
- useSingleSelect: L,
193
+ useSingleSelect: C,
191
194
  useSummary: R
192
- }, Symbol.toStringTag, { value: "Module" })), x = (t, e = 88) => {
193
- const o = document.querySelector("html"), { scrollTop: l } = o, n = t.getBoundingClientRect();
195
+ }, Symbol.toStringTag, { value: "Module" })), x = (t, e = 96) => {
196
+ const o = document.querySelector("html"), { scrollTop: a } = o, n = t.getBoundingClientRect();
194
197
  o.scrollTo({
195
- top: l + n.y - e,
198
+ top: a + n.y - e,
196
199
  behavior: "smooth"
197
200
  });
198
- }, T = async ({ app: t, langs: e, langObj: o }) => new Promise((l) => {
201
+ }, T = async ({ app: t, langs: e, langObj: o }) => new Promise((a) => {
199
202
  const n = [];
200
203
  e.forEach((i) => {
201
204
  i.use && n.push(i);
@@ -204,7 +207,7 @@ const v = (t) => {
204
207
  globalThis.$getType(o) === "Object" ? r = o : globalThis.$getType(o) === "String" && (globalThis.$store.common()[o] ? r = globalThis.$store.common()[o] : console.warn(
205
208
  `Language object "${o}" not found in store.common()`
206
209
  ));
207
- const a = (i, c) => {
210
+ const l = (i, c) => {
208
211
  if (i)
209
212
  if (c && globalThis.$getType(c) === "Object") {
210
213
  let g = r[i] || i;
@@ -217,8 +220,8 @@ const v = (t) => {
217
220
  return i;
218
221
  };
219
222
  String.prototype.$l = function() {
220
- return a(this);
221
- }, globalThis.$l = a, t.config.globalProperties.$l = a, l();
223
+ return l(this);
224
+ }, globalThis.$l = l, t.config.globalProperties.$l = l, a();
222
225
  }), B = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
223
226
  __proto__: null,
224
227
  pageScrollTo: x,
@@ -255,12 +258,12 @@ const $ = function(t) {
255
258
  const o = document.createElement("script");
256
259
  o.id = "colorfulIcon", o.type = "text/javascript", o.src = t || globalThis.config.colorfulIcon, document.head.appendChild(o), e();
257
260
  });
258
- }, G = async (t = {}) => {
261
+ }, N = async (t = {}) => {
259
262
  if (!globalThis.$langs)
260
263
  return new Promise(async (e) => {
261
- const { theme: o = "light", currentLang: l, app: n } = t, r = document.documentElement, a = l || localStorage.getItem("lang") || globalThis.config.lang || "en_us";
262
- r.classList.add(a);
263
- const i = a.split("_");
264
+ const { theme: o = "light", currentLang: a, app: n } = t, r = document.documentElement, l = a || localStorage.getItem("lang") || globalThis.config.lang || "en_us";
265
+ r.classList.add(l);
266
+ const i = l.split("_");
264
267
  r.setAttribute("lang", `${i[0]}-${i[1].toUpperCase()}`);
265
268
  const c = i.includes("ar") ? "rtl" : "ltr";
266
269
  if (r.setAttribute("dir", c), r.classList.add(localStorage.getItem("theme") || o), n)
@@ -271,12 +274,12 @@ const $ = function(t) {
271
274
  );
272
275
  e();
273
276
  });
274
- }, N = () => {
277
+ }, G = () => {
275
278
  if (!globalThis.config)
276
279
  throw new Error(
277
280
  "globalThis.config is not defined, please create globalThis.config frist"
278
281
  );
279
- const { availWidth: t, availHeight: e } = globalThis.screen, { clientHeight: o } = globalThis.document.body, l = globalThis.config.page.paddingLeft || 32, n = globalThis.config.page.paddingRight || 32, r = t - l - n, a = globalThis.config.page.frameHeader || 82, i = globalThis.config.page.frameFooter || 36, c = o - a - i, g = globalThis.config.page.contentPaddingLeft || 16, p = globalThis.config.page.contentPaddingLeft || 16, h = r - g - p, w = globalThis.config.page.tableHeader || 56, s = globalThis.config.page.tableFooter || 56, d = o - a - w - s, m = globalThis.config.page.drawerHeader || 64, f = o - m, b = globalThis.navigator.userAgent.match(
282
+ const { availWidth: t, availHeight: e } = globalThis.screen, { clientHeight: o } = globalThis.document.body, a = globalThis.config.page.paddingLeft || 32, n = globalThis.config.page.paddingRight || 32, r = t - a - n, l = globalThis.config.page.frameHeader || 82, i = globalThis.config.page.frameFooter || 36, c = o - l - i, g = globalThis.config.page.contentPaddingLeft || 16, p = globalThis.config.page.contentPaddingLeft || 16, h = r - g - p, w = globalThis.config.page.tableHeader || 56, s = globalThis.config.page.tableFooter || 56, d = o - l - w - s, m = globalThis.config.page.drawerHeader || 64, f = o - m, b = globalThis.navigator.userAgent.match(
280
283
  /(phone|pad|pod|iPhone|iPod|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
281
284
  ) ? "h5" : "pc", P = /iPhone|iPad|iPod/i.test(globalThis.navigator.userAgent);
282
285
  return globalThis.config.options = {
@@ -293,8 +296,8 @@ const $ = function(t) {
293
296
  }, Q = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
294
297
  __proto__: null,
295
298
  initColorfulIcon: W,
296
- initLang: G,
297
- initOptions: N
299
+ initLang: N,
300
+ initOptions: G
298
301
  }, Symbol.toStringTag, { value: "Module" })), V = () => {
299
302
  const t = document.querySelectorAll(".echart-tooltip");
300
303
  t != null && t.length && t.forEach((e) => e.remove());
@@ -326,20 +329,20 @@ export {
326
329
  j as download,
327
330
  J as hideEchartTooltip,
328
331
  W as initColorfulIcon,
329
- G as initLang,
330
- N as initOptions,
332
+ N as initLang,
333
+ G as initOptions,
331
334
  M as loadImage,
332
335
  O as loadVideo,
333
336
  x as pageScrollTo,
334
337
  v as useAgeFormat,
335
338
  S as useAgeValue,
336
- C as useColumn,
339
+ L as useColumn,
337
340
  I as useEmptyColumn,
338
341
  U as useFormat,
339
342
  _ as useGenderFormat,
340
343
  T as useLang,
341
344
  k as useRaf,
342
345
  F as useRemoteSummary,
343
- L as useSingleSelect,
346
+ C as useSingleSelect,
344
347
  R as useSummary
345
348
  };