magtool 1.0.2 → 1.0.4

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/dist/store.js ADDED
@@ -0,0 +1,11 @@
1
+ import { createPinia as n, defineStore as r } from "pinia";
2
+ const a = n(), i = (e) => {
3
+ const t = {};
4
+ return Object.keys(e).forEach((o) => {
5
+ const c = o.match(/chip\/(\S*).js/)[1];
6
+ t[c] = r(c, e[o].default);
7
+ }), { pinia: a, store: t };
8
+ };
9
+ export {
10
+ i as s
11
+ };
package/dist/util.js CHANGED
@@ -1,134 +1,179 @@
1
- const E = (i) => {
2
- const u = (e) => new URL((/* @__PURE__ */ Object.assign({}))[`/src/assets/img/${e}`], import.meta.url).href;
3
- i.config.globalProperties.$getImg = u, window.$getImg = u;
4
- const $ = (e, n = 0) => {
5
- let t = parseInt(Math.random() * e);
6
- return t += n, t;
1
+ const S = (i) => {
2
+ const f = (e) => new URL((/* @__PURE__ */ Object.assign({}))[`/src/assets/img/${e}`], import.meta.url).href;
3
+ i.config.globalProperties.$getImg = f, window.$getImg = f;
4
+ const $ = (e, t = 0) => {
5
+ let o = parseInt(Math.random() * e);
6
+ return o += t, o;
7
7
  };
8
8
  window.$rn = $;
9
- const g = (e, n) => {
10
- let t = [];
11
- for (let o = 0; o < e; o++)
12
- t.push(n(o));
13
- return t;
9
+ const y = (e, t) => {
10
+ let o = [];
11
+ for (let r = 0; r < e; r++)
12
+ o.push(t(r));
13
+ return o;
14
14
  };
15
- window.$fd = g, i.config.globalProperties.$setTimeout = function(e = () => {
16
- }, n) {
15
+ window.$fd = y, i.config.globalProperties.$setTimeout = function(e = () => {
16
+ }, t) {
17
17
  this.timer && (clearTimeout(this.timer), this.timer = null), this.timer = setTimeout(() => {
18
18
  e(), clearTimeout(this.timer);
19
- }, n);
19
+ }, t);
20
20
  };
21
- const b = (e) => e.substr(0, 1).toUpperCase() + e.substr(1, e.length).toLowerCase();
22
- window.$toUpperCamel = b;
23
- const c = (e, n = 2) => {
24
- const t = window.$getType(e);
25
- let o;
26
- t === "Number" ? (e = e.toFixed(n), o = String(e), e = String(Math.abs(e))) : t === "String" && (o = e, e = String(Math.abs(Number(e))));
27
- const r = e.split(".");
28
- let a = r[0].split("");
21
+ const h = (e) => e.substr(0, 1).toUpperCase() + e.substr(1, e.length).toLowerCase();
22
+ window.$toUpperCamel = h;
23
+ const u = (e, t = 2) => {
24
+ const o = window.$getType(e);
25
+ let r;
26
+ o === "Number" ? (e = e.toFixed(t), r = String(e), e = String(Math.abs(e))) : o === "String" && (r = e, e = String(Math.abs(Number(e))));
27
+ const n = e.split(".");
28
+ let a = n[0].split("");
29
29
  a = a.reverse();
30
30
  let l = [];
31
- a.forEach((N, m) => {
32
- m !== 0 && m % 3 === 0 && l.push(","), l.push(N);
31
+ a.forEach((N, b) => {
32
+ b !== 0 && b % 3 === 0 && l.push(","), l.push(N);
33
33
  });
34
- let s = l.reverse().join("");
35
- return window.$getType(n) === "Number" && n > 0 && (s += ".", r[1] ? s += r[1].padEnd(n, 0).substr(0, n) : s += "0".padEnd(n, "0")), Number(o) !== Number(e) ? `-${s}` : s;
34
+ let c = l.reverse().join("");
35
+ return window.$getType(t) === "Number" && t > 0 && (c += ".", n[1] ? c += n[1].padEnd(t, 0).substr(0, t) : c += "0".padEnd(t, "0")), Number(r) !== Number(e) ? `-${c}` : c;
36
36
  };
37
- window.$fa = c, i.config.globalProperties.$fa = c;
38
- const p = ({
37
+ window.$fa = u, i.config.globalProperties.$fa = u;
38
+ const d = ({
39
39
  prop: e,
40
- currency: n,
41
- value: t,
42
- obj: o = window.$map.asa.asaMetric.allObj
40
+ currency: t,
41
+ value: o,
42
+ obj: r = window.$map.asa.asaMetric.allObj
43
43
  }) => {
44
- const r = o[e];
45
- return r.unit === "currency" ? n ? `${n} ${window.$fa(t, r == null ? void 0 : r.precision)}` : window.$fa(t, r == null ? void 0 : r.precision) : r.unit === "%" ? `${window.$fa(t, r == null ? void 0 : r.precision)}%` : window.$fa(t, r == null ? void 0 : r.precision);
44
+ const n = r[e];
45
+ 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);
46
46
  };
47
- window.$fu = p, i.config.globalProperties.$fu = p;
48
- const d = (e = () => {
49
- }, n = 2) => {
50
- let t = null;
51
- return new Promise((o, r) => {
52
- t = setTimeout(() => {
53
- e(o, r), clearTimeout(t), o(!0);
54
- }, n * 100);
47
+ window.$fu = d, i.config.globalProperties.$fu = d;
48
+ const w = (e = () => {
49
+ }, t = 2) => {
50
+ let o = null;
51
+ return new Promise((r, n) => {
52
+ o = setTimeout(() => {
53
+ e(r, n), clearTimeout(o), r(!0);
54
+ }, t * 100);
55
55
  });
56
56
  };
57
- window.$pm = d, window.$promise = d;
58
- const w = (e = () => {
59
- }, n = 500) => {
60
- let t;
61
- return function(...o) {
62
- t && clearTimeout(t), t = setTimeout(() => {
63
- e.apply(this, o);
64
- }, n);
57
+ window.$pm = w, window.$promise = w;
58
+ const g = (e = () => {
59
+ }, t = 500) => {
60
+ let o;
61
+ return function(...r) {
62
+ o && clearTimeout(o), o = setTimeout(() => {
63
+ e.apply(this, r);
64
+ }, t);
65
65
  };
66
66
  };
67
- window.$db = w, window.$debounce = w, Number.prototype.toFixedNumber = function(e) {
67
+ window.$db = g, window.$debounce = g, Number.prototype.toFixedNumber = function(e) {
68
68
  return Number(this.toFixed(e));
69
69
  }, Array.prototype.filter1 = function(e) {
70
70
  if (!e || typeof e != "function")
71
71
  throw new Error(e + " is not a function");
72
- let n, t;
73
- for (let o = 0; o < this.length; o++)
74
- if (e(this[o], o, this)) {
75
- t = o, n = this[o];
72
+ let t, o;
73
+ for (let r = 0; r < this.length; r++)
74
+ if (e(this[r], r, this)) {
75
+ o = r, t = this[r];
76
76
  break;
77
77
  }
78
78
  return {
79
- index: t,
80
- data: n
79
+ index: o,
80
+ data: t
81
81
  };
82
82
  }, window.$getType = (e) => Object.prototype.toString.call(e).slice(8, -1);
83
- const f = (e, n) => {
83
+ const p = (e, t) => {
84
84
  if (!e) {
85
85
  console.info("No Value");
86
86
  return;
87
87
  }
88
- const t = window.$l("Copied");
89
- let o;
90
- if (n ? window.$getType(n) !== "Boolean" ? o = `${t} ${n}: ${e}` : o = `${t}: ${e}` : o = t, navigator.clipboard && window.isSecureContext)
88
+ const o = window.$l("Copied");
89
+ let r;
90
+ if (t ? window.$getType(t) !== "Boolean" ? r = `${o} ${t}: ${e}` : r = `${o}: ${e}` : r = o, navigator.clipboard && window.isSecureContext)
91
91
  navigator.clipboard.writeText(e).then(() => {
92
92
  i.config.globalProperties.$message.success({
93
- message: o,
93
+ message: r,
94
94
  // grouping: true,
95
95
  center: !0,
96
96
  duration: 0
97
97
  });
98
98
  });
99
99
  else {
100
- let r = document.createElement("textarea");
101
- r.value = e, r.style.position = "fixed", r.style.opacity = 0, document.body.appendChild(r), r.select(), document.execCommand("Copy"), r.remove(), i.config.globalProperties.$message.success({
102
- message: o,
100
+ let n = document.createElement("textarea");
101
+ n.value = e, n.style.position = "fixed", n.style.opacity = 0, document.body.appendChild(n), n.select(), document.execCommand("Copy"), n.remove(), i.config.globalProperties.$message.success({
102
+ message: r,
103
103
  // grouping: true,
104
104
  center: !0,
105
105
  duration: 0
106
106
  });
107
107
  }
108
108
  };
109
- window.$copy = f, i.config.globalProperties.$copy = f;
110
- const h = (e) => e < 1e3 ? e : e < 1e6 ? parseInt(e / 1e3) + "K" : parseInt(e / 1e6) + "M";
111
- window.$sc = h;
112
- const y = {
109
+ window.$copy = p, i.config.globalProperties.$copy = p;
110
+ const F = (e) => e < 1e3 ? e : e < 1e6 ? parseInt(e / 1e3) + "K" : parseInt(e / 1e6) + "M";
111
+ window.$sc = F;
112
+ const C = {
113
113
  cpa: "avgCPA",
114
114
  cpt: "avgCPT"
115
- }, T = (e, n = y) => {
116
- const t = n[e.name];
117
- t && (e.name = t);
115
+ }, T = (e, t = C) => {
116
+ const o = t[e.name];
117
+ o && (e.name = o);
118
118
  };
119
119
  window.$nr = T;
120
- const C = (e, n) => (Object.keys(e).forEach((t) => {
121
- objMap[t] && (e[objMap[t]] = e[t], delete e[t]);
120
+ const k = (e, t) => (Object.keys(e).forEach((o) => {
121
+ objMap[o] && (e[objMap[o]] = e[o], delete e[o]);
122
122
  }), e);
123
- window.$nro = C;
123
+ window.$nro = k;
124
124
  const P = (e) => {
125
- let n = 0;
126
- return Object.keys(e).forEach((t) => {
127
- (window.$getType(e[t]) === "Array" && e[t].length !== 0 || e[t]) && n++;
128
- }), n;
125
+ let t = 0;
126
+ return Object.keys(e).forEach((o) => {
127
+ (window.$getType(e[o]) === "Array" && e[o].length !== 0 || e[o]) && t++;
128
+ }), t;
129
129
  };
130
130
  window.$pc = P;
131
+ const m = {
132
+ info: {
133
+ tag: "background-color:#0085FF; color:#f1f7ff;",
134
+ style: "background-color:#f1f7ff; color:#0085FF;"
135
+ },
136
+ log: {
137
+ tag: "background-color:#FFFFFF; color:#272b41;",
138
+ style: "background-color:#272b41; color:#FFFFFF;"
139
+ },
140
+ error: {
141
+ tag: "background-color:#ff4d4f; color:#fff3f3;",
142
+ style: "background-color:#fff3f3; color:#ff4d4f;"
143
+ },
144
+ warn: {
145
+ tag: "background-color:#fa8b0c; color:#fffbf6;",
146
+ style: "background-color:#fffbf6; color:#fa8b0c;"
147
+ },
148
+ success: {
149
+ tag: "background-color:#20c997; color:#f6fffc;",
150
+ style: "background-color:#f6fffc; color:#20c997;"
151
+ }
152
+ }, s = (e = "info", t) => {
153
+ e === "success" && (e = "info"), console[e](
154
+ `%c ${e.toUpperCase()} %c┆${t}┆`,
155
+ `${m[e].tag}`,
156
+ `${m[e].style}`
157
+ );
158
+ };
159
+ window.$console = {
160
+ info: (...e) => {
161
+ s("info", e);
162
+ },
163
+ log: (...e) => {
164
+ s("log", e);
165
+ },
166
+ error: (...e) => {
167
+ s("error", e);
168
+ },
169
+ warn: (...e) => {
170
+ s("warn", e);
171
+ },
172
+ success: (...e) => {
173
+ s("success", e);
174
+ }
175
+ };
131
176
  };
132
177
  export {
133
- E as d
178
+ S as d
134
179
  };
package/package.json CHANGED
@@ -1,30 +1,30 @@
1
1
  {
2
2
  "name": "magtool",
3
3
  "packageManager": "yarn@4.4.1",
4
- "version": "1.0.2",
4
+ "version": "1.0.4",
5
5
  "author": "magxl",
6
- "main": "./dist/index.mjs",
7
- "module": "./dist/index.mjs",
6
+ "main": "./dist/index.js",
7
+ "module": "./dist/index.js",
8
8
  "exports": {
9
9
  ".": {
10
- "import": "./dist/index.mjs",
11
- "require": "./dist/index.mjs"
10
+ "import": "./dist/index.js",
11
+ "require": "./dist/index.js"
12
12
  },
13
13
  "./cps": {
14
- "import": "./dist/cps.mjs",
15
- "require": "./dist/cps.mjs"
14
+ "import": "./dist/cps.js",
15
+ "require": "./dist/cps.js"
16
16
  },
17
17
  "./directive": {
18
- "import": "./dist/directive.mjs",
19
- "require": "./dist/directive.mjs"
18
+ "import": "./dist/directive.js",
19
+ "require": "./dist/directive.js"
20
20
  },
21
21
  "./util": {
22
- "import": "./dist/util.mjs",
23
- "require": "./dist/util.mjs"
22
+ "import": "./dist/util.js",
23
+ "require": "./dist/util.js"
24
24
  },
25
- "./pinia": {
26
- "import": "./dist/pinia.mjs",
27
- "require": "./dist/pinia.mjs"
25
+ "./store": {
26
+ "import": "./dist/store.js",
27
+ "require": "./dist/store.js"
28
28
  }
29
29
  },
30
30
  "scripts": {
@@ -35,7 +35,7 @@
35
35
  "dist/*"
36
36
  ],
37
37
  "dependencies": {
38
- "magtool": "^1.0.1",
38
+ "magtool": "^1.0.3",
39
39
  "moment": "^2.30.1",
40
40
  "pinia": "^3.0.0",
41
41
  "vue": "^3.3.4"