magtool 1.5.18 → 1.5.19

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 n, l;
3
+ let o, l;
4
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";
5
+ const { minAge: n, maxAge: r } = e.included[0] || {};
6
+ n ? o = n : o = "all", r ? l = r : l = "all";
7
7
  }
8
- return l === "all" ? n === "all" ? "All" : `${n}~65+` : `${n}~${l}`;
8
+ return l === "all" ? o === "all" ? "All" : `${o}~65+` : `${o}~${l}`;
9
9
  }, S = (t, e) => t === "all" ? null : e === 65 ? {
10
10
  included: [
11
11
  {
@@ -22,42 +22,59 @@ const v = (t) => {
22
22
  }, _ = (t) => {
23
23
  const { gender: e } = t || {};
24
24
  return e != null && e.included ? e.included[0] : null;
25
- }, M = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
25
+ }, E = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
26
26
  __proto__: null,
27
27
  useAgeFormat: v,
28
28
  useAgeValue: S,
29
29
  useGenderFormat: _
30
- }, Symbol.toStringTag, { value: "Module" })), A = (t) => new Promise((e, n) => {
30
+ }, Symbol.toStringTag, { value: "Module" })), M = (t) => new Promise((e, o) => {
31
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) => {
32
+ l.src = window.$getType(t) === "String" ? t : URL.createObjectURL(t), l.onload = () => e(l), l.onerror = () => o(new Error("Could not load image"));
33
+ }), O = (t) => new Promise((e, o) => {
34
34
  const l = document.createElement("video");
35
35
  l.preload = "metadata", window.$getType(t) === "String" ? l.src = t : l.src = URL.createObjectURL(t), l.onloadedmetadata = () => {
36
36
  window.URL.revokeObjectURL(t), e(l);
37
37
  };
38
- }), j = ({ type: t = "csv", data: e, name: n }) => {
39
- let l = document.createElement("a");
38
+ }), j = async ({
39
+ type: t,
40
+ url: e,
41
+ headers: o,
42
+ data: l,
43
+ name: n,
44
+ error: r = () => {
45
+ }
46
+ }) => {
47
+ let a = document.createElement("a");
40
48
  if (t === "csv") {
41
- const r = new Blob(["\uFEFF" + e], {
49
+ if (!l)
50
+ throw r(), new Error("data is null");
51
+ const c = new Blob(["\uFEFF" + l], {
42
52
  type: "text/csv,charset=UTF-8"
43
53
  });
44
- l.href = URL.createObjectURL(r);
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);
45
62
  }
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({
63
+ let i = new MouseEvent("click");
64
+ a.download = n || "download", a.dispatchEvent(i), URL.revokeObjectURL(a.url), a = null, i = null;
65
+ }, A = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
49
66
  __proto__: null,
50
67
  download: j,
51
- loadImage: A,
68
+ loadImage: M,
52
69
  loadVideo: O
53
- }, Symbol.toStringTag, { value: "Module" })), E = ({ table: t, key: e, form: n, value: l, cb: o = () => {
70
+ }, Symbol.toStringTag, { value: "Module" })), L = ({ table: t, key: e, form: o, value: l, cb: n = () => {
54
71
  } }) => {
55
72
  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) => ({
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) => ({
61
78
  label: a.label,
62
79
  prop: a.value,
63
80
  width: a.width,
@@ -73,15 +90,15 @@ const v = (t) => {
73
90
  width: 80,
74
91
  align: "right"
75
92
  }), r;
76
- }, L = () => ({
93
+ }, I = () => ({
77
94
  label: "-"
78
- }), R = ({ columns: t, data: e, currency: n = "", channel: l = "" }) => {
95
+ }), R = ({ columns: t, data: e, currency: o = "", channel: l = "" }) => {
79
96
  if (!e.length || !t.length)
80
97
  return [];
81
- const o = {
98
+ const n = {
82
99
  spend: {
83
100
  prop: "spend",
84
- prefix: n,
101
+ prefix: o,
85
102
  format: (s) => window.$fa(s, 2)
86
103
  },
87
104
  taps: {
@@ -124,76 +141,76 @@ const v = (t) => {
124
141
  };
125
142
  t.forEach((s, d) => {
126
143
  a[s.property] && (a[s.property].i = d);
127
- const m = o[s.property];
144
+ const m = n[s.property];
128
145
  if (m) {
129
146
  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);
147
+ let f = window.$bn(0);
148
+ e.forEach((b) => {
149
+ f = f.plus(b[s.property] || 0);
150
+ }), f = f.toNumber(), m.total = f, r.push(f);
134
151
  } else
135
152
  r.push("");
136
- }), Object.keys(o).forEach((s) => {
137
- const d = o[s];
153
+ }), Object.keys(n).forEach((s) => {
154
+ const d = n[s];
138
155
  d.format && r[d.i] && (r[d.i] = d.format(r[d.i]));
139
156
  });
140
- const c = o.taps.total ? window.$fa(o.spend.total / o.taps.total) : "0.00";
157
+ const c = n.taps.total ? window.$fa(n.spend.total / n.taps.total) : "0.00";
141
158
  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";
159
+ 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) {
161
+ const s = n.impressions.total ? window.$fa(n.spend.total / (n.impressions.total / 1e3)) : "0.00";
145
162
  r[a.avgCPM.i] = s;
146
163
  }
147
- const p = o.taps.total ? window.$fa(o.installs.total / o.taps.total * 100) : "0.00";
164
+ const p = n.taps.total ? window.$fa(n.installs.total / n.taps.total * 100) : "0.00";
148
165
  r[a.cr.i] = p;
149
- const h = o.impressions.total ? window.$fa(o.taps.total / o.impressions.total * 100) : "0.00";
166
+ const h = n.impressions.total ? window.$fa(n.taps.total / n.impressions.total * 100) : "0.00";
150
167
  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;
168
+ const w = n.impressions.total ? window.$fa(n.installs.total * 1e3 / n.impressions.total) : "0.00";
169
+ return r[a.IPM.i] = w, r;
153
170
  }, U = (t) => {
154
171
  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 }));
