x-essential-lib 0.1.14 → 0.2.0

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/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { AxiosInstance } from 'axios'
1
2
  import { DefineComponent, ComputedRef, Ref } from 'vue'
2
3
  import { RouteLocationNormalized, NavigationGuardNext } from 'vue-router'
3
4
 
@@ -61,6 +62,13 @@ export declare function useSystem(): {
61
62
  compactWidth: ComputedRef<string>
62
63
  }
63
64
 
65
+ type OnError = (error: any) => void
66
+
67
+ export declare function createAxios(
68
+ baseUrl: string,
69
+ onError: OnError
70
+ ): AxiosInstance
71
+
64
72
  export declare function waitMs(ms: number): Promise<void>
65
73
 
66
74
  export declare function waitUtil(
package/dist/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  (function(){"use strict";try{if(typeof document<"u"){var t=document.createElement("style");t.appendChild(document.createTextNode('.inner-left-enter-active,.inner-right-enter-active{transition:transform .35s ease}.inner-left-enter-from{transform:translate(-100%)}.inner-right-enter-from{transform:translate(100%)}.inner-left-enter-to,.inner-right-enter-to{transform:translate(0)}.x-cont[data-v-a8f3d91f]{position:absolute;top:0;left:0;bottom:0;right:0;display:flex;align-items:center;justify-content:center}.lds-spinner[data-v-a8f3d91f]{color:official;display:inline-block;position:relative;width:40px;height:40px}.lds-spinner div[data-v-a8f3d91f]{transform-origin:20px 20px;animation:lds-spinner-a8f3d91f 1.2s linear infinite}.lds-spinner div[data-v-a8f3d91f]:after{content:" ";display:block;position:absolute;top:3px;left:18px;width:2px;height:6px;border-radius:5%;background:#9e9e9e}.lds-spinner div[data-v-a8f3d91f]:nth-child(1){transform:rotate(0);animation-delay:-1.1s}.lds-spinner div[data-v-a8f3d91f]:nth-child(2){transform:rotate(30deg);animation-delay:-1s}.lds-spinner div[data-v-a8f3d91f]:nth-child(3){transform:rotate(60deg);animation-delay:-.9s}.lds-spinner div[data-v-a8f3d91f]:nth-child(4){transform:rotate(90deg);animation-delay:-.8s}.lds-spinner div[data-v-a8f3d91f]:nth-child(5){transform:rotate(120deg);animation-delay:-.7s}.lds-spinner div[data-v-a8f3d91f]:nth-child(6){transform:rotate(150deg);animation-delay:-.6s}.lds-spinner div[data-v-a8f3d91f]:nth-child(7){transform:rotate(180deg);animation-delay:-.5s}.lds-spinner div[data-v-a8f3d91f]:nth-child(8){transform:rotate(210deg);animation-delay:-.4s}.lds-spinner div[data-v-a8f3d91f]:nth-child(9){transform:rotate(240deg);animation-delay:-.3s}.lds-spinner div[data-v-a8f3d91f]:nth-child(10){transform:rotate(270deg);animation-delay:-.2s}.lds-spinner div[data-v-a8f3d91f]:nth-child(11){transform:rotate(300deg);animation-delay:-.1s}.lds-spinner div[data-v-a8f3d91f]:nth-child(12){transform:rotate(330deg);animation-delay:0s}@keyframes lds-spinner-a8f3d91f{0%{opacity:1}to{opacity:0}}.x-cont[data-v-70ed4b89]{position:absolute;left:50%;bottom:20px;transform:translate(-50%);z-index:9999}')),document.head.appendChild(t)}}catch(a){console.error("vite-plugin-css-injected-by-js",a)}})();
2
- import { VBtn as ce, VCard as ie, VCardActions as ue, VCardText as de, VCardTitle as pe, VDialog as fe, VForm as me, VTextField as ve } from "vuetify/lib/components/index.mjs";
3
- import { defineComponent as S, useModel as K, ref as _, computed as d, onMounted as R, onBeforeUnmount as N, watch as L, resolveComponent as m, openBlock as V, createBlock as B, withKeys as E, withModifiers as $, withCtx as v, createVNode as h, createTextVNode as C, toDisplayString as k, createElementBlock as j, normalizeStyle as ge, pushScopeId as _e, popScopeId as he, createElementVNode as g, reactive as xe, Fragment as ye, renderList as we, unref as ke } from "vue";
4
- import { useLocale as z, useTheme as F, useDisplay as Ce } from "vuetify/lib/framework.mjs";
5
- function Ve(e) {
2
+ import { VBtn as pe, VCard as fe, VCardActions as me, VCardText as ve, VCardTitle as ge, VDialog as _e, VForm as he, VTextField as xe } from "vuetify/lib/components/index.mjs";
3
+ import { defineComponent as S, useModel as L, ref as _, computed as d, onMounted as $, onBeforeUnmount as U, watch as N, resolveComponent as m, openBlock as b, createBlock as A, withKeys as E, withModifiers as M, withCtx as v, createVNode as h, createTextVNode as C, toDisplayString as k, createElementBlock as K, normalizeStyle as ye, pushScopeId as we, popScopeId as ke, createElementVNode as g, reactive as Ce, Fragment as be, renderList as Ve, unref as qe, inject as De } from "vue";
4
+ import { useLocale as H, useTheme as X, useDisplay as Se } from "vuetify/lib/framework.mjs";
5
+ import Re from "axios";
6
+ function Te(e) {
6
7
  return { all: e = e || /* @__PURE__ */ new Map(), on: function(o, t) {
7
8
  var n = e.get(o);
8
9
  n ? n.push(t) : e.set(o, [t]);
@@ -11,29 +12,29 @@ function Ve(e) {
11
12
  n && (t ? n.splice(n.indexOf(t) >>> 0, 1) : e.set(o, []));
12
13
  }, emit: function(o, t) {
13
14
  var n = e.get(o);
14
- n && n.slice().map(function(l) {
15
- l(t);
16
- }), (n = e.get("*")) && n.slice().map(function(l) {
17
- l(o, t);
15
+ n && n.slice().map(function(r) {
16
+ r(t);
17
+ }), (n = e.get("*")) && n.slice().map(function(r) {
18
+ r(o, t);
18
19
  });
19
20
  } };
20
21
  }
21
- const i = Ve();
22
- async function Fe(e) {
22
+ const i = Te();
23
+ async function st(e) {
23
24
  return new Promise((o) => {
24
25
  setTimeout(o, e);
25
26
  });
26
27
  }
27
- async function H(e, o, t) {
28
+ async function F(e, o, t) {
28
29
  const n = Date.now();
29
- return new Promise((l) => {
30
- const r = async () => {
31
- e() ? l(!0) : o && Date.now() - n > o ? l(!1) : setTimeout(r, t ?? 30);
30
+ return new Promise((r) => {
31
+ const l = async () => {
32
+ e() ? r(!0) : o && Date.now() - n > o ? r(!1) : setTimeout(l, t ?? 30);
32
33
  };
33
- r();
34
+ l();
34
35
  });
35
36
  }
36
- const be = /* @__PURE__ */ S({
37
+ const Ie = /* @__PURE__ */ S({
37
38
  __name: "index",
38
39
  props: {
39
40
  modelValue: { type: Boolean },
@@ -41,41 +42,41 @@ const be = /* @__PURE__ */ S({
41
42
  },
42
43
  emits: ["update:modelValue"],
43
44
  setup(e) {
44
- const o = z(), t = K(e, "modelValue"), n = _(""), l = _(""), r = _(), a = _(), s = d(() => {
45
+ const o = H(), t = L(e, "modelValue"), n = _(""), r = _(""), l = _(), a = _(), s = d(() => {
45
46
  var u;
46
- return ((u = r.value) == null ? void 0 : u.color) ?? "primary";
47
+ return ((u = l.value) == null ? void 0 : u.color) ?? "primary";
47
48
  }), f = d(() => {
48
49
  var u;
49
- return ((u = r.value) == null ? void 0 : u.text) ?? o.t("cancel");
50
+ return ((u = l.value) == null ? void 0 : u.text) ?? o.t("cancel");
50
51
  }), p = d(() => {
51
52
  var u;
52
53
  return ((u = a.value) == null ? void 0 : u.color) ?? "primary";
53
- }), b = d(() => {
54
+ }), V = d(() => {
54
55
  var u;
55
56
  return ((u = a.value) == null ? void 0 : u.text) ?? o.t("confirm");
56
57
  });
57
- let T = 0, D = !1;
58
- const A = (u) => {
59
- n.value = u.title, l.value = u.text, r.value = u.cancel, a.value = u.confirm, T = u.seq, D = !1, t.value = !0;
58
+ let R = 0, q = !1;
59
+ const B = (u) => {
60
+ n.value = u.title, r.value = u.text, l.value = u.cancel, a.value = u.confirm, R = u.seq, q = !1, t.value = !0;
60
61
  };
61
- R(() => {
62
- i.on("confirmDlg", A);
63
- }), N(() => {
64
- i.off("confirmDlg", A);
62
+ $(() => {
63
+ i.on("confirmDlg", B);
64
+ }), U(() => {
65
+ i.off("confirmDlg", B);
65
66
  });
66
67
  const O = () => {
67
- t.value = !1, D || (i.emit("confirmDlgResult" + T, !0), D = !0);
68
+ t.value = !1, q || (i.emit("confirmDlgResult" + R, !0), q = !0);
68
69
  };
69
- return L(t, (u) => {
70
- !u && !D && (i.emit("confirmDlgResult" + T, !1), D = !0);
70
+ return N(t, (u) => {
71
+ !u && !q && (i.emit("confirmDlgResult" + R, !1), q = !0);
71
72
  }), (u, y) => {
72
- const q = m("v-card-title"), W = m("v-card-text"), I = m("v-btn"), c = m("v-card-actions"), x = m("v-card"), U = m("v-dialog");
73
- return V(), B(U, {
73
+ const D = m("v-card-title"), j = m("v-card-text"), T = m("v-btn"), c = m("v-card-actions"), x = m("v-card"), z = m("v-dialog");
74
+ return b(), A(z, {
74
75
  modelValue: t.value,
75
- "onUpdate:modelValue": y[1] || (y[1] = (M) => t.value = M),
76
+ "onUpdate:modelValue": y[1] || (y[1] = (I) => t.value = I),
76
77
  onKeydown: [
77
- y[2] || (y[2] = E($((M) => t.value = !1, ["stop", "prevent"]), ["esc"])),
78
- E($(O, ["stop", "prevent"]), ["enter"])
78
+ y[2] || (y[2] = E(M((I) => t.value = !1, ["stop", "prevent"]), ["esc"])),
79
+ E(M(O, ["stop", "prevent"]), ["enter"])
79
80
  ],
80
81
  transition: "dialog-top-transition",
81
82
  "max-width": "600px"
@@ -83,22 +84,22 @@ const be = /* @__PURE__ */ S({
83
84
  default: v(() => [
84
85
  h(x, null, {
85
86
  default: v(() => [
86
- h(q, null, {
87
+ h(D, null, {
87
88
  default: v(() => [
88
89
  C(k(n.value), 1)
89
90
  ]),
90
91
  _: 1
91
92
  }),
92
- h(W, null, {
93
+ h(j, null, {
93
94
  default: v(() => [
94
- C(k(l.value), 1)
95
+ C(k(r.value), 1)
95
96
  ]),
96
97
  _: 1
97
98
  }),
98
99
  h(c, { class: "d-flex justify-end" }, {
99
100
  default: v(() => [
100
- h(I, {
101
- onClick: y[0] || (y[0] = (M) => t.value = !1),
101
+ h(T, {
102
+ onClick: y[0] || (y[0] = (I) => t.value = !1),
102
103
  color: s.value,
103
104
  variant: "text"
104
105
  }, {
@@ -107,13 +108,13 @@ const be = /* @__PURE__ */ S({
107
108
  ]),
108
109
  _: 1
109
110
  }, 8, ["color"]),
110
- h(I, {
111
+ h(T, {
111
112
  onClick: O,
112
113
  color: p.value,
113
114
  variant: "text"
114
115
  }, {
115
116
  default: v(() => [
116
- C(k(b.value), 1)
117
+ C(k(V.value), 1)
117
118
  ]),
118
119
  _: 1
119
120
  }, 8, ["color"])
@@ -128,7 +129,7 @@ const be = /* @__PURE__ */ S({
128
129
  }, 8, ["modelValue", "onKeydown"]);
129
130
  };
130
131
  }
131
- }), De = (e) => (_e("data-v-a8f3d91f"), e = e(), he(), e), qe = /* @__PURE__ */ De(() => /* @__PURE__ */ g("div", { class: "lds-spinner" }, [
132
+ }), Pe = (e) => (we("data-v-a8f3d91f"), e = e(), ke(), e), Me = /* @__PURE__ */ Pe(() => /* @__PURE__ */ g("div", { class: "lds-spinner" }, [
132
133
  /* @__PURE__ */ g("div"),
133
134
  /* @__PURE__ */ g("div"),
134
135
  /* @__PURE__ */ g("div"),
@@ -141,9 +142,9 @@ const be = /* @__PURE__ */ S({
141
142
  /* @__PURE__ */ g("div"),
142
143
  /* @__PURE__ */ g("div"),
143
144
  /* @__PURE__ */ g("div")
144
- ], -1)), Se = [
145
- qe
146
- ], Te = /* @__PURE__ */ S({
145
+ ], -1)), $e = [
146
+ Me
147
+ ], Ae = /* @__PURE__ */ S({
147
148
  __name: "index",
148
149
  props: {
149
150
  zIndex: {
@@ -152,21 +153,21 @@ const be = /* @__PURE__ */ S({
152
153
  }
153
154
  },
154
155
  setup(e) {
155
- const o = F(), t = e, n = d(() => ({
156
+ const o = X(), t = e, n = d(() => ({
156
157
  background: o.current.value.dark ? "#1e1e1e" : "#ffffff",
157
158
  zIndex: t.zIndex
158
159
  }));
159
- return (l, r) => (V(), j("div", {
160
+ return (r, l) => (b(), K("div", {
160
161
  class: "x-cont",
161
- style: ge(n.value)
162
- }, Se, 4));
162
+ style: ye(n.value)
163
+ }, $e, 4));
163
164
  }
164
- }), Y = (e, o) => {
165
+ }), oe = (e, o) => {
165
166
  const t = e.__vccOpts || e;
166
- for (const [n, l] of o)
167
- t[n] = l;
167
+ for (const [n, r] of o)
168
+ t[n] = r;
168
169
  return t;
169
- }, Ie = /* @__PURE__ */ Y(Te, [["__scopeId", "data-v-a8f3d91f"]]), Me = /* @__PURE__ */ S({
170
+ }, Be = /* @__PURE__ */ oe(Ae, [["__scopeId", "data-v-a8f3d91f"]]), Oe = /* @__PURE__ */ S({
170
171
  __name: "item",
171
172
  props: {
172
173
  id: {
@@ -188,7 +189,7 @@ const be = /* @__PURE__ */ S({
188
189
  },
189
190
  emits: ["timeout"],
190
191
  setup(e, { emit: o }) {
191
- const t = e, n = _(!0), l = o, r = d(() => {
192
+ const t = e, n = _(!0), r = o, l = d(() => {
192
193
  let a = "";
193
194
  switch (t.type) {
194
195
  case "error":
@@ -206,20 +207,20 @@ const be = /* @__PURE__ */ S({
206
207
  }
207
208
  return a;
208
209
  });
209
- return R(() => {
210
+ return $(() => {
210
211
  setTimeout(() => {
211
- l("timeout", t.id);
212
+ r("timeout", t.id);
212
213
  }, t.timeout);
213
- }), L(n, (a) => {
214
- a || l("timeout", t.id);
214
+ }), N(n, (a) => {
215
+ a || r("timeout", t.id);
215
216
  }), (a, s) => {
216
217
  const f = m("v-alert");
217
- return V(), B(f, {
218
+ return b(), A(f, {
218
219
  modelValue: n.value,
219
220
  "onUpdate:modelValue": s[0] || (s[0] = (p) => n.value = p),
220
221
  class: "mt-2",
221
222
  type: e.type,
222
- icon: r.value,
223
+ icon: l.value,
223
224
  text: e.text,
224
225
  "max-width": "90%",
225
226
  width: "500px",
@@ -229,34 +230,34 @@ const be = /* @__PURE__ */ S({
229
230
  }, null, 8, ["modelValue", "type", "icon", "text"]);
230
231
  };
231
232
  }
232
- }), Pe = /* @__PURE__ */ S({
233
+ }), je = /* @__PURE__ */ S({
233
234
  __name: "index",
234
235
  setup(e) {
235
- const o = xe({ items: [] });
236
- R(() => {
236
+ const o = Ce({ items: [] });
237
+ $(() => {
237
238
  i.on("message", t);
238
- }), N(() => {
239
+ }), U(() => {
239
240
  i.off("message", t);
240
241
  });
241
242
  const t = (s) => {
242
- r(s.type, s.text, s.timeout);
243
+ l(s.type, s.text, s.timeout);
243
244
  }, n = (s) => {
244
245
  a(s);
245
246
  };
246
- let l = 0;
247
- const r = (s, f, p) => {
248
- const b = l++;
249
- o.items.push({ id: b, type: s, text: f, timeout: p });
247
+ let r = 0;
248
+ const l = (s, f, p) => {
249
+ const V = r++;
250
+ o.items.push({ id: V, type: s, text: f, timeout: p });
250
251
  }, a = (s) => {
251
252
  const f = o.items.findIndex((p) => p.id === s);
252
253
  f >= 0 && o.items.splice(f, 1);
253
254
  };
254
- return (s, f) => (V(), j("div", {
255
- onClick: f[0] || (f[0] = $(() => {
255
+ return (s, f) => (b(), K("div", {
256
+ onClick: f[0] || (f[0] = M(() => {
256
257
  }, ["stop"])),
257
258
  class: "x-cont d-flex flex-column-reverse align-center"
258
259
  }, [
259
- (V(!0), j(ye, null, we(o.items, (p) => (V(), B(Me, {
260
+ (b(!0), K(be, null, Ve(o.items, (p) => (b(), A(Oe, {
260
261
  onTimeout: n,
261
262
  id: p.id,
262
263
  type: p.type,
@@ -266,7 +267,7 @@ const be = /* @__PURE__ */ S({
266
267
  }, null, 8, ["id", "type", "text", "timeout"]))), 128))
267
268
  ]));
268
269
  }
269
- }), $e = /* @__PURE__ */ Y(Pe, [["__scopeId", "data-v-70ed4b89"]]), Re = /* @__PURE__ */ S({
270
+ }), We = /* @__PURE__ */ oe(je, [["__scopeId", "data-v-70ed4b89"]]), Ee = /* @__PURE__ */ S({
270
271
  __name: "index",
271
272
  props: {
272
273
  modelValue: { type: Boolean },
@@ -274,67 +275,67 @@ const be = /* @__PURE__ */ S({
274
275
  },
275
276
  emits: ["update:modelValue"],
276
277
  setup(e) {
277
- const o = z(), t = K(e, "modelValue"), n = _(""), l = _(""), r = _(), a = _(), s = _(), f = _(""), p = _(), b = _(), T = d(() => {
278
+ const o = H(), t = L(e, "modelValue"), n = _(""), r = _(""), l = _(), a = _(), s = _(), f = _(""), p = _(), V = _(), R = d(() => {
278
279
  var c;
279
280
  return ((c = p.value) == null ? void 0 : c.color) ?? "primary";
280
- }), D = d(() => {
281
+ }), q = d(() => {
281
282
  var c;
282
283
  return ((c = p.value) == null ? void 0 : c.text) ?? o.t("cancel");
283
- }), A = d(() => {
284
+ }), B = d(() => {
284
285
  var c;
285
- return ((c = b.value) == null ? void 0 : c.color) ?? "primary";
286
+ return ((c = V.value) == null ? void 0 : c.color) ?? "primary";
286
287
  }), O = d(() => {
287
288
  var c;
288
- return ((c = b.value) == null ? void 0 : c.text) ?? o.t("confirm");
289
+ return ((c = V.value) == null ? void 0 : c.text) ?? o.t("confirm");
289
290
  }), u = _();
290
- let y = 0, q = !1;
291
- const W = async (c) => {
291
+ let y = 0, D = !1;
292
+ const j = async (c) => {
292
293
  var x;
293
- n.value = c.title, l.value = c.text, r.value = c.label, a.value = c.placeholder, s.value = c.rules, f.value = c.value, p.value = c.cancel, b.value = c.confirm, y = c.seq, q = !1, t.value = !0, await H(() => u.value !== void 0, 1e3), (x = u.value) == null || x.focus();
294
+ n.value = c.title, r.value = c.text, l.value = c.label, a.value = c.placeholder, s.value = c.rules, f.value = c.value, p.value = c.cancel, V.value = c.confirm, y = c.seq, D = !1, t.value = !0, await F(() => u.value !== void 0, 1e3), (x = u.value) == null || x.focus();
294
295
  };
295
- R(() => {
296
- i.on("promptDlg", W);
297
- }), N(() => {
298
- i.off("promptDlg", W);
296
+ $(() => {
297
+ i.on("promptDlg", j);
298
+ }), U(() => {
299
+ i.off("promptDlg", j);
299
300
  });
300
- const I = () => {
301
- t.value = !1, q || (i.emit("promptDlgResult" + y, f.value ?? ""), q = !0);
301
+ const T = () => {
302
+ t.value = !1, D || (i.emit("promptDlgResult" + y, f.value ?? ""), D = !0);
302
303
  };
303
- return L(t, (c) => {
304
- !c && !q && (i.emit("promptDlgResult" + y, void 0), q = !0);
304
+ return N(t, (c) => {
305
+ !c && !D && (i.emit("promptDlgResult" + y, void 0), D = !0);
305
306
  }), (c, x) => {
306
- const U = m("v-card-title"), M = m("v-card-text"), ne = m("v-text-field"), le = m("v-form"), X = m("v-btn"), ae = m("v-card-actions"), re = m("v-card"), se = m("v-dialog");
307
- return V(), B(se, {
307
+ const z = m("v-card-title"), I = m("v-card-text"), se = m("v-text-field"), ce = m("v-form"), J = m("v-btn"), ie = m("v-card-actions"), ue = m("v-card"), de = m("v-dialog");
308
+ return b(), A(de, {
308
309
  modelValue: t.value,
309
310
  "onUpdate:modelValue": x[2] || (x[2] = (P) => t.value = P),
310
311
  onKeydown: [
311
- x[3] || (x[3] = E($((P) => t.value = !1, ["stop", "prevent"]), ["esc"])),
312
- E($(I, ["stop", "prevent"]), ["enter"])
312
+ x[3] || (x[3] = E(M((P) => t.value = !1, ["stop", "prevent"]), ["esc"])),
313
+ E(M(T, ["stop", "prevent"]), ["enter"])
313
314
  ],
314
315
  transition: "dialog-top-transition",
315
316
  "max-width": "600px"
316
317
  }, {
317
318
  default: v(() => [
318
- h(re, null, {
319
+ h(ue, null, {
319
320
  default: v(() => [
320
- h(U, null, {
321
+ h(z, null, {
321
322
  default: v(() => [
322
323
  C(k(n.value), 1)
323
324
  ]),
324
325
  _: 1
325
326
  }),
326
- h(M, null, {
327
+ h(I, null, {
327
328
  default: v(() => [
328
- C(k(l.value), 1)
329
+ C(k(r.value), 1)
329
330
  ]),
330
331
  _: 1
331
332
  }),
332
- h(le, { class: "mx-3" }, {
333
+ h(ce, { class: "mx-3" }, {
333
334
  default: v(() => [
334
- h(ne, {
335
+ h(se, {
335
336
  modelValue: f.value,
336
337
  "onUpdate:modelValue": x[0] || (x[0] = (P) => f.value = P),
337
- label: r.value,
338
+ label: l.value,
338
339
  placeholder: a.value,
339
340
  rules: s.value,
340
341
  ref_key: "target",
@@ -343,21 +344,21 @@ const be = /* @__PURE__ */ S({
343
344
  ]),
344
345
  _: 1
345
346
  }),
346
- h(ae, { class: "d-flex justify-end" }, {
347
+ h(ie, { class: "d-flex justify-end" }, {
347
348
  default: v(() => [
348
- h(X, {
349
+ h(J, {
349
350
  onClick: x[1] || (x[1] = (P) => t.value = !1),
350
- color: T.value,
351
+ color: R.value,
351
352
  variant: "text"
352
353
  }, {
353
354
  default: v(() => [
354
- C(k(D.value), 1)
355
+ C(k(q.value), 1)
355
356
  ]),
356
357
  _: 1
357
358
  }, 8, ["color"]),
358
- h(X, {
359
- onClick: I,
360
- color: A.value,
359
+ h(J, {
360
+ onClick: T,
361
+ color: B.value,
361
362
  variant: "text"
362
363
  }, {
363
364
  default: v(() => [
@@ -376,7 +377,7 @@ const be = /* @__PURE__ */ S({
376
377
  }, 8, ["modelValue", "onKeydown"]);
377
378
  };
378
379
  }
379
- }), Be = { class: "mx-auto my-auto" }, Ae = { class: "d-flex align-center justify-center w-100 h-100" }, Oe = /* @__PURE__ */ S({
380
+ }), Ue = { class: "mx-auto my-auto" }, ze = { class: "d-flex align-center justify-center w-100 h-100" }, Ke = /* @__PURE__ */ S({
380
381
  __name: "index",
381
382
  props: {
382
383
  modelValue: { type: Boolean },
@@ -384,18 +385,18 @@ const be = /* @__PURE__ */ S({
384
385
  },
385
386
  emits: ["update:modelValue"],
386
387
  setup(e) {
387
- const o = z(), t = K(e, "modelValue"), n = () => {
388
+ const o = H(), t = L(e, "modelValue"), n = () => {
388
389
  t.value = !0;
389
- }, l = () => {
390
+ }, r = () => {
390
391
  t.value = !1;
391
392
  };
392
- return R(() => {
393
- i.on("openWaitDlg", n), i.on("closeWaitDlg", l);
394
- }), N(() => {
395
- i.off("openWaitDlg", n), i.off("closeWaitDlg", l);
396
- }), (r, a) => {
393
+ return $(() => {
394
+ i.on("openWaitDlg", n), i.on("closeWaitDlg", r);
395
+ }), U(() => {
396
+ i.off("openWaitDlg", n), i.off("closeWaitDlg", r);
397
+ }), (l, a) => {
397
398
  const s = m("v-card"), f = m("v-dialog");
398
- return V(), B(f, {
399
+ return b(), A(f, {
399
400
  modelValue: t.value,
400
401
  "onUpdate:modelValue": a[0] || (a[0] = (p) => t.value = p),
401
402
  persistent: "",
@@ -403,15 +404,15 @@ const be = /* @__PURE__ */ S({
403
404
  fullscreen: ""
404
405
  }, {
405
406
  default: v(() => [
406
- g("div", Be, [
407
+ g("div", Ue, [
407
408
  h(s, {
408
409
  width: "300px",
409
410
  height: "80px",
410
411
  loading: ""
411
412
  }, {
412
413
  default: v(() => [
413
- g("div", Ae, [
414
- g("span", null, k(ke(o).t("waitingResponse")), 1)
414
+ g("div", ze, [
415
+ g("span", null, k(qe(o).t("waitingResponse")), 1)
415
416
  ])
416
417
  ]),
417
418
  _: 1
@@ -423,79 +424,135 @@ const be = /* @__PURE__ */ S({
423
424
  };
424
425
  }
425
426
  });
426
- function He() {
427
- const e = F(), o = d(() => e.global.current.value.colors.primary), t = d(() => e.global.current.value.colors.secondary), n = d(() => e.current.value.dark ? "#2e2e2e" : "#bdbdbd"), l = d(() => e.current.value.dark ? "#272727" : "#eeeeee"), r = d(() => e.current.value.dark ? "#1e1e1e" : "#ffffff"), a = d(() => e.current.value.dark ? "#303030" : "#f6f6f6"), s = d(() => e.current.value.dark ? "#ffffff1f" : "#0000001f");
427
+ function ct() {
428
+ const e = X(), o = d(() => e.global.current.value.colors.primary), t = d(() => e.global.current.value.colors.secondary), n = d(() => e.current.value.dark ? "#2e2e2e" : "#bdbdbd"), r = d(() => e.current.value.dark ? "#272727" : "#eeeeee"), l = d(() => e.current.value.dark ? "#1e1e1e" : "#ffffff"), a = d(() => e.current.value.dark ? "#303030" : "#f6f6f6"), s = d(() => e.current.value.dark ? "#ffffff1f" : "#0000001f");
428
429
  return {
429
430
  primaryColor: o,
430
431
  secondaryColor: t,
431
432
  backgroundColor0: n,
432
- backgroundColor1: l,
433
- backgroundColor2: r,
433
+ backgroundColor1: r,
434
+ backgroundColor2: l,
434
435
  highlightColor: a,
435
436
  borderColor: s
436
437
  };
437
438
  }
438
- function Xe() {
439
- const e = F(), { width: o } = Ce(), t = d(() => e.current.value.dark), n = _(""), l = d(() => !!window.cordova), r = d(() => o.value <= 1280 ? o.value + "px" : o.value <= 1920 ? 1920 / 2.5 + "px" : 2560 / 2.5 + "px");
440
- return { dark: t, routeTransName: n, sysBarAvail: l, compactWidth: r };
439
+ function it() {
440
+ const e = X(), { width: o } = Se(), t = d(() => e.current.value.dark), n = _(""), r = d(() => !!window.cordova), l = d(() => o.value <= 1280 ? o.value + "px" : o.value <= 1920 ? 1920 / 2.5 + "px" : 2560 / 2.5 + "px");
441
+ return { dark: t, routeTransName: n, sysBarAvail: r, compactWidth: l };
442
+ }
443
+ var Le = {}, G;
444
+ (function(e) {
445
+ e.pop = "pop", e.push = "push";
446
+ })(G || (G = {}));
447
+ var Q;
448
+ (function(e) {
449
+ e.back = "back", e.forward = "forward", e.unknown = "";
450
+ })(Q || (Q = {}));
451
+ var Y;
452
+ (function(e) {
453
+ e[e.aborted = 4] = "aborted", e[e.cancelled = 8] = "cancelled", e[e.duplicated = 16] = "duplicated";
454
+ })(Y || (Y = {}));
455
+ const Ne = Symbol(Le.NODE_ENV !== "production" ? "router" : "");
456
+ function He() {
457
+ return De(Ne);
458
+ }
459
+ const W = require("js-cookie");
460
+ function ut(e, o) {
461
+ const t = Re.create({
462
+ timeout: 6e3
463
+ });
464
+ return t.defaults.baseURL = e, t.interceptors.request.use(
465
+ (n) => Xe(n),
466
+ (n) => {
467
+ Fe(n, o);
468
+ }
469
+ ), t.interceptors.response.use(
470
+ (n) => Je(n),
471
+ (n) => Ge(n, o)
472
+ ), t;
473
+ }
474
+ function Xe(e) {
475
+ const o = W.get("accessToken") ?? "";
476
+ return e.headers.Authorization = "Basic " + o, e.headers["Content-Type"] = "application/json", e.data = JSON.stringify(e.data), e;
441
477
  }
442
- let G = Date.now();
443
- function Z() {
478
+ function Fe(e, o) {
479
+ console.error(e), o("request timeout");
480
+ }
481
+ function Je(e) {
482
+ return e.data;
483
+ }
484
+ function Ge(e, o) {
485
+ var r;
486
+ const t = e.response;
487
+ if (!t)
488
+ return Promise.reject(e);
489
+ t.status === 401 && Qe();
490
+ let n = (r = t.data) == null ? void 0 : r.message;
491
+ return n || (n = {
492
+ code: t.status,
493
+ message: t.statusText
494
+ }), o(n), Promise.reject(e);
495
+ }
496
+ function Qe() {
497
+ W.remove("accessToken"), W.remove("refreshToken"), W.remove("activeOrg"), He().replace({ path: "/passport/login" });
498
+ }
499
+ let Z = Date.now();
500
+ function ne() {
444
501
  const e = Date.now();
445
- return e - G > 500 ? (G = e, !0) : !1;
502
+ return e - Z > 500 ? (Z = e, !0) : !1;
446
503
  }
447
- let We = 0;
448
- function ee() {
449
- return ++We;
504
+ let Ye = 0;
505
+ function re() {
506
+ return ++Ye;
450
507
  }
451
- async function Ge(e) {
452
- if (!Z())
508
+ async function dt(e) {
509
+ if (!ne())
453
510
  return;
454
511
  let o = !1, t;
455
- const n = (r) => {
456
- t = r, o = !0;
457
- }, l = ee();
458
- return i.on("confirmDlgResult" + l, n), i.emit("confirmDlg", { ...e, seq: l }), await H(() => o), i.off("confirmDlgResult" + l, n), t;
512
+ const n = (l) => {
513
+ t = l, o = !0;
514
+ }, r = re();
515
+ return i.on("confirmDlgResult" + r, n), i.emit("confirmDlg", { ...e, seq: r }), await F(() => o), i.off("confirmDlgResult" + r, n), t;
459
516
  }
460
- async function Je(e) {
461
- if (!Z())
517
+ async function pt(e) {
518
+ if (!ne())
462
519
  return;
463
520
  let o = !1, t;
464
- const n = (r) => {
465
- t = r, o = !0;
466
- }, l = ee();
467
- return i.on("promptDlgResult" + l, n), i.emit("promptDlg", { ...e, seq: l }), await H(() => o), i.off("promptDlgResult" + l, n), t;
521
+ const n = (l) => {
522
+ t = l, o = !0;
523
+ }, r = re();
524
+ return i.on("promptDlgResult" + r, n), i.emit("promptDlg", { ...e, seq: r }), await F(() => o), i.off("promptDlgResult" + r, n), t;
468
525
  }
469
- function Qe() {
526
+ function ft() {
470
527
  i.emit("openWaitDlg");
471
528
  }
472
- function Ye() {
529
+ function mt() {
473
530
  i.emit("closeWaitDlg");
474
531
  }
475
- function Ze(e, o) {
532
+ function vt(e, o) {
476
533
  i.emit("message", { type: "error", text: e, timeout: o });
477
534
  }
478
- function et(e, o) {
535
+ function gt(e, o) {
479
536
  i.emit("message", { type: "info", text: e, timeout: o });
480
537
  }
481
- function tt(e, o) {
538
+ function _t(e, o) {
482
539
  i.emit("message", { type: "success", text: e, timeout: o });
483
540
  }
484
- function ot(e, o) {
541
+ function ht(e, o) {
485
542
  i.emit("message", { type: "warning", text: e, timeout: o });
486
543
  }
487
- function nt(e) {
488
- var n, l;
544
+ function xt(e) {
545
+ var n, r;
489
546
  if (!window.appAppear) {
490
547
  window.appAppear = !0;
491
548
  return;
492
549
  }
493
550
  const o = "single-spa-application:" + e, t = (n = document.getElementById(o)) == null ? void 0 : n.classList;
494
- t && (t.remove("app-left", "app-right", "app-reset"), (l = window.routeExtras) != null && l.forward ? t.add("app-left") : t.add("app-right"), setTimeout(() => {
551
+ t && (t.remove("app-left", "app-right", "app-reset"), (r = window.routeExtras) != null && r.forward ? t.add("app-left") : t.add("app-right"), setTimeout(() => {
495
552
  t.add("app-reset");
496
553
  }, 0));
497
554
  }
498
- const te = require("js-cookie"), Ee = [
555
+ const ae = require("js-cookie"), Ze = [
499
556
  { path: "/passport/login", level: 0 },
500
557
  { path: "/passport/loginAccount", level: 1 },
501
558
  { path: "/passport/register", level: 1 },
@@ -515,48 +572,48 @@ const te = require("js-cookie"), Ee = [
515
572
  { path: "/calc", level: 1, requiredState: "org" },
516
573
  { path: "/data", level: 1, requiredState: "org" }
517
574
  ];
518
- function oe(e) {
575
+ function le(e) {
519
576
  let o, t = 0;
520
577
  const n = e.split("/");
521
- return Ee.forEach((l) => {
522
- const r = l.path.split("/");
578
+ return Ze.forEach((r) => {
579
+ const l = r.path.split("/");
523
580
  let a = 0;
524
- for (let s = 0; s < n.length && !(s >= r.length || n[s] !== r[s]); s++)
581
+ for (let s = 0; s < n.length && !(s >= l.length || n[s] !== l[s]); s++)
525
582
  a++;
526
- a >= t && (o = l, t = a);
583
+ a >= t && (o = r, t = a);
527
584
  }), o;
528
585
  }
529
- function J(e) {
586
+ function ee(e) {
530
587
  if (e === "/")
531
588
  return { app: "", path: "/", level: -1 };
532
- const o = oe(e);
589
+ const o = le(e);
533
590
  if (!o)
534
591
  return { app: "invalidApp", path: "/invalidApp/invalidRoute", level: -1 };
535
592
  const t = e.split("/");
536
593
  return console.assert(t.length >= 2), { app: t[1], path: o.path, level: o.level };
537
594
  }
538
- const Q = _("");
595
+ const te = _("");
539
596
  function w(e, o) {
540
- const t = J(e), n = J(o), l = t.app === n.app, r = t.path === n.path, a = t.level >= n.level;
597
+ const t = ee(e), n = ee(o), r = t.app === n.app, l = t.path === n.path, a = t.level >= n.level;
541
598
  console.info(
542
- `~~~~before route change~~~~ ${n.path} -> ${t.path} inner=${l} forward=${a}`
543
- ), l ? r ? Q.value = "" : Q.value = a ? "inner-left" : "inner-right" : window.routeExtras = { forward: a };
599
+ `~~~~before route change~~~~ ${n.path} -> ${t.path} inner=${r} forward=${a}`
600
+ ), r ? l ? te.value = "" : te.value = a ? "inner-left" : "inner-right" : window.routeExtras = { forward: a };
544
601
  }
545
- function Ne() {
546
- return !!te.get("accessToken");
602
+ function et() {
603
+ return !!ae.get("accessToken");
547
604
  }
548
- function Ue() {
549
- return !!te.get("activeOrg");
605
+ function tt() {
606
+ return !!ae.get("activeOrg");
550
607
  }
551
- function lt(e, o, t) {
552
- const n = Ne(), l = Ue(), r = oe(e.path);
553
- if (!r) {
608
+ function yt(e, o, t) {
609
+ const n = et(), r = tt(), l = le(e.path);
610
+ if (!l) {
554
611
  t();
555
612
  return;
556
613
  }
557
- if (r.requiredState === "auth")
614
+ if (l.requiredState === "auth")
558
615
  if (n)
559
- if (l) {
616
+ if (r) {
560
617
  const a = "/main";
561
618
  w(a, o.path), t({ path: a });
562
619
  } else
@@ -565,9 +622,9 @@ function lt(e, o, t) {
565
622
  const a = "/passport/login";
566
623
  w(a, o.path), t({ path: a });
567
624
  }
568
- else if (r.requiredState === "org")
625
+ else if (l.requiredState === "org")
569
626
  if (n)
570
- if (l)
627
+ if (r)
571
628
  w(e.path, o.path), t();
572
629
  else {
573
630
  const a = "/org/joinOrCreate";
@@ -578,7 +635,7 @@ function lt(e, o, t) {
578
635
  w(a, o.path), t({ path: a });
579
636
  }
580
637
  else if (n)
581
- if (l) {
638
+ if (r) {
582
639
  const a = "/main";
583
640
  w(a, o.path), t({ path: a });
584
641
  } else {
@@ -588,24 +645,25 @@ function lt(e, o, t) {
588
645
  else
589
646
  w(e.path, o.path), t();
590
647
  }
591
- const je = (e) => {
592
- e.component("v-btn", ce), e.component("v-card", ie), e.component("v-card-actions", ue), e.component("v-card-text", de), e.component("v-card-title", pe), e.component("v-dialog", fe), e.component("v-form", me), e.component("v-text-field", ve), e.component("x-confirm-dlg", be), e.component("x-loading", Ie), e.component("x-message", $e), e.component("x-prompt-dlg", Re), e.component("x-wait-dlg", Oe);
593
- }, at = { install: je };
648
+ const ot = (e) => {
649
+ e.component("v-btn", pe), e.component("v-card", fe), e.component("v-card-actions", me), e.component("v-card-text", ve), e.component("v-card-title", ge), e.component("v-dialog", _e), e.component("v-form", he), e.component("v-text-field", xe), e.component("x-confirm-dlg", Ie), e.component("x-loading", Be), e.component("x-message", We), e.component("x-prompt-dlg", Ee), e.component("x-wait-dlg", Ke);
650
+ }, wt = { install: ot };
594
651
  export {
595
- nt as appAppear,
596
- Ye as closeWaitDlg,
597
- at as default,
598
- Ze as messageError,
599
- et as messageInfo,
600
- tt as messageSuccess,
601
- ot as messageWarning,
602
- lt as onBeforeEach,
603
- Ge as openConfirmDlg,
604
- Je as openPromptDlg,
605
- Qe as openWaitDlg,
606
- Q as routeTransName,
607
- He as useColor,
608
- Xe as useSystem,
609
- Fe as waitMs,
610
- H as waitUtil
652
+ xt as appAppear,
653
+ mt as closeWaitDlg,
654
+ ut as createAxios,
655
+ wt as default,
656
+ vt as messageError,
657
+ gt as messageInfo,
658
+ _t as messageSuccess,
659
+ ht as messageWarning,
660
+ yt as onBeforeEach,
661
+ dt as openConfirmDlg,
662
+ pt as openPromptDlg,
663
+ ft as openWaitDlg,
664
+ te as routeTransName,
665
+ ct as useColor,
666
+ it as useSystem,
667
+ st as waitMs,
668
+ F as waitUtil
611
669
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "x-essential-lib",
3
3
  "private": false,
4
- "version": "0.1.14",
4
+ "version": "0.2.0",
5
5
  "type": "module",
6
6
  "module": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -26,6 +26,7 @@
26
26
  "mitt": "^3.0.1"
27
27
  },
28
28
  "peerDependencies": {
29
+ "axios": "^1.6.8",
29
30
  "vue": "^3.4.23",
30
31
  "vue-router": "^4.3.2",
31
32
  "vuetify": "^3.5.16"