mamba-layout 0.1.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.
Files changed (169) hide show
  1. package/README.md +47 -0
  2. package/dist/_virtual/_plugin-vue_export-helper.js +9 -0
  3. package/dist/assets/logo.png.js +4 -0
  4. package/dist/components/UserAvatar/index.d.ts +2 -0
  5. package/dist/components/UserAvatar/index.js +5 -0
  6. package/dist/components/UserAvatar/src/UserAvatar.css +1 -0
  7. package/dist/components/UserAvatar/src/UserAvatar.vue.d.ts +9 -0
  8. package/dist/components/UserAvatar/src/UserAvatar.vue.js +7 -0
  9. package/dist/components/UserAvatar/src/UserAvatar.vue2.js +61 -0
  10. package/dist/components/index.d.ts +2 -0
  11. package/dist/components/index.js +51 -0
  12. package/dist/index.d.ts +13 -0
  13. package/dist/index.js +80 -0
  14. package/dist/layout/BaseLayout.css +1 -0
  15. package/dist/layout/BaseLayout.vue.d.ts +23 -0
  16. package/dist/layout/BaseLayout.vue.js +7 -0
  17. package/dist/layout/BaseLayout.vue2.js +75 -0
  18. package/dist/layout/components/AppSelect.css +1 -0
  19. package/dist/layout/components/AppSelect.vue.d.ts +2 -0
  20. package/dist/layout/components/AppSelect.vue.js +7 -0
  21. package/dist/layout/components/AppSelect.vue2.js +69 -0
  22. package/dist/layout/components/AsideBar.css +1 -0
  23. package/dist/layout/components/AsideBar.vue.d.ts +21 -0
  24. package/dist/layout/components/AsideBar.vue.js +7 -0
  25. package/dist/layout/components/AsideBar.vue2.js +49 -0
  26. package/dist/layout/components/AsideSubMenuItem.vue.d.ts +25 -0
  27. package/dist/layout/components/AsideSubMenuItem.vue.js +84 -0
  28. package/dist/layout/components/AsideSubMenuItem.vue2.js +4 -0
  29. package/dist/layout/components/AsideSubMenus.vue.d.ts +16 -0
  30. package/dist/layout/components/AsideSubMenus.vue.js +36 -0
  31. package/dist/layout/components/AsideSubMenus.vue2.js +4 -0
  32. package/dist/layout/components/AsideTabMenus.vue.d.ts +2 -0
  33. package/dist/layout/components/AsideTabMenus.vue.js +41 -0
  34. package/dist/layout/components/AsideTabMenus.vue2.js +4 -0
  35. package/dist/layout/components/AsideUser.vue.d.ts +2 -0
  36. package/dist/layout/components/AsideUser.vue.js +58 -0
  37. package/dist/layout/components/AsideUser.vue2.js +4 -0
  38. package/dist/layout/components/HeaderBar.css +1 -0
  39. package/dist/layout/components/HeaderBar.vue.d.ts +17 -0
  40. package/dist/layout/components/HeaderBar.vue.js +7 -0
  41. package/dist/layout/components/HeaderBar.vue2.js +55 -0
  42. package/dist/layout/components/HeaderMenuToggle.vue.d.ts +25 -0
  43. package/dist/layout/components/HeaderMenuToggle.vue.js +40 -0
  44. package/dist/layout/components/HeaderMenuToggle.vue2.js +4 -0
  45. package/dist/layout/components/LanguageSelect.css +1 -0
  46. package/dist/layout/components/LanguageSelect.vue.d.ts +22 -0
  47. package/dist/layout/components/LanguageSelect.vue.js +8 -0
  48. package/dist/layout/components/LanguageSelect.vue2.js +101 -0
  49. package/dist/layout/components/LanguageSelect2.css +1 -0
  50. package/dist/layout/components/LayoutBreadcrumb.css +1 -0
  51. package/dist/layout/components/LayoutBreadcrumb.vue.d.ts +29 -0
  52. package/dist/layout/components/LayoutBreadcrumb.vue.js +7 -0
  53. package/dist/layout/components/LayoutBreadcrumb.vue2.js +189 -0
  54. package/dist/layout/components/MenuDrawer.css +1 -0
  55. package/dist/layout/components/MenuDrawer.vue.d.ts +12 -0
  56. package/dist/layout/components/MenuDrawer.vue.js +163 -0
  57. package/dist/layout/components/MenuDrawer.vue3.js +5 -0
  58. package/dist/layout/components/MenuItemIcon.css +1 -0
  59. package/dist/layout/components/MenuItemIcon.vue.d.ts +7 -0
  60. package/dist/layout/components/MenuItemIcon.vue.js +7 -0
  61. package/dist/layout/components/MenuItemIcon.vue2.js +23 -0
  62. package/dist/layout/components/NavIconBtn.css +1 -0
  63. package/dist/layout/components/NavIconBtn.vue.d.ts +26 -0
  64. package/dist/layout/components/NavIconBtn.vue.js +7 -0
  65. package/dist/layout/components/NavIconBtn.vue2.js +23 -0
  66. package/dist/layout/components/SHeaderRight.css +1 -0
  67. package/dist/layout/components/SHeaderRight.vue.d.ts +2 -0
  68. package/dist/layout/components/SHeaderRight.vue.js +7 -0
  69. package/dist/layout/components/SHeaderRight.vue2.js +80 -0
  70. package/dist/layout/components/ThemeToggle.css +1 -0
  71. package/dist/layout/components/ThemeToggle.vue.d.ts +2 -0
  72. package/dist/layout/components/ThemeToggle.vue.js +7 -0
  73. package/dist/layout/components/ThemeToggle.vue2.js +30 -0
  74. package/dist/layout/components/TimezoneSelect.css +1 -0
  75. package/dist/layout/components/TimezoneSelect.vue.d.ts +7 -0
  76. package/dist/layout/components/TimezoneSelect.vue.js +8 -0
  77. package/dist/layout/components/TimezoneSelect.vue2.js +78 -0
  78. package/dist/layout/components/TimezoneSelect2.css +1 -0
  79. package/dist/layout/components/UserInfo.css +1 -0
  80. package/dist/layout/components/UserInfo.vue.d.ts +2 -0
  81. package/dist/layout/components/UserInfo.vue.js +8 -0
  82. package/dist/layout/components/UserInfo.vue2.js +111 -0
  83. package/dist/layout/components/UserInfo2.css +1 -0
  84. package/dist/layout/components/index.d.ts +23 -0
  85. package/dist/layout/components/index.js +49 -0
  86. package/dist/layout/components/mobile/AppSelectMobile.vue.d.ts +2 -0
  87. package/dist/layout/components/mobile/AppSelectMobile.vue.js +60 -0
  88. package/dist/layout/components/mobile/AppSelectMobile.vue2.js +4 -0
  89. package/dist/layout/components/mobile/AsideBarMobile.css +1 -0
  90. package/dist/layout/components/mobile/AsideBarMobile.vue.d.ts +21 -0
  91. package/dist/layout/components/mobile/AsideBarMobile.vue.js +7 -0
  92. package/dist/layout/components/mobile/AsideBarMobile.vue2.js +47 -0
  93. package/dist/layout/components/mobile/AsideUserMobile.css +1 -0
  94. package/dist/layout/components/mobile/AsideUserMobile.vue.d.ts +2 -0
  95. package/dist/layout/components/mobile/AsideUserMobile.vue.js +7 -0
  96. package/dist/layout/components/mobile/AsideUserMobile.vue2.js +56 -0
  97. package/dist/layout/components/mobile/AsideUserMobilePopover.css +1 -0
  98. package/dist/layout/components/mobile/AsideUserMobilePopover.vue.d.ts +17 -0
  99. package/dist/layout/components/mobile/AsideUserMobilePopover.vue.js +7 -0
  100. package/dist/layout/components/mobile/AsideUserMobilePopover.vue2.js +52 -0
  101. package/dist/layout/components/mobile/HeaderRightMobile.css +1 -0
  102. package/dist/layout/components/mobile/HeaderRightMobile.vue.d.ts +2 -0
  103. package/dist/layout/components/mobile/HeaderRightMobile.vue.js +7 -0
  104. package/dist/layout/components/mobile/HeaderRightMobile.vue2.js +50 -0
  105. package/dist/layout/components/mobile/MobileMenuToggle.css +1 -0
  106. package/dist/layout/components/mobile/MobileMenuToggle.vue.d.ts +2 -0
  107. package/dist/layout/components/mobile/MobileMenuToggle.vue.js +7 -0
  108. package/dist/layout/components/mobile/MobileMenuToggle.vue2.js +31 -0
  109. package/dist/layout/hooks/index.d.ts +4 -0
  110. package/dist/layout/hooks/index.js +17 -0
  111. package/dist/layout/hooks/useApp.d.ts +6 -0
  112. package/dist/layout/hooks/useApp.js +20 -0
  113. package/dist/layout/hooks/useSetting.d.ts +62 -0
  114. package/dist/layout/hooks/useSetting.js +24 -0
  115. package/dist/layout/hooks/useState.d.ts +763 -0
  116. package/dist/layout/hooks/useState.js +99 -0
  117. package/dist/layout/hooks/useTheme.d.ts +15 -0
  118. package/dist/layout/hooks/useTheme.js +44 -0
  119. package/dist/layout/utils/index.d.ts +7 -0
  120. package/dist/layout/utils/index.js +59 -0
  121. package/dist/layout.css +1 -0
  122. package/dist/layout.es.js +53770 -0
  123. package/dist/layout.global.js +78 -0
  124. package/dist/locales/en/account.d.ts +10 -0
  125. package/dist/locales/en/account.js +12 -0
  126. package/dist/locales/en/admin.d.ts +207 -0
  127. package/dist/locales/en/admin.js +209 -0
  128. package/dist/locales/en/common.d.ts +40 -0
  129. package/dist/locales/en/common.js +42 -0
  130. package/dist/locales/en/components.d.ts +37 -0
  131. package/dist/locales/en/components.js +39 -0
  132. package/dist/locales/en/constant.d.ts +151 -0
  133. package/dist/locales/en/constant.js +153 -0
  134. package/dist/locales/en/filterBox.d.ts +11 -0
  135. package/dist/locales/en/filterBox.js +13 -0
  136. package/dist/locales/en/index.d.ts +487 -0
  137. package/dist/locales/en/index.js +22 -0
  138. package/dist/locales/en/instanceForm.d.ts +17 -0
  139. package/dist/locales/en/instanceForm.js +19 -0
  140. package/dist/locales/en/password.d.ts +18 -0
  141. package/dist/locales/en/password.js +20 -0
  142. package/dist/locales/index.d.ts +973 -0
  143. package/dist/locales/index.js +12 -0
  144. package/dist/locales/messages.d.ts +973 -0
  145. package/dist/locales/messages.js +9 -0
  146. package/dist/locales/zh-cn/account.d.ts +10 -0
  147. package/dist/locales/zh-cn/account.js +12 -0
  148. package/dist/locales/zh-cn/admin.d.ts +205 -0
  149. package/dist/locales/zh-cn/admin.js +207 -0
  150. package/dist/locales/zh-cn/common.d.ts +40 -0
  151. package/dist/locales/zh-cn/common.js +42 -0
  152. package/dist/locales/zh-cn/components.d.ts +37 -0
  153. package/dist/locales/zh-cn/components.js +39 -0
  154. package/dist/locales/zh-cn/constant.d.ts +151 -0
  155. package/dist/locales/zh-cn/constant.js +153 -0
  156. package/dist/locales/zh-cn/filterBox.d.ts +11 -0
  157. package/dist/locales/zh-cn/filterBox.js +13 -0
  158. package/dist/locales/zh-cn/index.d.ts +485 -0
  159. package/dist/locales/zh-cn/index.js +22 -0
  160. package/dist/locales/zh-cn/instanceForm.d.ts +17 -0
  161. package/dist/locales/zh-cn/instanceForm.js +19 -0
  162. package/dist/locales/zh-cn/password.d.ts +18 -0
  163. package/dist/locales/zh-cn/password.js +20 -0
  164. package/dist/standalone.d.ts +0 -0
  165. package/dist/utils/createContext.d.ts +8 -0
  166. package/dist/utils/createContext.js +14 -0
  167. package/dist/utils/repoUtils.d.ts +59 -0
  168. package/dist/utils/repoUtils.js +160 -0
  169. package/package.json +110 -0