172
+ 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 }));
158
175
  }), 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];
176
+ }, F = ({ columns: t, data: e }, o) => t.length && e.length ? t.map((n) => {
177
+ let r = o[n.property] === void 0 ? "" : o[n.property];
161
178
  if (r !== "")
162
179
  try {
163
- r = window.$fa(r, window.$map.asa.allMetric.obj[o.property].precision);
180
+ r = window.$fa(r, window.$map.asa.allMetric.obj[n.property].precision);
164
181
  } catch {
165
182
  }
166
183
  return r;
167
184
  }) : [], H = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
168
185
  __proto__: null,
169
- useColumn: I,
170
- useEmptyColumn: L,
186
+ useColumn: C,
187
+ useEmptyColumn: I,
171
188
  useFormat: U,
172
189
  useRemoteSummary: F,
173
- useSingleSelect: E,
190
+ useSingleSelect: L,
174
191
  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,
192
+ }, Symbol.toStringTag, { value: "Module" })), x = (t, e = 88) => {
193
+ const o = document.querySelector("html"), { scrollTop: l } = o, n = t.getBoundingClientRect();
194
+ o.scrollTo({
195
+ top: l + n.y - e,
179
196
  behavior: "smooth"
180
197
  });
181
- }, T = async ({ app: t, langs: e, langObj: n }) => new Promise((l) => {
182
- const o = [];
198
+ }, T = async ({ app: t, langs: e, langObj: o }) => new Promise((l) => {
199
+ const n = [];
183
200
  e.forEach((i) => {
184
- i.use && o.push(i);
185
- }), globalThis.$langs = o;
201
+ i.use && n.push(i);
202
+ }), globalThis.$langs = n;
186
203
  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()`
204
+ globalThis.$getType(o) === "Object" ? r = o : globalThis.$getType(o) === "String" && (globalThis.$store.common()[o] ? r = globalThis.$store.common()[o] : console.warn(
205
+ `Language object "${o}" not found in store.common()`
189
206
  ));
190
207
  const a = (i, c) => {
191
208
  if (i)
192
209
  if (c && globalThis.$getType(c) === "Object") {
193
- let f = r[i] || i;
210
+ let g = r[i] || i;
194
211
  return Object.keys(c).forEach((p) => {
195
- f[`$${p}$`] = c[p];
196
- }), f;
212
+ g[`$${p}$`] = c[p];
213
+ }), g;
197
214
  } else
198
215
  return r[i] || i;
199
216
  else
@@ -202,9 +219,9 @@ const v = (t) => {
202
219
  String.prototype.$l = function() {
203
220
  return a(this);
204
221
  }, globalThis.$l = a, t.config.globalProperties.$l = a, l();
205
- }), k = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
222
+ }), B = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
206
223
  __proto__: null,
207
- pageScrollTo: B,
224
+ pageScrollTo: x,
208
225
  useLang: T
209
226
  }, Symbol.toStringTag, { value: "Module" })), u = [];
210
227
  let y = 0;
@@ -215,39 +232,39 @@ const $ = function(t) {
215
232
  return;
216
233
  }
217
234
  }), u.length && window.requestAnimationFrame($);
218
- }, z = function(t, e = 1e3) {
235
+ }, k = function(t, e = 1e3) {
219
236
  return y++, u.push({
220
237
  cb: t,
221
238
  time: e,
222
239
  lastTime: 0,
223
240
  id: y
224
241
  }), u.length === 1 && window.requestAnimationFrame($), y;
225
- }, q = function(t) {
242
+ }, z = function(t) {
226
243
  for (let e = 0; e < u.length; e++)
227
244
  if (u[e].id === t) {
228
245
  u.splice(e, 1);
229
246
  break;
230
247
  }
231
- }, x = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
248
+ }, q = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
232
249
  __proto__: null,
233
- clearRaf: q,
234
- useRaf: z
250
+ clearRaf: z,
251
+ useRaf: k
235
252
  }, Symbol.toStringTag, { value: "Module" })), W = async (t) => {
236
253
  if (!document.getElementById("colorfulIcon"))
237
254
  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();
255
+ const o = document.createElement("script");
256
+ o.id = "colorfulIcon", o.type = "text/javascript", o.src = t || globalThis.config.colorfulIcon, document.head.appendChild(o), e();
240
257
  });
241
258
  }, G = async (t = {}) => {
242
259
  if (!globalThis.$langs)
243
260
  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";
261
+ const { theme: o = "light", currentLang: l, app: n } = t, r = document.documentElement, a = l || localStorage.getItem("lang") || globalThis.config.lang || "en_us";
245
262
  r.classList.add(a);
246
263
  const i = a.split("_");
247
264
  r.setAttribute("lang", `${i[0]}-${i[1].toUpperCase()}`);
248
265
  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 || [] });
266
+ if (r.setAttribute("dir", c), r.classList.add(localStorage.getItem("theme") || o), n)
267
+ await T({ app: n, langs: globalThis.config.langs || [] });
251
268
  else
252
269
  throw new Error(
253
270
  "app is not defined, please check your vue app create from createApp() function"
@@ -259,7 +276,7 @@ const $ = function(t) {
259
276
  throw new Error(
260
277
  "globalThis.config is not defined, please create globalThis.config frist"
261
278
  );
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(
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(
263
280
  /(phone|pad|pod|iPhone|iPod|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i
264
281
  ) ? "h5" : "pc", P = /iPhone|iPad|iPod/i.test(globalThis.navigator.userAgent);
265
282
  return globalThis.config.options = {
@@ -269,8 +286,8 @@ const $ = function(t) {
269
286
  pageHeight: c,
270
287
  contentWidth: h,
271
288
  tableHeight: d,
272
- drawerHeight: g,
273
- device: w,
289
+ drawerHeight: f,
290
+ device: b,
274
291
  isIOS: P
275
292
  }, globalThis.config.options;
276
293
  }, Q = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -287,42 +304,42 @@ const $ = function(t) {
287
304
  e && (e.style.display = "none");
288
305
  } else {
289
306
  const e = document.querySelectorAll(".echart-tooltip");
290
- e != null && e.length && e.forEach((n) => n.remove());
307
+ e != null && e.length && e.forEach((o) => o.remove());
291
308
  }
292
309
  }, K = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
293
310
  __proto__: null,
294
311
  clearEchartTooltip: V,
295
312
  hideEchartTooltip: J
296
313
  }, Symbol.toStringTag, { value: "Module" })), X = {
297
- ...M,
298
- ...C,
314
+ ...E,
315
+ ...A,
299
316
  ...H,
300
- ...k,
301
- ...x,
317
+ ...B,
318
+ ...q,
302
319
  ...Q,
303
320
  ...K
304
321
  };
305
322
  export {
306
323
  V as clearEchartTooltip,
307
- q as clearRaf,
324
+ z as clearRaf,
308
325
  X as default,
309
326
  j as download,
310
327
  J as hideEchartTooltip,
311
328
  W as initColorfulIcon,
312
329
  G as initLang,
313
330
  N as initOptions,
314
- A as loadImage,
331
+ M as loadImage,
315
332
  O as loadVideo,
316
- B as pageScrollTo,
333
+ x as pageScrollTo,
317
334
  v as useAgeFormat,
318
335
  S as useAgeValue,
319
- I as useColumn,
320
- L as useEmptyColumn,
336
+ C as useColumn,
337
+ I as useEmptyColumn,
321
338
  U as useFormat,
322
339
  _ as useGenderFormat,
323
340
  T as useLang,
324
- z as useRaf,
341
+ k as useRaf,
325
342
  F as useRemoteSummary,
326
- E as useSingleSelect,
343
+ L as useSingleSelect,
327
344
  R as useSummary
328
345
  };