mamba-layout 0.5.0 → 0.7.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.
@@ -1,98 +1,160 @@
1
- import { ref as S } from "vue";
2
- const T = 3600 * 24 * 7, b = "UTC", j = "timezone", a = () => {
1
+ import { ref as E, readonly as Z } from "vue";
2
+ const D = 3600 * 24 * 7, u = "UTC", S = "timezone", A = [
3
+ "UTC",
4
+ "Asia/Shanghai",
5
+ "Asia/Hong_Kong",
6
+ "Asia/Singapore",
7
+ "Asia/Tokyo",
8
+ "Europe/London",
9
+ "Europe/Berlin",
10
+ "America/New_York",
11
+ "America/Los_Angeles"
12
+ ], T = /* @__PURE__ */ new Map(), l = () => {
3
13
  try {
4
14
  return globalThis.localStorage;
5
15
  } catch {
6
16
  return;
7
17
  }
8
- }, g = {
9
- get(t, n = null) {
10
- const e = a(), r = e == null ? void 0 : e.getItem(t.toUpperCase());
11
- if (!r) return n;
18
+ }, m = {
19
+ get(e, t = null) {
20
+ const n = l(), o = n == null ? void 0 : n.getItem(e.toUpperCase());
21
+ if (!o) return t;
12
22
  try {
13
- const o = JSON.parse(r);
14
- if (o.expire === null || o.expire >= Date.now())
15
- return o.value;
16
- e == null || e.removeItem(t.toUpperCase());
23
+ const r = JSON.parse(o);
24
+ if (r.expire === null || r.expire >= Date.now())
25
+ return r.value;
26
+ n == null || n.removeItem(e.toUpperCase());
17
27
  } catch {
18
- return n;
28
+ return t;
19
29
  }
20
- return n;
30
+ return t;
21
31
  },
22
- set(t, n, e = T) {
23
- const r = a(), o = {
24
- value: n,
25
- expire: e === null ? null : Date.now() + e * 1e3
32
+ set(e, t, n = D) {
33
+ const o = l(), r = {
34
+ value: t,
35
+ expire: n === null ? null : Date.now() + n * 1e3
26
36
  };
27
- r == null || r.setItem(t.toUpperCase(), JSON.stringify(o));
37
+ o == null || o.setItem(e.toUpperCase(), JSON.stringify(r));
28
38
  },
29
39
  clear() {
30
- var t;
31
- (t = a()) == null || t.clear();
40
+ var e;
41
+ (e = l()) == null || e.clear();
32
42
  }
33
- }, y = (t) => typeof t == "object" && t !== null, f = (t) => {
34
- if (!y(t) || Object.prototype.toString.call(t) !== "[object Object]") return !1;
35
- const n = Object.getPrototypeOf(t);
36
- return n === null || n === Object.prototype;
43
+ }, L = (e) => typeof e == "object" && e !== null, h = (e) => {
44
+ if (!L(e) || Object.prototype.toString.call(e) !== "[object Object]") return !1;
45
+ const t = Object.getPrototypeOf(e);
46
+ return t === null || t === Object.prototype;
37
47
  };
38
- function E(t, n) {
39
- if (!f(t)) return n;
40
- if (!f(n)) return t;
41
- const e = t;
42
- return Object.keys(n).concat(Object.getOwnPropertySymbols(n)).forEach((r) => {
43
- e[r] = E(
44
- e[r],
45
- n[r]
48
+ function U(e, t) {
49
+ if (!h(e)) return t;
50
+ if (!h(t)) return e;
51
+ const n = e;
52
+ return Object.keys(t).concat(Object.getOwnPropertySymbols(t)).forEach((o) => {
53
+ n[o] = U(
54
+ n[o],
55
+ t[o]
46
56
  );
47
- }), e;
57
+ }), n;
48
58
  }
49
- function w() {
50
- const t = typeof navigator > "u" ? "en-US" : navigator.language;
51
- return String(g.get("locale", t)).includes("zh") ? "zh-CN" : "en-US";
59
+ function M() {
60
+ const e = typeof navigator > "u" ? "en-US" : navigator.language;
61
+ return String(m.get("locale", e)).includes("zh") ? "zh-CN" : "en-US";
52
62
  }
53
- const m = (t, n, e) => {
54
- var r;
55
- return ((r = n == null ? void 0 : n[e]) == null ? void 0 : r[t]) || "";
56
- }, v = (t, n, e = "") => {
57
- const r = t;
58
- return m(n, r, w()) || e || m(n, r, "en-US");
59
- }, x = (t = "") => t.replace(/【.*】/, ""), C = (t, n, e) => {
60
- var r, o, c, i, l;
61
- for (const s of n) {
62
- const h = ((r = s.path) == null ? void 0 : r.replace(/\/:(\w+)/g, "/([^/]+)")) || "", O = new RegExp(`^${h}$`);
63
- if (((o = s.path) == null ? void 0 : o.toLowerCase()) === t || O.test(t))
64
- return ((c = s.meta) == null ? void 0 : c.visible) === "0" && (e == null ? void 0 : e.path) || "";
65
- if ((i = s.children) != null && i.length) {
66
- const p = C(
67
- t,
68
- s.children,
69
- ((l = s.meta) == null ? void 0 : l.visible) === "1" ? s : e
63
+ const d = (e, t, n) => {
64
+ var o;
65
+ return ((o = t == null ? void 0 : t[n]) == null ? void 0 : o[e]) || "";
66
+ }, z = (e, t, n = "") => {
67
+ const o = e;
68
+ return d(t, o, M()) || n || d(t, o, "en-US");
69
+ }, F = (e = "") => e.replace(/【.*】/, ""), j = (e, t, n) => {
70
+ var o, r, s, i, f;
71
+ for (const c of t) {
72
+ const C = ((o = c.path) == null ? void 0 : o.replace(/\/:(\w+)/g, "/([^/]+)")) || "", b = new RegExp(`^${C}$`);
73
+ if (((r = c.path) == null ? void 0 : r.toLowerCase()) === e || b.test(e))
74
+ return ((s = c.meta) == null ? void 0 : s.visible) === "0" && (n == null ? void 0 : n.path) || "";
75
+ if ((i = c.children) != null && i.length) {
76
+ const g = j(
77
+ e,
78
+ c.children,
79
+ ((f = c.meta) == null ? void 0 : f.visible) === "1" ? c : n
70
80
  );
71
- if (p) return p;
81
+ if (g) return g;
72
82
  }
73
83
  }
74
84
  return "";
75
- }, D = (t, n) => {
76
- const e = t.resolve(n);
77
- if (!(e != null && e.name)) return !1;
78
- const r = String(e.name).split("-").filter((c) => !!c && c !== "index"), o = e.path.split("-").join("/").split("/").filter(Boolean);
79
- return r.length === o.length && r.every((c, i) => c === o[i]);
80
- }, u = (t) => typeof t == "string" && L(t) ? t : "", L = (t) => {
85
+ }, x = (e, t) => {
86
+ const n = e.resolve(t);
87
+ if (!(n != null && n.name)) return !1;
88
+ const o = String(n.name).split("-").filter((s) => !!s && s !== "index"), r = n.path.split("-").join("/").split("/").filter(Boolean);
89
+ return o.length === r.length && o.every((s, i) => s === r[i]);
90
+ }, a = (e) => typeof e == "string" && O(e) ? e : "", O = (e) => {
81
91
  try {
82
- return new Intl.DateTimeFormat("en-US", { timeZone: t }).format(/* @__PURE__ */ new Date()), !0;
92
+ return new Intl.DateTimeFormat("en-US", { timeZone: e }).format(/* @__PURE__ */ new Date()), !0;
83
93
  } catch {
84
94
  return !1;
85
95
  }
86
- }, d = () => u(Intl.DateTimeFormat().resolvedOptions().timeZone) || b;
87
- S(
88
- u(g.get(j)) || d()
89
- );
96
+ }, y = () => a(Intl.DateTimeFormat().resolvedOptions().timeZone) || u, p = E(
97
+ a(m.get(S)) || y()
98
+ ), B = () => Z(p);
99
+ function R(e) {
100
+ const t = a(e);
101
+ t && (p.value = t, m.set(S, t, null));
102
+ }
103
+ const _ = (e) => {
104
+ const t = a(e) || u, n = T.get(t);
105
+ if (n) return n;
106
+ const o = new Intl.DateTimeFormat("en-US", {
107
+ timeZone: t,
108
+ year: "numeric",
109
+ month: "2-digit",
110
+ day: "2-digit",
111
+ hour: "2-digit",
112
+ minute: "2-digit",
113
+ second: "2-digit",
114
+ hourCycle: "h23"
115
+ });
116
+ return T.set(t, o), o;
117
+ }, v = (e, t) => _(t).formatToParts(e).reduce((o, r) => (r.type !== "literal" && (o[r.type] = Number(r.value)), o), {}), I = (e, t = /* @__PURE__ */ new Date()) => {
118
+ const n = a(e) || u, o = v(t, n), r = Date.UTC(
119
+ o.year || 0,
120
+ (o.month || 1) - 1,
121
+ o.day || 1,
122
+ o.hour || 0,
123
+ o.minute || 0,
124
+ o.second || 0,
125
+ t.getMilliseconds()
126
+ );
127
+ return Math.round((r - t.getTime()) / 6e4);
128
+ }, w = (e, t = /* @__PURE__ */ new Date()) => {
129
+ const n = I(e, t), o = n >= 0 ? "+" : "-", r = Math.abs(n), s = Math.floor(r / 60), i = r % 60;
130
+ return `UTC${o}${String(s).padStart(2, "0")}:${String(
131
+ i
132
+ ).padStart(2, "0")}`;
133
+ }, K = (e, t = /* @__PURE__ */ new Date()) => `${e} (${w(e, t)})`, H = (e = /* @__PURE__ */ new Date()) => {
134
+ const t = new Set(
135
+ [y(), ...A, p.value].filter(
136
+ O
137
+ )
138
+ );
139
+ return Array.from(t).map((n) => {
140
+ const o = w(n, e);
141
+ return {
142
+ value: n,
143
+ label: `${n} (${o})`,
144
+ offset: o
145
+ };
146
+ });
147
+ };
90
148
  export {
91
- g as Storage,
92
- E as deepMerge,
93
- w as getCurrentLocale,
94
- C as getRouteLastVisibleParentMenu,
95
- D as hasRoutePermission,
96
- x as replaceName,
97
- v as tname
149
+ m as Storage,
150
+ U as deepMerge,
151
+ M as getCurrentLocale,
152
+ j as getRouteLastVisibleParentMenu,
153
+ K as getTimeZoneLabel,
154
+ H as getTimeZoneOptions,
155
+ x as hasRoutePermission,
156
+ F as replaceName,
157
+ R as setCurrentTimeZone,
158
+ z as tname,
159
+ B as useCurrentTimeZone
98
160
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mamba-layout",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "Shared Mamba Vue layout shell and standalone browser layout.",
5
5
  "private": false,
6
6
  "type": "module",