mamba-layout 0.6.0 → 0.8.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.js CHANGED
@@ -1,31 +1,27 @@
1
- import { default as o } from "./layout/BaseLayout.vue.js";
1
+ import { default as t } from "./layout/BaseLayout.vue.js";
2
2
  import { useApp as a } from "./layout/hooks/useApp.js";
3
- import { injectLayoutContext as f, provideLayoutContext as s, useStateHook as p } from "./layout/hooks/useState.js";
4
- import { initTheme as x, setTheme as n, syncThemeFromSetting as i, toggleTheme as d, useTheme as l } from "./layout/hooks/useTheme.js";
5
- import { provideSetting as T, useSetting as h } from "./layout/hooks/useSetting.js";
6
- import { default as S } from "./components/UserAvatar/src/UserAvatar.vue.js";
7
- import { default as L } from "./layout/components/LayoutBreadcrumb.vue.js";
8
- import { default as A } from "./layout/components/TimezoneSelect.vue.js";
9
- import { default as C } from "./layout/components/UserInfo.vue.js";
10
- import { default as b } from "./locales/index.js";
11
- import { messages as k } from "./locales/messages.js";
3
+ import { injectLayoutContext as s, provideLayoutContext as m, useStateHook as p } from "./layout/hooks/useState.js";
4
+ import { useTheme as x } from "./layout/hooks/useTheme.js";
5
+ import { provideSetting as n, useSetting as i } from "./layout/hooks/useSetting.js";
6
+ import { default as y } from "./components/UserAvatar/src/UserAvatar.vue.js";
7
+ import { default as S } from "./layout/components/LayoutBreadcrumb.vue.js";
8
+ import { default as g } from "./layout/components/TimezoneSelect.vue.js";
9
+ import { default as A } from "./layout/components/UserInfo.vue.js";
10
+ import { default as C } from "./locales/index.js";
11
+ import { messages as U } from "./locales/messages.js";
12
12
  export {
13
- o as BaseLayout,
14
- L as LayoutBreadcrumb,
15
- A as TimezoneSelect,
16
- S as UserAvatar,
17
- C as UserInfo,
18
- b as i18n,
19
- x as initTheme,
20
- f as injectLayoutContext,
21
- k as messages,
22
- s as provideLayoutContext,
23
- T as provideSetting,
24
- n as setTheme,
25
- i as syncThemeFromSetting,
26
- d as toggleTheme,
13
+ t as BaseLayout,
14
+ S as LayoutBreadcrumb,
15
+ g as TimezoneSelect,
16
+ y as UserAvatar,
17
+ A as UserInfo,
18
+ C as i18n,
19
+ s as injectLayoutContext,
20
+ U as messages,
21
+ m as provideLayoutContext,
22
+ n as provideSetting,
27
23
  a as useApp,
28
- h as useSetting,
24
+ i as useSetting,
29
25
  p as useStateHook,
30
- l as useTheme
26
+ x as useTheme
31
27
  };
@@ -1,17 +1,13 @@
1
1
  import { useApp as o } from "./useApp.js";
2
- import { provideSetting as m, useSetting as i } from "./useSetting.js";
3
- import { injectLayoutContext as p, provideLayoutContext as s, useStateHook as u } from "./useState.js";
4
- import { initTheme as g, setTheme as h, syncThemeFromSetting as T, toggleTheme as f, useTheme as S } from "./useTheme.js";
2
+ import { provideSetting as p, useSetting as u } from "./useSetting.js";
3
+ import { injectLayoutContext as i, provideLayoutContext as m, useStateHook as n } from "./useState.js";
4
+ import { useTheme as s } from "./useTheme.js";
5
5
  export {
6
- g as initTheme,
7
- p as injectLayoutContext,
8
- s as provideLayoutContext,
9
- m as provideSetting,
10
- h as setTheme,
11
- T as syncThemeFromSetting,
12
- f as toggleTheme,
6
+ i as injectLayoutContext,
7
+ m as provideLayoutContext,
8
+ p as provideSetting,
13
9
  o as useApp,
14
- i as useSetting,
15
- u as useStateHook,
16
- S as useTheme
10
+ u as useSetting,
11
+ n as useStateHook,
12
+ s as useTheme
17
13
  };
