@das-fed/utils 1.0.0 → 1.0.2

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 (66) hide show
  1. package/api-services/index.js +6840 -19720
  2. package/api-services/modules/app-manage.js +6966 -6
  3. package/api-services/modules/authentication.js +6966 -6
  4. package/api-services/modules/bems.js +6970 -11
  5. package/api-services/modules/contract.js +6966 -6
  6. package/api-services/modules/duty-manage.js +6970 -10
  7. package/api-services/modules/enterpriseright.js +6966 -6
  8. package/api-services/modules/file.js +7108 -353
  9. package/api-services/modules/gateway-edge.js +6966 -6
  10. package/api-services/modules/index.js +7163 -437
  11. package/api-services/modules/iot.js +6979 -19
  12. package/api-services/modules/justauth.js +6967 -7
  13. package/api-services/modules/knowledge.js +6966 -6
  14. package/api-services/modules/link.js +6966 -6
  15. package/api-services/modules/permission.js +6966 -6
  16. package/api-services/modules/platformManage.js +6974 -14
  17. package/api-services/modules/portal.js +6966 -6
  18. package/api-services/modules/space-manage.js +6966 -6
  19. package/api-services/modules/super-admin.js +6969 -9
  20. package/api-services/modules/supplier.js +6968 -8
  21. package/api-services/modules/supplychain-manage.js +6966 -6
  22. package/api-services/modules/systemConfiguration.js +6966 -6
  23. package/api-services/modules/tool.js +6966 -6
  24. package/api-services/src/create-service.js +6840 -19720
  25. package/api-services/src/sso.js +1711 -157
  26. package/api-services/src/util.js +1466 -19
  27. package/atob/index.js +9 -10
  28. package/common-info/getIframeUrl.js +14 -11
  29. package/common-info/index.js +194 -269
  30. package/common-info/setInfoFromUrl.js +60 -128
  31. package/common-tools/arr-tools.js +6 -13
  32. package/common-tools/date-format.js +18 -21
  33. package/common-tools/get-url-params.js +47 -88
  34. package/common-tools/handle-data.js +3 -4
  35. package/common-tools/index.js +108 -204
  36. package/common-tools/nest-tree-format.js +22 -49
  37. package/common-tools/obj-tools.js +17 -18
  38. package/common-tools/setHtmlMinWH.js +6 -10
  39. package/common-tools/throttled.js +7 -16
  40. package/config/index.js +8 -25
  41. package/curring-http/index.js +5150 -17289
  42. package/directive/auth.js +205 -97
  43. package/directive/clickOutside.js +25 -49
  44. package/directive/hoverInside.js +18 -35
  45. package/directive/index.js +238 -159
  46. package/directive/utils.js +6 -11
  47. package/dom-check-in/index.js +7 -15
  48. package/dom-watcher/index.js +7 -8
  49. package/hooks/popup-manager/use-zindex.js +17 -36
  50. package/index.js +242 -191
  51. package/load-js/index.js +14 -20
  52. package/oss/index.js +15 -15
  53. package/package.json +7 -11
  54. package/pinyin-first-character/index.js +25011 -12217
  55. package/process-engine-info/index.js +8 -10
  56. package/pure-image-src/index.js +3 -29
  57. package/set-personal-info/index.js +1566 -16
  58. package/size-watcher/index.js +17 -24
  59. package/style/index.js +62 -103
  60. package/style/math.js +16 -31
  61. package/style/style.js +49 -72
  62. package/token-tools/index.js +1594 -152
  63. package/vue/hooks/use-model-value.js +9 -10
  64. package/vue/index.js +9 -10
  65. package/webSocket-service/index.js +162 -135
  66. package/with-install/index.js +5 -7
