@fewangsit/wangsvue-fats 1.0.1-alpha.21 → 1.0.1-alpha.23

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.
@@ -231,8 +231,8 @@ const H = /* @__PURE__ */ nA(vA), j = "data:image/png;base64,iVBORw0KGgoAAAANSUh
231
231
  t[4] || (t[4] = e("span", null, "Preview", -1)),
232
232
  a(eA, {
233
233
  icon: "info",
234
- info: `This preview is only for showing the side of the
235
- label that printed or not. It does not show the
234
+ info: `This preview is only for showing the side of the\r
235
+ label that printed or not. It does not show the\r
236
236
  exact amount you entered.`,
237
237
  severity: "primary"
238
238
  })
@@ -1,51 +1,52 @@
1
- import { defineComponent as h, onMounted as v, shallowRef as i, watch as w, createBlock as c, openBlock as u, unref as _, withCtx as s, createVNode as g, createCommentVNode as y } from "vue";
1
+ import { defineComponent as h, onMounted as v, shallowRef as i, watch as w, createBlock as u, openBlock as c, unref as _, withCtx as s, createVNode as g, createCommentVNode as y } from "vue";
2
2
  import { u as L } from "../plugins/basei18n.es.js";
3
+ import { g as C } from "../utils/cookie.util.es.js";
3
4
  import { s as x } from "../vendor/primevue/dropdown/dropdown.esm.es.js";
4
- import { _ as C } from "../icon/index.es.js";
5
+ import { _ as k } from "../icon/index.es.js";
5
6
  import { _ as p } from "../languagedropdownoption/index.es.js";
6
- const b = /* @__PURE__ */ h({
7
+ const N = /* @__PURE__ */ h({
7
8
  __name: "LanguageSwitcher",
8
- setup(S) {
9
+ setup(O) {
9
10
  v(async () => {
10
- n.value = await f();
11
+ t.value = await f();
11
12
  });
12
- const { service: r, setLocale: m } = L(), n = i(), o = i([]), l = i(!1), f = async () => {
13
- const a = localStorage.getItem("lang") || navigator.language.split("-")[0];
14
- if (!o.value.length)
13
+ const { service: r, setLocale: m } = L(), t = i(), a = i([]), l = i(!1), f = async () => {
14
+ const o = C("lang") || navigator.language.split("-")[0];
15
+ if (!a.value.length)
15
16
  try {
16
- const e = await r.getLanguageOptionMeta(a);
17
+ const e = await r.getLanguageOptionMeta(o);
17
18
  if (e.isoCode)
18
- return o.value[0] = e, e;
19
+ return a.value[0] = e, e;
19
20
  } catch (e) {
20
21
  console.error(
21
22
  "Ups! Something error while fetching Language Option Meta.",
22
23
  e
23
24
  );
24
25
  }
25
- return o.value.find((e) => e.isoCode === a) || o.value[0];
26
+ return a.value.find((e) => e.isoCode === o) || a.value[0];
26
27
  }, d = async () => {
27
- if (!(!r || o.value.length > 1))
28
+ if (!(!r || a.value.length > 1))
28
29
  try {
29
30
  l.value = !0;
30
- const a = await r.getLanguageOptions();
31
- o.value = a;
32
- } catch (a) {
31
+ const o = await r.getLanguageOptions();
32
+ a.value = o;
33
+ } catch (o) {
33
34
  console.error(
34
35
  "Ups! Something error while fetching language options.",
35
- a
36
+ o
36
37
  );
37
38
  } finally {
38
39
  l.value = !1;
39
40
  }
40
41
  };
41
- return w(n, (a) => {
42
- m(a.isoCode);
43
- }), (a, e) => (u(), c(_(x), {
44
- modelValue: n.value,
45
- "onUpdate:modelValue": e[0] || (e[0] = (t) => n.value = t),
42
+ return w(t, (o) => {
43
+ m(o.isoCode);
44
+ }), (o, e) => (c(), u(_(x), {
45
+ modelValue: t.value,
46
+ "onUpdate:modelValue": e[0] || (e[0] = (n) => t.value = n),
46
47
  "filter-fields": ["language", "name"],
47
48
  loading: l.value,
48
- options: o.value,
49
+ options: a.value,
49
50
  pt: {
50
51
  root: {
51
52
  class: "flex items-center gap-1 gap-1"
@@ -64,25 +65,25 @@ const b = /* @__PURE__ */ h({
64
65
  "filter-placeholder": "Search language"
65
66
  }, {
66
67
  dropdownicon: s(() => [
67
- g(C, {
68
+ g(k, {
68
69
  class: "w-4 h-4 rotate-180 text-general-800 transition-transform",
69
70
  icon: "arrow-up-s"
70
71
  })
71
72
  ]),
72
- value: s(({ value: t }) => [
73
- t ? (u(), c(p, {
73
+ value: s(({ value: n }) => [
74
+ n ? (c(), u(p, {
74
75
  key: 0,
75
- option: t,
76
+ option: n,
76
77
  "icon-only": ""
77
78
  }, null, 8, ["option"])) : y("", !0)
78
79
  ]),
79
- option: s(({ option: t }) => [
80
- g(p, { option: t }, null, 8, ["option"])
80
+ option: s(({ option: n }) => [
81
+ g(p, { option: n }, null, 8, ["option"])
81
82
  ]),
82
83
  _: 1
83
84
  }, 8, ["modelValue", "loading", "options"]));
84
85
  }
85
86
  });
86
87
  export {
87
- b as _
88
+ N as _
88
89
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fewangsit/wangsvue-fats",
3
- "version": "1.0.1-alpha.21",
3
+ "version": "1.0.1-alpha.23",
4
4
  "author": "Wangsit FE Developer",
5
5
  "description": "Fixed Asset Tagsamurai VueJS Component Library",
6
6
  "type": "module",
@@ -1,88 +1,89 @@
1
- import { shallowRef as P, shallowReactive as I, inject as M } from "vue";
2
- import { u as b } from "../assetinfo/index.es.js";
3
- const n = P(), u = "messages";
4
- let r;
1
+ import { shallowRef as m, shallowReactive as P, inject as I } from "vue";
2
+ import { u as M } from "../assetinfo/index.es.js";
3
+ import { s as b, g as y } from "../utils/cookie.util.es.js";
4
+ const s = m(), u = "messages";
5
+ let o;
5
6
  const f = () => {
6
7
  try {
7
- const t = localStorage.getItem(u);
8
- return t ? JSON.parse(t) : {};
8
+ const e = localStorage.getItem(u);
9
+ return e ? JSON.parse(e) : {};
9
10
  } catch {
10
11
  return {};
11
12
  }
12
- }, g = I(f()), a = new Proxy(g, {
13
- get: (t, e) => {
14
- const l = f()[e];
15
- return g[e] = l, l;
13
+ }, i = P(f()), r = new Proxy(i, {
14
+ get: (e, t) => {
15
+ const l = f()[t];
16
+ return i[t] = l, l;
16
17
  },
17
- set: (t, e, s) => (g[e] = s, m(g), !0)
18
- }), m = (t) => {
19
- localStorage.setItem(u, JSON.stringify(t));
20
- }, y = async (t) => {
21
- var e;
22
- if (!(t in a)) {
23
- const { setLoading: s } = b();
24
- s(!0, "Loading language package...");
18
+ set: (e, t, n) => (i[t] = n, x(i), !0)
19
+ }), x = (e) => {
20
+ localStorage.setItem(u, JSON.stringify(e));
21
+ }, A = async (e) => {
22
+ var t;
23
+ if (!(e in r)) {
24
+ const { setLoading: n } = M();
25
+ n(!0, "Loading language package...");
25
26
  let l = {};
26
27
  try {
27
- const { data: c } = await (((e = r == null ? void 0 : r.getMessages) == null ? void 0 : e.call(r, t)) ?? {});
28
+ const { data: c } = await (((t = o == null ? void 0 : o.getMessages) == null ? void 0 : t.call(o, e)) ?? {});
28
29
  l = c.data;
29
30
  } catch {
30
31
  } finally {
31
- s(!1);
32
+ n(!1);
32
33
  }
33
34
  return l;
34
35
  }
35
- return a[t];
36
- }, d = (t, ...e) => {
36
+ return r[e];
37
+ }, d = (e, ...t) => {
37
38
  var c;
38
- if (!n.value && !localStorage.lang) return t;
39
- let s = (c = a[n.value]) == null ? void 0 : c[t];
40
- const l = s === t && n.value !== "en";
41
- if ((!s || l) && (s = t, r == null || r.translateText(t, n.value).then((o) => {
42
- a[n.value] ? a[n.value] = {
43
- ...a[n.value],
44
- [t]: o
45
- } : a[n.value] = {
46
- [t]: o
39
+ if (!s.value && !y("lang")) return e;
40
+ let n = (c = r[s.value]) == null ? void 0 : c[e];
41
+ const l = n === e && s.value !== "en";
42
+ if ((!n || l) && (n = e, o == null || o.translateText(e, s.value).then((a) => {
43
+ r[s.value] ? r[s.value] = {
44
+ ...r[s.value],
45
+ [e]: a
46
+ } : r[s.value] = {
47
+ [e]: a
47
48
  };
48
- }).catch((o) => {
49
- console.error("Translation error:", o);
50
- })), e.length === 1 && typeof e[0] == "object" && !Array.isArray(e[0])) {
51
- const o = e[0];
52
- return Object.keys(o).reduce(
53
- (h, i) => h.replaceAll(`{${i}}`, o[i]),
54
- s
49
+ }).catch((a) => {
50
+ console.error("Translation error:", a);
51
+ })), t.length === 1 && typeof t[0] == "object" && !Array.isArray(t[0])) {
52
+ const a = t[0];
53
+ return Object.keys(a).reduce(
54
+ (h, g) => h.replaceAll(`{${g}}`, a[g]),
55
+ n
55
56
  );
56
57
  }
57
- if (e.length > 0) {
58
- let o = 0;
59
- return s.replace(/%s/g, () => String(e[o++] ?? ""));
58
+ if (t.length > 0) {
59
+ let a = 0;
60
+ return n.replace(/%s/g, () => String(t[a++] ?? ""));
60
61
  }
61
- return s;
62
- }, v = async (t) => {
63
- if (n.value !== t) {
64
- const e = await y(t);
65
- n.value = t, a[t] = e, localStorage.lang = t;
62
+ return n;
63
+ }, v = async (e) => {
64
+ if (s.value !== e) {
65
+ const t = await A(e);
66
+ s.value = e, r[e] = t, b({ name: "lang", value: s.value, path: "/" });
66
67
  }
67
- }, O = () => (M("i18n") || console.error("I18n Plugin not installed!"), {
68
+ }, E = () => (I("i18n") || console.error("I18n Plugin not installed!"), {
68
69
  t: d,
69
- locale: n,
70
+ locale: s,
70
71
  setLocale: v,
71
- service: r
72
- }), S = () => {
73
- const t = {
72
+ service: o
73
+ }), O = () => {
74
+ const e = {
74
75
  t: d,
75
- locale: n,
76
+ locale: s,
76
77
  setLocale: v,
77
- service: r
78
+ service: o
78
79
  };
79
80
  return {
80
- install(e) {
81
- e.config.globalProperties.$i18n = t, e.config.globalProperties.$t = t.t, e.provide("i18n", t);
81
+ install(t) {
82
+ t.config.globalProperties.$i18n = e, t.config.globalProperties.$t = e.t, t.provide("i18n", e);
82
83
  }
83
84
  };
84
- }, T = (t) => (r = t, S());
85
+ }, R = (e) => (o = e, O());
85
86
  export {
86
- T as c,
87
- O as u
87
+ R as c,
88
+ E as u
88
89
  };