magtool 1.2.9 → 1.3.1

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.
Files changed (2) hide show
  1. package/dist/util.js +118 -115
  2. package/package.json +2 -2
package/dist/util.js CHANGED
@@ -1,7 +1,9 @@
1
- const A = (a) => {
2
- window.$getLang = () => localStorage.getItem("lang"), window.token = "WQpvrYIEnSzAxhOWrbUpGvElhGztdOjOGOdbrSlhUYlrQArOdpMhY1vYMSA7l4xMOUl9MAl1I6AvSrQ8vlE0bpChQ0UWMMlYt0hQC0M0pSz0rUhvlIllSWzMESnAMUlt", window.$md5 = (e) => e.match(/\d+(\.\d+)?/g).join("");
3
- const f = (e = {}) => {
4
- const { alpha: r, name: o } = e, t = [
1
+ const I = (a) => {
2
+ window.$getLang = () => localStorage.getItem("lang") || "en_us", window.token = "WQpvrYIEnSzAxhOWrbUpGvElhGztdOjOGOdbrSlhUYlrQArOdpMhY1vYMSA7l4xMOUl9MAl1I6AvSrQ8vlE0bpChQ0UWMMlYt0hQC0M0pSz0rUhvlIllSWzMESnAMUlt";
3
+ const k = (e) => Number(e.match(/\d+(\.\d+)?/g).join(""));
4
+ window.$md5 = (e) => k(e);
5
+ const u = (e = {}) => {
6
+ const { alpha: t, name: o } = e, r = [
5
7
  "blue",
6
8
  "red",
7
9
  "orange",
@@ -11,18 +13,18 @@ const A = (a) => {
11
13
  "purple",
12
14
  "primary",
13
15
  "dark"
14
- ], n = ["", 1, 3, 5, 7], c = o || t[parseInt(Math.random() * t.length)], s = r === 0 ? "" : n[parseInt(Math.random() * n.length)];
15
- return `${c}${s}`;
16
+ ], n = ["", 1, 3, 5, 7], c = o || r[parseInt(Math.random() * r.length)], i = t === 0 ? "" : n[parseInt(Math.random() * n.length)];
17
+ return `${c}${i}`;
16
18
  };
17
- window.$randomColor = f, window.$rc = f, a.config.globalProperties.$rc = f;
18
- const k = (e, r = 0) => {
19
+ window.$rc = u, a.config.globalProperties.$rc = u;
20
+ const U = (e, t = 0) => {
19
21
  let o = parseInt(Math.random() * e);
20
- return o += r, o;
22
+ return o += t, o;
21
23
  };
22
- window.$rn = k, window.$elc = (e = {}) => {
23
- let { i: r = 0, color: o } = e;
24
- const t = window.global.config.color;
25
- o = o || t[r];
24
+ window.$rn = U, window.$elc = (e = {}) => {
25
+ let { i: t = 0, color: o } = e;
26
+ const r = window.global.config.color;
27
+ o = o || r[t];
26
28
  const n = o + "FF", c = o + "00";
27
29
  return {
28
30
  type: "linear",
@@ -42,9 +44,9 @@ const A = (a) => {
42
44
  ]
43
45
  };
44
46
  }, window.$egc = (e = {}) => {
45
- let { i: r = 0, color: o } = e;
46
- const t = window.config.color;
47
- o = o || t[r];
47
+ let { i: t = 0, color: o } = e;
48
+ const r = window.config.color;
49
+ o = o || r[t];
48
50
  const n = o + "FF";
49
51
  return {
50
52
  type: "radial",
@@ -63,62 +65,62 @@ const A = (a) => {
63
65
  ]
64
66
  };
65
67
  };
66
- const F = (e, r) => {
68
+ const O = (e, t) => {
67
69
  let o = [];
68
- for (let t = 0; t < e; t++)
69
- o.push(r(t));
70
+ for (let r = 0; r < e; r++)
71
+ o.push(t(r));
70
72
  return o;
71
73
  };
72
- window.$fd = F, a.config.globalProperties.$setTimeout = function(e = () => {
73
- }, r) {
74
+ window.$fd = O, a.config.globalProperties.$setTimeout = function(e = () => {
75
+ }, t) {
74
76
  this.timer && (clearTimeout(this.timer), this.timer = null), this.timer = setTimeout(() => {
75
77
  e(), clearTimeout(this.timer);
76
- }, r);
78
+ }, t);
77
79
  };
78
- const u = (e) => e.substr(0, 1).toUpperCase() + e.substr(1, e.length).toLowerCase();
79
- a.config.globalProperties.$toUpperCamel = u, window.$toUpperCamel = u;
80
- const p = (e, r = 2) => {
80
+ const w = (e) => e.substr(0, 1).toUpperCase() + e.substr(1, e.length).toLowerCase();
81
+ a.config.globalProperties.$toUpperCamel = w, window.$toUpperCamel = w;
82
+ const p = (e, t = 2) => {
81
83
  const o = window.$getType(e);
82
- let t;
83
- o === "Number" ? (e = e.toFixed(r), t = String(e), e = String(Math.abs(e))) : o === "String" && (t = e, e = String(Math.abs(Number(e))));
84
+ let r;
85
+ o === "Number" ? (e = e.toFixed(t), r = String(e), e = String(Math.abs(e))) : o === "String" && (r = e, e = String(Math.abs(Number(e))));
84
86
  const n = e.split(".");
85
87
  let c = n[0].split("");
86
88
  c = c.reverse();
87
- let s = [];
88
- c.forEach((P, U) => {
89
- U !== 0 && U % 3 === 0 && s.push(","), s.push(P);
89
+ let i = [];
90
+ c.forEach((A, h) => {
91
+ h !== 0 && h % 3 === 0 && i.push(","), i.push(A);
90
92
  });
91
- let d = s.reverse().join("");
92
- return window.$getType(r) === "Number" && r > 0 && (d += ".", n[1] ? d += n[1].padEnd(r, 0).substr(0, r) : d += "0".padEnd(r, "0")), Number(t) !== Number(e) ? `-${d}` : d;
93
+ let s = i.reverse().join("");
94
+ return window.$getType(t) === "Number" && t > 0 && (s += ".", n[1] ? s += n[1].padEnd(t, 0).substr(0, t) : s += "0".padEnd(t, "0")), Number(r) !== Number(e) ? `-${s}` : s;
93
95
  };
94
96
  window.$fa = p, a.config.globalProperties.$fa = p;
95
97
  const m = ({
96
98
  prop: e,
97
- currency: r,
99
+ currency: t,
98
100
  value: o,
99
- obj: t = window.$map.asa.asaMetric.allObj
101
+ obj: r = window.$map.asa.asaMetric.allObj
100
102
  }) => {
101
- const n = t[e];
102
- return n.unit === "currency" ? r ? `${r} ${window.$fa(o, n == null ? void 0 : n.precision)}` : window.$fa(o, n == null ? void 0 : n.precision) : n.unit === "%" ? `${window.$fa(o, n == null ? void 0 : n.precision)}%` : window.$fa(o, n == null ? void 0 : n.precision);
103
+ const n = r[e];
104
+ return n.unit === "currency" ? t ? `${t} ${window.$fa(o, n == null ? void 0 : n.precision)}` : window.$fa(o, n == null ? void 0 : n.precision) : n.unit === "%" ? `${window.$fa(o, n == null ? void 0 : n.precision)}%` : window.$fa(o, n == null ? void 0 : n.precision);
103
105
  };
104
106
  window.$fu2 = m, a.config.globalProperties.$fu2 = m;
105
107
  const g = (e = () => {
106
- }, r = 2) => {
108
+ }, t = 2) => {
107
109
  let o = null;
108
- return new Promise((t, n) => {
110
+ return new Promise((r, n) => {
109
111
  o = setTimeout(() => {
110
- e(t, n), clearTimeout(o), t(!0);
111
- }, r * 100);
112
+ e(r, n), clearTimeout(o), r(!0);
113
+ }, t * 100);
112
114
  });
113
115
  };
114
116
  window.$pm = g, window.$promise = g;
115
117
  const b = (e = () => {
116
- }, r = 500) => {
118
+ }, t = 500) => {
117
119
  let o;
118
- return function(...t) {
120
+ return function(...r) {
119
121
  o && clearTimeout(o), o = setTimeout(() => {
120
- e.apply(this, t);
121
- }, r);
122
+ e.apply(this, r);
123
+ }, t);
122
124
  };
123
125
  };
124
126
  window.$db = b, window.$debounce = b, Number.prototype.toFixedNumber = function(e) {
@@ -126,28 +128,28 @@ const A = (a) => {
126
128
  }, Array.prototype.filter1 = function(e) {
127
129
  if (!e || typeof e != "function")
128
130
  throw new Error(e + " is not a function");
129
- let r, o;
130
- for (let t = 0; t < this.length; t++)
131
- if (e(this[t], t, this)) {
132
- o = t, r = this[t];
131
+ let t, o;
132
+ for (let r = 0; r < this.length; r++)
133
+ if (e(this[r], r, this)) {
134
+ o = r, t = this[r];
133
135
  break;
134
136
  }
135
137
  return {
136
138
  index: o,
137
- data: r
139
+ data: t
138
140
  };
139
141
  }, window.$getType = (e) => Object.prototype.toString.call(e).slice(8, -1);
140
- const $ = (e, r) => {
142
+ const $ = (e, t) => {
141
143
  if (!e) {
142
144
  console.info("No Value");
143
145
  return;
144
146
  }
145
147
  const o = window.$l("Copied");
146
- let t;
147
- if (r ? window.$getType(r) !== "Boolean" ? t = `${o} ${r}: ${e}` : t = `${o}: ${e}` : t = o, navigator.clipboard && window.isSecureContext)
148
+ let r;
149
+ if (t ? window.$getType(t) !== "Boolean" ? r = `${o} ${t}: ${e}` : r = `${o}: ${e}` : r = o, navigator.clipboard && window.isSecureContext)
148
150
  navigator.clipboard.writeText(e).then(() => {
149
151
  a.config.globalProperties.$message.success({
150
- message: t,
152
+ message: r,
151
153
  // grouping: true,
152
154
  center: !0,
153
155
  duration: 5e3
@@ -156,7 +158,7 @@ const A = (a) => {
156
158
  else {
157
159
  let n = document.createElement("textarea");
158
160
  n.value = e, n.style.position = "fixed", n.style.opacity = 0, document.body.appendChild(n), n.select(), document.execCommand("Copy"), n.remove(), a.config.globalProperties.$message.success({
159
- message: t,
161
+ message: r,
160
162
  // grouping: true,
161
163
  center: !0,
162
164
  duration: 5e3
@@ -164,28 +166,28 @@ const A = (a) => {
164
166
  }
165
167
  };
166
168
  window.$copy = $, a.config.globalProperties.$copy = $;
167
- const O = (e) => e < 1e3 ? e : e < 1e6 ? parseInt(e / 1e3) + "K" : parseInt(e / 1e6) + "M";
168
- window.$sc = O;
169
+ const F = (e) => e < 1e3 ? e : e < 1e6 ? parseInt(e / 1e3) + "K" : parseInt(e / 1e6) + "M";
170
+ window.$sc = F;
169
171
  const C = {
170
172
  cpa: "avgCPA",
171
173
  cpt: "avgCPT"
172
- }, M = (e, r = C) => {
173
- const o = r[e.name];
174
+ }, T = (e, t = C) => {
175
+ const o = t[e.name];
174
176
  o && (e.name = o);
175
177
  };
176
- window.$nr = M;
177
- const S = (e, r) => (Object.keys(e).forEach((o) => {
178
+ window.$nr = T;
179
+ const E = (e, t) => (Object.keys(e).forEach((o) => {
178
180
  objMap[o] && (e[objMap[o]] = e[o], delete e[o]);
179
181
  }), e);
180
- window.$nro = S;
181
- const T = (e) => {
182
- let r = 0;
182
+ window.$nro = E;
183
+ const M = (e) => {
184
+ let t = 0;
183
185
  return Object.keys(e).forEach((o) => {
184
- (window.$getType(e[o]) === "Array" && e[o].length !== 0 || e[o]) && r++;
185
- }), r;
186
+ (window.$getType(e[o]) === "Array" && e[o].length !== 0 || e[o]) && t++;
187
+ }), t;
186
188
  };
187
- window.$pc = T;
188
- const h = {
189
+ window.$pc = M;
190
+ const d = {
189
191
  info: {
190
192
  tag: "background-color:#0085FF; color:#f1f7ff;",
191
193
  style: "background-color:#f1f7ff; color:#0085FF;"
@@ -206,85 +208,86 @@ const A = (a) => {
206
208
  tag: "background-color:#20c997; color:#f6fffc;",
207
209
  style: "background-color:#f6fffc; color:#20c997;"
208
210
  }
209
- }, i = (e = "info", r) => {
210
- console.info(
211
- `%c ${e.toUpperCase()} %c┆${r}┆`,
212
- `${h[e].tag}`,
213
- `${h[e].style}`
214
- );
215
- };
216
- window.$c = {
217
- info: (...e) => {
218
- i("info", e);
219
- },
220
- log: (...e) => {
221
- i("log", e);
222
- },
223
- error: (...e) => {
224
- i("error", e);
225
- },
226
- warn: (...e) => {
227
- i("warn", e);
228
- },
229
- success: (...e) => {
230
- i("success", e);
231
- }
232
- };
233
- const E = (e) => new Promise((r, o) => {
234
- const t = new Image();
235
- t.src = window.$getType(e) === "String" ? e : URL.createObjectURL(e), t.onload = () => r(t), t.onerror = () => o(new Error("Could not load image"));
211
+ }, j = (e) => {
212
+ let t = !1;
213
+ for (let o in e)
214
+ if (window.$getType(e[o]) === "Object") {
215
+ t = !0;
216
+ break;
217
+ }
218
+ return t;
219
+ }, S = ["info", "log", "warn", "success"];
220
+ window.$c = {}, S.forEach((e) => {
221
+ window.$c[e] = (...t) => {
222
+ const o = e.toUpperCase();
223
+ j(t) ? (console.groupCollapsed(
224
+ `%c ${o} %c`,
225
+ `${d[type].tag}`
226
+ ), console[e](...t), console.groupEnd()) : console.info(
227
+ `%c ${o} %c┆${t}┆`,
228
+ `${d[type].tag}`,
229
+ `${d[type].style}`
230
+ );
231
+ };
236
232
  });
237
- window.$loadImage = E;
238
- const j = (e) => new Promise((r, o) => {
239
- const t = document.createElement("video");
240
- t.preload = "metadata", window.$getType(e) === "String" ? t.src = e : t.src = URL.createObjectURL(e), t.onloadedmetadata = () => {
241
- window.URL.revokeObjectURL(e), console.info([t]), r(t);
233
+ const L = (e) => {
234
+ if (e)
235
+ return new Promise((t, o) => {
236
+ const r = new Image();
237
+ r.src = window.$getType(e) === "String" ? e : URL.createObjectURL(e), r.onload = () => t(r), r.onerror = () => o(new Error("Could not load image"));
238
+ });
239
+ };
240
+ window.$loadImage = L;
241
+ const P = (e) => new Promise((t, o) => {
242
+ const r = document.createElement("video");
243
+ r.preload = "metadata", window.$getType(e) === "String" ? r.src = e : r.src = URL.createObjectURL(e), r.onloadedmetadata = () => {
244
+ window.URL.revokeObjectURL(e), console.info([r]), t(r);
242
245
  };
243
246
  });
244
- window.$loadVideo = j;
247
+ window.$loadVideo = P;
245
248
  const y = (e) => {
246
249
  if (e && window.$getType(e) === "Object") {
247
250
  const o = {};
248
- return Object.keys(e).forEach((t) => {
249
- const n = e[t];
251
+ return Object.keys(e).forEach((r) => {
252
+ const n = e[r];
250
253
  switch (window.$getType(n)) {
251
254
  case "Object":
252
- Object.keys(n) !== 0 && (o[t] = n);
255
+ Object.keys(n) !== 0 && (o[r] = n);
253
256
  break;
254
257
  case "Array":
255
- n.length !== 0 && (o[t] = n);
258
+ n.length !== 0 && (o[r] = n);
256
259
  break;
257
260
  case "String":
258
- n && (o[t] = n.toLowerCase());
261
+ n && (o[r] = n.toLowerCase());
259
262
  break;
260
263
  // case 'Number':
261
264
  // r[it] = String(itv);
262
265
  // break;
263
266
  default:
264
- [void 0, null, ""].indexOf(n) === -1 && (o[t] = n);
267
+ [void 0, null, ""].indexOf(n) === -1 && (o[r] = n);
265
268
  break;
266
269
  }
267
270
  }), o;
268
271
  }
269
272
  };
270
273
  window.$removeEmptyParams = y, window.$rep = y;
271
- let l = null, w = null;
272
- const L = async (e) => {
273
- let { type: r = "img", url: o, name: t, data: n } = e;
274
- if (l = document.createElement("a"), r === "csv") {
274
+ let l = null, f = null;
275
+ const R = async (e) => {
276
+ let { type: t = "img", url: o, name: r, data: n } = e;
277
+ if (l = document.createElement("a"), t === "csv") {
275
278
  const c = new Blob(["\uFEFF" + n], {
276
279
  type: "text/csv,charset=UTF-8"
277
280
  });
278
281
  l.href = URL.createObjectURL(c);
279
- } else r === "video" || r === "excel" ? await fetch(o, e).then((c) => c.blob()).then((c) => {
282
+ } else t === "video" || t === "excel" ? await fetch(o, e).then((c) => c.blob()).then((c) => {
280
283
  l.href = URL.createObjectURL(c);
281
- }) : (r = "table") ? await fetch(o).then((c) => c.blob()).then((c) => {
284
+ }) : (t = "table") ? await fetch(o).then((c) => c.blob()).then((c) => {
282
285
  l.href = URL.createObjectURL(c);
283
286
  }) : l.href = o;
284
- w = new MouseEvent("click"), l.download = t || "download", l.dispatchEvent(w), (r === "csv" || r === "video") && URL.revokeObjectURL(l.url), l = null, w = null;
287
+ f = new MouseEvent("click"), l.download = r || "download", l.dispatchEvent(f), (t === "csv" || t === "video") && URL.revokeObjectURL(l.url), l = null, f = null;
285
288
  };
286
- window.$download = L;
289
+ window.$download = R;
287
290
  };
288
291
  export {
289
- A as d
292
+ I as d
290
293
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "magtool",
3
3
  "packageManager": "yarn@4.4.1",
4
- "version": "1.2.9",
4
+ "version": "1.3.1",
5
5
  "author": "matt avis",
6
6
  "main": "./dist/index.js",
7
7
  "module": "./dist/index.js",
@@ -31,7 +31,7 @@
31
31
  "dependencies": {
32
32
  "bignumber.js": "^9.1.2",
33
33
  "echarts": "^5.6.0",
34
- "magtool": "^1.2.8",
34
+ "magtool": "^1.3.0",
35
35
  "markdown-it": "^14.1.0",
36
36
  "moment": "^2.30.1",
37
37
  "pinia": "^3.0.0",