@@ -1,183 +1,262 @@
1
- import { getUrlParams, flatTree } from '@das-fed/utils/common-tools';
2
- import { getTabInfo, getSubApps, getPageAuth } from '@das-fed/utils/common-info';
3
-
4
- const getEl = async (el, options) => {
5
- let res = el;
6
- if (options?.target) {
7
- if (typeof options.target === "string")
8
- res = options.target;
9
- if (typeof options.target === "function")
10
- res = await options.target(el);
1
+ import { ref as w } from "vue";
2
+ const p = (e, t) => {
3
+ let n = window.location.search || "";
4
+ if (e && e !== location.href) {
5
+ const r = e.indexOf("?");
6
+ r !== -1 ? n = e.slice(r) : n = "";
7
+ }
8
+ const s = new URLSearchParams(n);
9
+ if (t)
10
+ return s.get(t);
11
+ {
12
+ let r = {};
13
+ for (let [o, c] of s.entries())
14
+ r[o] = c;
15
+ return r;
16
+ }
17
+ }, y = (e, t = "children", n = !0) => Array.isArray(e) && e.length ? e.reduce((s, r) => {
18
+ let o = r[t], c = { ...r };
19
+ return n && delete c[t], o && o.length ? s.concat(c, y(o, t, n)) : s.concat(c);
20
+ }, []) : [];
21
+ /*! js-cookie v3.0.5 | MIT */
22
+ function g(e) {
23
+ for (var t = 1; t < arguments.length; t++) {
24
+ var n = arguments[t];
25
+ for (var s in n)
26
+ e[s] = n[s];
27
+ }
28
+ return e;
29
+ }
30
+ var C = {
31
+ read: function(e) {
32
+ return e[0] === '"' && (e = e.slice(1, -1)), e.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
33
+ },
34
+ write: function(e) {
35
+ return encodeURIComponent(e).replace(
36
+ /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,
37
+ decodeURIComponent
38
+ );
11
39
  }
12
- return res;
13
40
  };
14
-
15
- const hasBtnAuth = (btnList, code) => {
16
- if (!btnList || !code)
17
- return false;
18
- if (typeof code === "string") {
19
- const currentItem = btnList.find((item) => item.code === code);
20
- return !!currentItem;
21
- } else {
22
- let flag = false;
23
- for (let value of code) {
24
- const currentItem = btnList.find((item) => item.code === value);
25
- if (currentItem) {
26
- flag = true;
27
- break;
28
- }
41
+ function _(e, t) {
42
+ function n(r, o, c) {
43
+ if (!(typeof document > "u")) {
44
+ c = g({}, t, c), typeof c.expires == "number" && (c.expires = new Date(Date.now() + c.expires * 864e5)), c.expires && (c.expires = c.expires.toUTCString()), r = encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
45
+ var a = "";
46
+ for (var i in c)
47
+ c[i] && (a += "; " + i, c[i] !== !0 && (a += "=" + c[i].split(";")[0]));
48
+ return document.cookie = r + "=" + e.write(o, r) + a;
29
49
  }
30
- return flag;
31
50
  }
32
- };
33
- const hasPermission = (options) => {
34
- const code = options?.code ?? "";
35
- const path = options?.path ?? location.pathname;
36
- const applicationCode = options?.applicationCode ?? "";
37
- let menuCode = "";
38
- if (window.__IN_MICRO_APP__) {
39
- menuCode = options?.menuCode ? options.menuCode : getUrlParams(location.href, "menu");
40
- } else {
41
- menuCode = options?.menuCode ? options.menuCode : getTabInfo().currentTab?.code;
51
+ function s(r) {
52
+ if (!(typeof document > "u" || arguments.length && !r)) {
53
+ for (var o = document.cookie ? document.cookie.split("; ") : [], c = {}, a = 0; a < o.length; a++) {
54
+ var i = o[a].split("="), u = i.slice(1).join("=");
55
+ try {
56
+ var f = decodeURIComponent(i[0]);
57
+ if (c[f] = e.read(u, f), r === f)
58
+ break;
59
+ } catch {
60
+ }
61
+ }
62
+ return r ? c[r] : c;
63
+ }
42
64
  }
43
- if (!menuCode) {
44
- const currentMenus = getSubApps().currentSubApp?.menus ?? [];
45
- if (currentMenus && currentMenus.length) {
46
- const flatMenus = flatTree(currentMenus).filter((item) => item?.routeUrl);
47
- if (flatMenus && flatMenus.length) {
48
- const currentMenu = flatMenus.find((item) => {
49
- if (item?.applicationPath) {
50
- return path?.includes("/" + item.applicationPath + item.routeUrl);
51
- } else {
52
- return path?.includes(item.routeUrl);
53
- }
54
- });
55
- if (currentMenu)
56
- menuCode = currentMenu?.code ?? "";
65
+ return Object.create(
66
+ {
67
+ set: n,
68
+ get: s,
69
+ remove: function(r, o) {
70
+ n(
71
+ r,
72
+ "",
73
+ g({}, o, {
74
+ expires: -1
75
+ })
76
+ );
77
+ },
78
+ withAttributes: function(r) {
79
+ return _(this.converter, g({}, this.attributes, r));
80
+ },
81
+ withConverter: function(r) {
82
+ return _(g({}, this.converter, r), this.attributes);
57
83
  }
84
+ },
85
+ {
86
+ attributes: { value: Object.freeze(t) },
87
+ converter: { value: Object.freeze(e) }
58
88
  }
89
+ );
90
+ }
91
+ var m = _(C, { path: "/" });
92
+ const k = (e) => {
93
+ var t = encodeURIComponent(e);
94
+ return t = btoa(t), t;
95
+ }, v = () => {
96
+ let t = { ...(window == null ? void 0 : window.config) || {} };
97
+ t.rootContainer || (t.rootContainer = "#app"), t.baseURL || (t.baseURL = location.origin), t.ossBaseURL || (t.ossBaseURL = "/oss"), t.ossBaseURL.startsWith("/") && (t.ossBaseURL = `${t.baseURL}/oss`), t.ssoBaseURL || (t.ssoBaseURL = t.baseURL);
98
+ let { microAppName: n, publicPath: s, mainAppName: r } = t;
99
+ return n && !0 && !s && (s = `/${n}/`.replace(/\/\//g, "/")), s || (s = "/"), t.publicPath = s, t.autoOssBucket || (t.autoOssBucket = r || n), t;
100
+ };
101
+ w(!1);
102
+ v();
103
+ k("das123"), +/* @__PURE__ */ new Date();
104
+ const S = () => {
105
+ const e = new URL(location.href).searchParams, t = e.get("token") || e.get("accessToken") || e.get("accesstoken") || "";
106
+ if (t) {
107
+ const n = JSON.stringify({ access_token: t });
108
+ sessionStorage.setItem("accessToken", t), sessionStorage.setItem("tokenInfo", n), m.set("accessToken", t), m.set("accessTokenInfo", n);
59
109
  }
60
- let flag = false;
61
- if (code) {
62
- const btnList = getPageAuth(menuCode, applicationCode) ?? [];
63
- flag = hasBtnAuth(btnList, code);
110
+ }, L = () => {
111
+ const e = JSON.parse(sessionStorage.getItem("projectInfo") || "{}"), t = new URL(location.href).searchParams, n = t.get("project") || t.get("projectId") || "";
112
+ if (!n)
113
+ return;
114
+ const s = t.get("projectParent") || t.get("projectParentId") || (e == null ? void 0 : e.parentId) || "", r = t.get("projectName") || (e == null ? void 0 : e.name) || "";
115
+ sessionStorage.setItem("project", n), sessionStorage.setItem("projectInfo", JSON.stringify({ ...e, id: n, name: r, parentId: s }));
116
+ }, P = () => m.get("accessToken") ?? "", h = (e, t) => {
117
+ const n = "permission-btn", s = v(), r = A(), o = p(location.href, "app") || "", c = t || o || (window.__IN_MICRO_APP__ ? r.currentSubAppCode : s.title);
118
+ if (!c)
119
+ return;
120
+ const a = p(location.href, "menu") || "", i = e || a || (window.__IN_MICRO_APP__ ? r.currentSubApp.currentMenuCode : JSON.parse(sessionStorage.getItem(`${s.title}-tabs`) || "{}").currentTab.code), u = JSON.parse(sessionStorage.getItem(n) || "{}");
121
+ if (!u || JSON.stringify(u) === "{}")
122
+ return;
123
+ const f = u[c][i];
124
+ return f && f.length ? f : u[c]["origin-auth"] ? u[c]["origin-auth"][i] ?? [] : [];
125
+ }, A = () => {
126
+ var s;
127
+ if (!window.__IN_MICRO_APP__)
128
+ return {};
129
+ const e = JSON.parse(sessionStorage.getItem("subApps") || "{}"), t = ((s = e.appcategorys) == null ? void 0 : s.map((r) => r.apps).flat()) ?? [];
130
+ return {
131
+ appcategorys: e.appcategorys ?? [],
132
+ currentSubApp: e.currentSubApp ?? {},
133
+ currentSubAppCode: e.currentSubAppCode ?? "",
134
+ flatSubAppList: t,
135
+ subAppList: e.subAppList ?? []
136
+ };
137
+ }, R = () => {
138
+ const e = v();
139
+ let t = {};
140
+ if (window.__IN_MICRO_APP__) {
141
+ const n = JSON.parse(sessionStorage.getItem("tabs") || "{}");
142
+ t = {
143
+ activeKey: n.activeKey ?? "",
144
+ currentTab: n.currentTab ?? {},
145
+ tabMap: n.tabMap ?? {}
146
+ };
64
147
  } else {
65
- flag = !!getPageAuth(menuCode, applicationCode);
148
+ const n = JSON.parse(sessionStorage.getItem(`${e.title}-tabs`) || "{}");
149
+ t = {
150
+ activeKey: n.activeKey ?? "",
151
+ currentTab: n.currentTab ?? {},
152
+ tabList: n.tabList ?? []
153
+ };
66
154
  }
67
- return flag;
155
+ return t;
68
156
  };
69
- const removeEl = (el, type) => {
70
- if (type === "hide") {
71
- el.classList.add("is-hide");
72
- } else {
73
- el.setAttribute("disabled", "");
74
- el.classList.add("is-disabled");
157
+ P() || S();
158
+ L();
159
+ const d = async (e, t) => {
160
+ let n = e;
161
+ return t != null && t.target && (typeof t.target == "string" && (n = t.target), typeof t.target == "function" && (n = await t.target(e))), n;
162
+ }, U = (e, t) => {
163
+ if (!e || !t)
164
+ return !1;
165
+ if (typeof t == "string")
166
+ return !!e.find((s) => s.code === t);
167
+ {
168
+ let n = !1;
169
+ for (let s of t)
170
+ if (e.find((o) => o.code === s)) {
171
+ n = !0;
172
+ break;
173
+ }
174
+ return n;
75
175
  }
76
- };
77
- const addEl = (el, type) => {
78
- if (type === "hide") {
79
- el.classList.remove("is-hide");
80
- } else {
81
- el.removeAttribute("disabled");
82
- el.classList.remove("is-disabled");
176
+ }, I = (e) => {
177
+ var c, a;
178
+ const t = (e == null ? void 0 : e.code) ?? "", n = (e == null ? void 0 : e.path) ?? location.pathname, s = (e == null ? void 0 : e.applicationCode) ?? "";
179
+ let r = "";
180
+ if (window.__IN_MICRO_APP__ ? r = e != null && e.menuCode ? e.menuCode : p(location.href, "menu") : r = e != null && e.menuCode ? e.menuCode : (c = R().currentTab) == null ? void 0 : c.code, !r) {
181
+ const i = ((a = A().currentSubApp) == null ? void 0 : a.menus) ?? [];
182
+ if (i && i.length) {
183
+ const u = y(i).filter((f) => f == null ? void 0 : f.routeUrl);
184
+ if (u && u.length) {
185
+ const f = u.find((l) => l != null && l.applicationPath ? n == null ? void 0 : n.includes("/" + l.applicationPath + l.routeUrl) : n == null ? void 0 : n.includes(l.routeUrl));
186
+ f && (r = (f == null ? void 0 : f.code) ?? "");
187
+ }
188
+ }
83
189
  }
84
- };
85
- const vAuth = (el, binding) => {
86
- let options = (el ? binding.value : binding) || {};
87
- if (typeof options === "string")
88
- options = { code: options };
89
- const type = options?.type ?? "hide";
90
- const isPermission = hasPermission(options);
91
- if (el) {
92
- if (!binding.oldValue) {
93
- if (!isPermission)
94
- getEl(el, options).then((element) => {
95
- removeEl(element, type);
96
- });
97
- } else {
98
- const oldHasPermission = hasPermission(binding.oldValue);
99
- const newHasPermission = isPermission;
100
- if (oldHasPermission === newHasPermission)
190
+ let o = !1;
191
+ if (t) {
192
+ const i = h(r, s) ?? [];
193
+ o = U(i, t);
194
+ } else
195
+ o = !!h(r, s);
196
+ return o;
197
+ }, b = (e, t) => {
198
+ t === "hide" ? e.classList.add("is-hide") : (e.setAttribute("disabled", ""), e.classList.add("is-disabled"));
199
+ }, O = (e, t) => {
200
+ t === "hide" ? e.classList.remove("is-hide") : (e.removeAttribute("disabled"), e.classList.remove("is-disabled"));
201
+ }, T = (e, t) => {
202
+ let n = (e ? t.value : t) || {};
203
+ typeof n == "string" && (n = { code: n });
204
+ const s = (n == null ? void 0 : n.type) ?? "hide", r = I(n);
205
+ if (e)
206
+ if (!t.oldValue)
207
+ r || d(e, n).then((o) => {
208
+ b(o, s);
209
+ });
210
+ else {
211
+ const o = I(t.oldValue), c = r;
212
+ if (o === c)
101
213
  return;
102
- getEl(el, options).then((element) => {
103
- if (newHasPermission) {
104
- addEl(element, type);
105
- } else {
106
- removeEl(element, type);
107
- }
214
+ d(e, n).then((a) => {
215
+ c ? O(a, s) : b(a, s);
108
216
  });
109
217
  }
110
- }
111
- return isPermission;
112
- };
113
-
114
- const vClickOutside = {
115
- mounted: async (el, binding) => {
116
- const options = binding.value;
117
- const targetEl = await getEl(el, options);
118
- function eventHandler(e) {
119
- let flag = true;
120
- if (Array.isArray(targetEl)) {
121
- for (let dom of targetEl) {
122
- dom.__click_outside__ = eventHandler;
123
- if (dom.contains(e.target))
124
- flag = false;
125
- }
126
- } else {
127
- if (targetEl.contains(e.target)) {
128
- flag = false;
129
- }
130
- targetEl.__click_outside__ = eventHandler;
131
- }
132
- if (flag) {
133
- if (options?.fn && typeof options?.fn === "function") {
134
- options?.fn(e);
135
- }
136
- }
218
+ return r;
219
+ }, N = {
220
+ mounted: async (e, t) => {
221
+ const n = t.value, s = await d(e, n);
222
+ function r(o) {
223
+ let c = !0;
224
+ if (Array.isArray(s))
225
+ for (let a of s)
226
+ a.__click_outside__ = r, a.contains(o.target) && (c = !1);
227
+ else
228
+ s.contains(o.target) && (c = !1), s.__click_outside__ = r;
229
+ c && n != null && n.fn && typeof (n == null ? void 0 : n.fn) == "function" && (n == null || n.fn(o));
137
230
  }
138
- document.addEventListener("click", eventHandler);
231
+ document.addEventListener("click", r);
139
232
  },
140
- beforeUnmount: async (el, binding) => {
141
- const options = binding.value;
142
- const targetEl = await getEl(el, options);
143
- if (Array.isArray(targetEl)) {
144
- for (let dom of targetEl) {
145
- document.removeEventListener("click", dom.__click_outside__);
146
- delete dom.__click_outside__;
147
- }
148
- } else {
149
- document.removeEventListener("click", targetEl.__click_outside__);
150
- delete targetEl.__click_outside__;
151
- }
233
+ beforeUnmount: async (e, t) => {
234
+ const n = t.value, s = await d(e, n);
235
+ if (Array.isArray(s))
236
+ for (let r of s)
237
+ document.removeEventListener("click", r.__click_outside__), delete r.__click_outside__;
238
+ else
239
+ document.removeEventListener("click", s.__click_outside__), delete s.__click_outside__;
152
240
  }
153
- };
154
-
155
- const vHoverInside = {
156
- mounted: async (el, binding) => {
157
- const options = binding.value;
158
- const targetEl = await getEl(el, options);
159
- function eventHandler(flag, e) {
160
- targetEl._inside_event = eventHandler;
161
- if (typeof options === "function") {
162
- options(flag, e);
163
- } else if (options?.fn && typeof options?.fn === "function") {
164
- options?.fn(flag, e);
165
- }
241
+ }, B = {
242
+ mounted: async (e, t) => {
243
+ const n = t.value, s = await d(e, n);
244
+ function r(o, c) {
245
+ s._inside_event = r, typeof n == "function" ? n(o, c) : n != null && n.fn && typeof (n == null ? void 0 : n.fn) == "function" && (n == null || n.fn(o, c));
166
246
  }
167
- targetEl.addEventListener("mouseenter", (e) => {
168
- eventHandler(true, e);
169
- });
170
- targetEl.addEventListener("mouseleave", (e) => {
171
- eventHandler(false, e);
247
+ s.addEventListener("mouseenter", (o) => {
248
+ r(!0, o);
249
+ }), s.addEventListener("mouseleave", (o) => {
250
+ r(!1, o);
172
251
  });
173
252
  },
174
- beforeUnmount: async (el, binding) => {
175
- const options = binding.value;
176
- const targetEl = await getEl(el, options);
177
- targetEl.addEventListener("mouseenter", targetEl._inside_event);
178
- targetEl.addEventListener("mouseleave", targetEl._inside_event);
179
- delete targetEl._inside_event;
253
+ beforeUnmount: async (e, t) => {
254
+ const n = t.value, s = await d(e, n);
255
+ s.addEventListener("mouseenter", s._inside_event), s.addEventListener("mouseleave", s._inside_event), delete s._inside_event;
180
256
  }
181
257
  };
182
-
183
- export { vAuth, vClickOutside, vHoverInside };
258
+ export {
259
+ T as vAuth,
260
+ N as vClickOutside,
261
+ B as vHoverInside
262
+ };
@@ -1,12 +1,7 @@
1
- const getEl = async (el, options) => {
2
- let res = el;
3
- if (options?.target) {
4
- if (typeof options.target === "string")
5
- res = options.target;
6
- if (typeof options.target === "function")
7
- res = await options.target(el);
8
- }
9
- return res;
1
+ const a = async (r, t) => {
2
+ let e = r;
3
+ return t != null && t.target && (typeof t.target == "string" && (e = t.target), typeof t.target == "function" && (e = await t.target(r))), e;
4
+ };
5
+ export {
6
+ a as getEl
10
7
  };
11
-
12
- export { getEl };
@@ -1,16 +1,8 @@
1
- const domCheckIn = (dom) => {
2
- const event = window.event;
3
- let x = Number(event.clientX);
4
- let y = Number(event.clientY);
5
- let div_x = Number(dom.getBoundingClientRect().left);
6
- let div_x_width = Number(dom.getBoundingClientRect().left + dom.clientWidth);
7
- let div_y = Number(dom.getBoundingClientRect().top);
8
- let div_y_height = Number(dom.getBoundingClientRect().top + dom.clientHeight);
9
- if (x > div_x && x < div_x_width && y > div_y && y < div_y_height) {
10
- return true;
11
- } else {
12
- return false;
13
- }
1
+ const g = (e) => {
2
+ const t = window.event;
3
+ let n = Number(t.clientX), i = Number(t.clientY), l = Number(e.getBoundingClientRect().left), u = Number(e.getBoundingClientRect().left + e.clientWidth), r = Number(e.getBoundingClientRect().top), c = Number(e.getBoundingClientRect().top + e.clientHeight);
4
+ return n > l && n < u && i > r && i < c;
5
+ };
6
+ export {
7
+ g as domCheckIn
14
8
  };
15
-
16
- export { domCheckIn };
@@ -1,10 +1,9 @@
1
- const DomWatcher = (cb, dom, config = { attributes: true, childList: true, subtree: true }) => {
2
- const watchDom = dom || document.body;
3
- const domObserver = new MutationObserver((mutationsList) => {
4
- cb(mutationsList);
1
+ const c = (e, r, o = { attributes: !0, childList: !0, subtree: !0 }) => {
2
+ const s = r || document.body, t = new MutationObserver((u) => {
3
+ e(u);
5
4
  });
6
- domObserver.observe(watchDom, config);
7
- return domObserver;
5
+ return t.observe(s, o), t;
6
+ };
7
+ export {
8
+ c as DomWatcher
8
9
  };
9
-
10
- export { DomWatcher };
@@ -1,41 +1,22 @@
1
- import { ref, getCurrentInstance, inject, computed, unref } from 'vue';
2
-
3
- const isNumber = (val) => typeof val === "number";
4
-
5
- const zIndex = ref(0);
6
- const defaultInitialZIndex = 2e3;
7
- const zIndexContextKey = Symbol("zIndexContextKey");
8
- const useZIndex$1 = (zIndexOverrides) => {
9
- const zIndexInjection = zIndexOverrides || (getCurrentInstance() ? inject(zIndexContextKey, void 0) : void 0);
10
- const initialZIndex = computed(() => {
11
- const zIndexFromInjection = unref(zIndexInjection);
12
- return isNumber(zIndexFromInjection) ? zIndexFromInjection : defaultInitialZIndex;
13
- });
14
- const currentZIndex = computed(() => initialZIndex.value + zIndex.value);
15
- const nextZIndex = () => {
16
- zIndex.value++;
17
- return currentZIndex.value;
18
- };
1
+ import { ref as I, getCurrentInstance as u, inject as s, computed as e, unref as i } from "vue";
2
+ const Z = (n) => typeof n == "number", d = I(0), l = 2e3, a = Symbol("zIndexContextKey"), m = (n) => {
3
+ const t = n || (u() ? s(a, void 0) : void 0), r = e(() => {
4
+ const c = i(t);
5
+ return Z(c) ? c : l;
6
+ }), x = e(() => r.value + d.value);
19
7
  return {
20
- initialZIndex,
21
- currentZIndex,
22
- nextZIndex
23
- };
24
- };
25
-
26
- const elementZindex = useZIndex$1();
27
- const useZIndex = () => {
28
- const initialZIndex = computed(() => elementZindex.initialZIndex.value);
29
- const currentZIndex = computed(() => elementZindex.currentZIndex.value);
30
- const nextZIndex = () => {
31
- const currentZIndex2 = elementZindex.nextZIndex();
32
- return currentZIndex2;
8
+ initialZIndex: r,
9
+ currentZIndex: x,
10
+ nextZIndex: () => (d.value++, x.value)
33
11
  };
12
+ }, o = m(), z = () => {
13
+ const n = e(() => o.initialZIndex.value), t = e(() => o.currentZIndex.value);
34
14
  return {
35
- initialZIndex,
36
- currentZIndex,
37
- nextZIndex
15
+ initialZIndex: n,
16
+ currentZIndex: t,
17
+ nextZIndex: () => o.nextZIndex()
38
18
  };
39
19
  };
40
-
41
- export { useZIndex };
20
+ export {
21
+ z as useZIndex
22
+ };