@@ -1,8 +1,8 @@
1
- import { unref as m, ref as n } from "vue";
1
+ import { unref as m, ref as s } from "vue";
2
2
  import { deepMerge as u } from "../../utils/repoUtils.js";
3
- import { syncThemeFromSetting as a } from "./useTheme.js";
3
+ import { useTheme as a } from "./useTheme.js";
4
4
  import { setLayoutStyle as i } from "../utils/index.js";
5
- const t = n({
5
+ const t = s({
6
6
  menus: [],
7
7
  layout: "classic",
8
8
  title: "",
@@ -10,15 +10,17 @@ const t = n({
10
10
  tabs: "tab",
11
11
  pageType: "common"
12
12
  });
13
- function l() {
13
+ function c() {
14
14
  return t;
15
15
  }
16
- const g = (o) => {
17
- const e = l(), r = o && m(o) || {};
16
+ const v = (o) => {
17
+ const e = c(), r = o && m(o) || {};
18
18
  if (!(e != null && e.value)) return r;
19
- t.value = u(e.value, r), a(t.value.theme), i(t.value);
19
+ t.value = u(e.value, r);
20
+ const { syncThemeFromSetting: n } = a();
21
+ n(), i(t.value);
20
22
  };
21
23
  export {
22
- g as provideSetting,
23
- l as useSetting
24
+ v as provideSetting,
25
+ c as useSetting
24
26
  };
@@ -1,15 +1,11 @@
1
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
2
  export declare function useTheme(): {
9
3
  theme: import('vue').Ref<ThemeMode, ThemeMode>;
10
4
  isDark: import('vue').ComputedRef<boolean>;
11
- initTheme: typeof initTheme;
12
- setTheme: typeof setTheme;
13
- toggleTheme: typeof toggleTheme;
14
- syncThemeFromSetting: typeof syncThemeFromSetting;
5
+ initTheme: (fallback?: ThemeMode) => ThemeMode;
6
+ setTheme: (value: ThemeMode, options?: {
7
+ persist?: boolean;
8
+ }) => void;
9
+ toggleTheme: () => void;
10
+ syncThemeFromSetting: (value?: ThemeMode) => void;
15
11
  };
@@ -1,44 +1,37 @@
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() {
1
+ import { ref as m, computed as E } from "vue";
2
+ import { Storage as l } from "../../utils/repoUtils.js";
3
+ const r = m("light");
4
+ function M() {
5
+ const o = "theme", u = "(prefers-color-scheme: dark)", n = m(!1);
6
+ let i = !1;
7
+ const d = (e) => e === "dark" || e === "light" ? e : null, f = () => typeof window > "u" || typeof window.matchMedia != "function" ? "light" : window.matchMedia(u).matches ? "dark" : "light", h = (e) => {
8
+ const t = d(l.get(o, null));
9
+ return t ? (n.value = !0, t) : e || f();
10
+ }, c = (e) => {
11
+ typeof document > "u" || document.documentElement.classList.toggle("dark", e === "dark");
12
+ }, a = (e) => {
13
+ const t = h(e);
14
+ return r.value = t, c(t), i = !0, t;
15
+ }, s = (e, t) => {
16
+ r.value = e, c(e), (t == null ? void 0 : t.persist) !== !1 && (l.set(o, e, null), n.value = !0);
17
+ }, T = () => {
18
+ s(r.value === "dark" ? "light" : "dark");
19
+ }, g = (e) => {
20
+ if (!i) {
21
+ a(e);
22
+ return;
23
+ }
24
+ !n.value && e && s(e, { persist: !1 });
25
+ }, k = E(() => r.value === "dark");
29
26
  return {
30
27
  theme: r,
31
- isDark: m(() => r.value === "dark"),
32
- initTheme: l,
33
- setTheme: i,
34
- toggleTheme: g,
35
- syncThemeFromSetting: k
28
+ isDark: k,
29
+ initTheme: a,
30
+ setTheme: s,
31
+ toggleTheme: T,
32
+ syncThemeFromSetting: g
36
33
  };
37
34
  }
38
35
  export {
39
- l as initTheme,
40
- i as setTheme,
41
- k as syncThemeFromSetting,
42
- g as toggleTheme,
43
- w as useTheme
36
+ M as useTheme
44
37
  };