@@ -0,0 +1,99 @@
1
+ import { ref as o, onActivated as j, onMounted as k, onUnmounted as H, watch as A } from "vue";
2
+ import { useRoute as N } from "vue-router";
3
+ import { createContext as O } from "../../utils/createContext.js";
4
+ import { replaceName as W, tname as $, getRouteLastVisibleParentMenu as U } from "../../utils/repoUtils.js";
5
+ import { useSetting as V } from "./useSetting.js";
6
+ const [Q, q] = O("LayoutRoot");
7
+ function X() {
8
+ const s = N(), h = o([]), r = o(), I = o(), c = o(""), i = o(""), M = o(""), m = V(), C = o(!0), E = o(!1), B = o(), d = () => {
9
+ var t;
10
+ return ((t = m.value.menus) == null ? void 0 : t.filter((v) => {
11
+ var n;
12
+ return ((n = v.meta) == null ? void 0 : n.appId) == i.value;
13
+ })) || [];
14
+ }, b = (t, v, n = 0, f) => {
15
+ var P, x, R, L;
16
+ const l = f ? [...f] : [], p = [], w = [];
17
+ for (const e in t) {
18
+ [...l], t[e];
19
+ const a = ((P = s.meta) == null ? void 0 : P.parent) || s.path, u = ((x = t[e].path) == null ? void 0 : x.replace(/\/:(\w+)/g, "/([^/]+)")) || "", T = new RegExp(`^${u}$`);
20
+ a == t[e].path ? p.push({ index: e, item: t[e] }) : T.test(a) && w.push({ index: e, item: t[e] });
21
+ }
22
+ const g = p.length > 0 ? p : w;
23
+ if (g.length > 0) {
24
+ const e = g[0], a = [...l];
25
+ a[n] = e.item, r.value = {
26
+ ...e.item,
27
+ paths: a.slice(0, n + 1)
28
+ }, i.value = ((R = e.item.meta) == null ? void 0 : R.appId) || "", I.value = v;
29
+ }
30
+ for (const e in t)
31
+ if (t[e].children && ((L = t[e].children) != null && L.length)) {
32
+ const a = t[e].children || [], u = [...l];
33
+ u[n] = t[e], b(a, t[e], n + 1, u);
34
+ }
35
+ M.value = s.meta.parentPath || U(
36
+ s.path.toLowerCase(),
37
+ m.value.menus || []
38
+ ) || s.path;
39
+ }, y = () => {
40
+ var f, l, p, w, g, P, x, R, L, e;
41
+ b(m.value.menus || []), i.value || (i.value = ((p = (l = (f = m.value.menus) == null ? void 0 : f.find(
42
+ (a) => {
43
+ var u;
44
+ return (u = a.path) == null ? void 0 : u.startsWith(c.value);
45
+ }
46
+ )) == null ? void 0 : l.meta) == null ? void 0 : p.appId) || "");
47
+ const t = ((w = r.value) == null ? void 0 : w.paths) || [], v = W(
48
+ $(((P = (g = r.value) == null ? void 0 : g.meta) == null ? void 0 : P.translations) || {}, "name")
49
+ ), n = ((x = r.value) == null ? void 0 : x.path) == ((R = t[1]) == null ? void 0 : R.path) ? "" : W($(((e = (L = t[1]) == null ? void 0 : L.meta) == null ? void 0 : e.translations) || {}, "name"));
50
+ document.title = v + (n ? ` - ${n}` : "");
51
+ }, z = () => {
52
+ c.value = "/" + (s.path.split("/").filter(Boolean).shift() || ""), y(), h.value = d();
53
+ };
54
+ z(), j(() => {
55
+ z();
56
+ });
57
+ const S = () => {
58
+ E.value = window.innerWidth < 1024, C.value = window.innerWidth > 1024;
59
+ };
60
+ return S(), k(() => {
61
+ window.addEventListener("resize", S);
62
+ }), H(() => {
63
+ window.removeEventListener("resize", S);
64
+ }), A(
65
+ () => c.value,
66
+ () => void (h.value = d())
67
+ ), A(
68
+ () => [s.path, m.value.menus],
69
+ () => {
70
+ M.value = "", r.value = void 0, c.value = "/" + (s.path.split("/").filter(Boolean).shift() || ""), y(), h.value = d(), E.value && (C.value = !1);
71
+ }
72
+ ), q({
73
+ menus: h,
74
+ currentEndRoute: r,
75
+ currentTabPath: c,
76
+ currentAppId: i,
77
+ defaultParentActive: M,
78
+ sideOpen: C,
79
+ isMobile: E,
80
+ getMenus: d,
81
+ currentEndParentRoute: I
82
+ }), {
83
+ menus: h,
84
+ currentEndRoute: r,
85
+ currentTabPath: c,
86
+ currentAppId: i,
87
+ defaultParentActive: M,
88
+ sideOpen: C,
89
+ isMobile: E,
90
+ getMenus: d,
91
+ currentEndParentRoute: I,
92
+ leftScrollRef: B
93
+ };
94
+ }
95
+ export {
96
+ Q as injectLayoutContext,
97
+ q as provideLayoutContext,
98
+ X as useStateHook
99
+ };
@@ -0,0 +1,15 @@
1
+ export type ThemeMode = "light" | "dark";
2
+ export declare function initTheme(fallback?: ThemeMode): ThemeMode;
3
+ export declare function setTheme(value: ThemeMode, options?: {
4
+ persist?: boolean;
5
+ }): void;
6
+ export declare function toggleTheme(): void;
7
+ export declare function syncThemeFromSetting(value?: ThemeMode): void;
8
+ export declare function useTheme(): {
9
+ theme: import('vue').Ref<ThemeMode, ThemeMode>;
10
+ isDark: import('vue').ComputedRef<boolean>;
11
+ initTheme: typeof initTheme;
12
+ setTheme: typeof setTheme;
13
+ toggleTheme: typeof toggleTheme;
14
+ syncThemeFromSetting: typeof syncThemeFromSetting;
15
+ };
@@ -0,0 +1,44 @@
1
+ import { computed as m, ref as o } from "vue";
2
+ import { Storage as s } from "../../utils/repoUtils.js";
3
+ const u = "theme", f = "(prefers-color-scheme: dark)", r = o("light"), n = o(!1);
4
+ let a = !1;
5
+ const d = (e) => e === "dark" || e === "light" ? e : null, h = () => typeof window > "u" || typeof window.matchMedia != "function" ? "light" : window.matchMedia(f).matches ? "dark" : "light", T = (e) => {
6
+ const t = d(s.get(u, null));
7
+ return t ? (n.value = !0, t) : e || h();
8
+ }, c = (e) => {
9
+ typeof document > "u" || document.documentElement.classList.toggle("dark", e === "dark");
10
+ };
11
+ function l(e) {
12
+ const t = T(e);
13
+ return r.value = t, c(t), a = !0, t;
14
+ }
15
+ function i(e, t) {
16
+ r.value = e, c(e), (t == null ? void 0 : t.persist) !== !1 && (s.set(u, e, null), n.value = !0);
17
+ }
18
+ function g() {
19
+ i(r.value === "dark" ? "light" : "dark");
20
+ }
21
+ function k(e) {
22
+ if (!a) {
23
+ l(e);
24
+ return;
25
+ }
26
+ !n.value && e && i(e, { persist: !1 });
27
+ }
28
+ function w() {
29
+ return {
30
+ theme: r,
31
+ isDark: m(() => r.value === "dark"),
32
+ initTheme: l,
33
+ setTheme: i,
34
+ toggleTheme: g,
35
+ syncThemeFromSetting: k
36
+ };
37
+ }
38
+ export {
39
+ l as initTheme,
40
+ i as setTheme,
41
+ k as syncThemeFromSetting,
42
+ g as toggleTheme,
43
+ w as useTheme
44
+ };
@@ -0,0 +1,7 @@
1
+ import { SettingConfig } from '../hooks/useSetting';
2
+ export declare function getQueryString(key: string, url?: string): string;
3
+ export declare const getLayoutLoginPath: (setting?: Partial<SettingConfig>) => string;
4
+ export declare const redirectToLayoutLogin: (setting?: Partial<SettingConfig>) => void;
5
+ export declare const getLayoutUserCenterPath: (setting?: Partial<SettingConfig>) => string;
6
+ export declare const setLayoutStyle: (setting: SettingConfig) => void;
7
+ export declare function setPrimaryColor(primaryColor: string): void;
@@ -0,0 +1,59 @@
1
+ function $(e, o) {
2
+ const n = new RegExp("(^|&)" + e + "=([^&]*)(&|$)", "i"), c = (o || window.location.search.replace(/^\?/, "")).match(n);
3
+ return c != null ? decodeURI(c[2]) : "";
4
+ }
5
+ const h = () => typeof location > "u" ? "" : location.href, p = (e) => (e == null ? void 0 : e.loginPath) || `/login?redirect=${encodeURIComponent(h())}`, C = (e) => {
6
+ typeof location > "u" || (location.href = p(e));
7
+ }, L = (e) => (e == null ? void 0 : e.userCenterPath) || "/usercenter/home", b = (e) => {
8
+ var l;
9
+ const o = e.themeColor, n = {};
10
+ if (o)
11
+ for (const r in o) {
12
+ if (!o[r]) continue;
13
+ const i = "--layout-" + r.replace(/([A-Z])/g, "-$1").toLocaleLowerCase();
14
+ n[i] = o[r], r == "colorPrimary" && f(o[r]);
15
+ }
16
+ let t = document.getElementById("layout-style");
17
+ t && ((l = t.parentNode) == null || l.removeChild(t)), t = document.createElement("style"), t.id = "layout-style", document.head.appendChild(t);
18
+ const c = Object.keys(n).map((r) => r + ":" + n[r]).join(";");
19
+ t.innerHTML = `html:root{${c}}`;
20
+ };
21
+ function f(e) {
22
+ var c;
23
+ let o = document.getElementById("primary-style");
24
+ if (e == "theme-default" && o) {
25
+ (c = o.parentNode) == null || c.removeChild(o);
26
+ return;
27
+ }
28
+ const n = g(e);
29
+ o || (o = document.createElement("style"), o.id = "primary-style", document.head.appendChild(o));
30
+ const t = Object.keys(n).map((l) => l + ":" + n[l]).join(";");
31
+ o.innerHTML = `html:root{${t}}`;
32
+ }
33
+ function g(e) {
34
+ var m;
35
+ const o = ((m = e.match(/\d+/g)) == null ? void 0 : m.map(Number)) || [], [n, t, c] = o, l = `rgb(${n}, ${t}, ${c})`, r = (d) => {
36
+ const a = d / 100, u = Math.min(255, n + (255 - n) * a), y = Math.min(255, t + (255 - t) * a), s = Math.min(255, c + (255 - c) * a);
37
+ return `rgb(${u.toFixed(1)}, ${y.toFixed(1)}, ${s.toFixed(1)})`;
38
+ }, i = (d) => {
39
+ const a = 1 - d / 100;
40
+ return `rgb(${Math.round(n * a)} ${Math.round(t * a)} ${Math.round(c * a)})`;
41
+ };
42
+ return {
43
+ "--el-color-primary": l,
44
+ "--el-color-primary-light-3": r(30),
45
+ "--el-color-primary-light-5": r(50),
46
+ "--el-color-primary-light-7": r(70),
47
+ "--el-color-primary-light-8": r(80),
48
+ "--el-color-primary-light-9": r(90),
49
+ "--el-color-primary-dark-2": i(20)
50
+ };
51
+ }
52
+ export {
53
+ p as getLayoutLoginPath,
54
+ L as getLayoutUserCenterPath,
55
+ $ as getQueryString,
56
+ C as redirectToLayoutLogin,
57
+ b as setLayoutStyle,
58
+ f as setPrimaryColor
59
+ };