mamba-layout 0.7.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,35 +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 s, provideLayoutContext as f, useStateHook as p } from "./layout/hooks/useState.js";
4
- import { applyThemeClass as x, getBrowserPreferredTheme as l, initTheme as n, normalizeTheme as i, resolveTheme as d, setTheme as T, syncThemeFromSetting as h, toggleTheme as g, useTheme as y } from "./layout/hooks/useTheme.js";
5
- import { provideSetting as c, useSetting as v } from "./layout/hooks/useSetting.js";
6
- import { default as B } from "./components/UserAvatar/src/UserAvatar.vue.js";
7
- import { default as z } from "./layout/components/LayoutBreadcrumb.vue.js";
8
- import { default as U } from "./layout/components/TimezoneSelect.vue.js";
9
- import { default as j } from "./layout/components/UserInfo.vue.js";
10
- import { default as w } from "./locales/index.js";
11
- import { messages as H } 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
- z as LayoutBreadcrumb,
15
- U as TimezoneSelect,
16
- B as UserAvatar,
17
- j as UserInfo,
18
- x as applyThemeClass,
19
- l as getBrowserPreferredTheme,
20
- w as i18n,
21
- n as initTheme,
13
+ t as BaseLayout,
14
+ S as LayoutBreadcrumb,
15
+ g as TimezoneSelect,
16
+ y as UserAvatar,
17
+ A as UserInfo,
18
+ C as i18n,
22
19
  s as injectLayoutContext,
23
- H as messages,
24
- i as normalizeTheme,
25
- f as provideLayoutContext,
26
- c as provideSetting,
27
- d as resolveTheme,
28
- T as setTheme,
29
- h as syncThemeFromSetting,
30
- g as toggleTheme,
20
+ U as messages,
21
+ m as provideLayoutContext,
22
+ n as provideSetting,
31
23
  a as useApp,
32
- v as useSetting,
24
+ i as useSetting,
33
25
  p as useStateHook,
34
- y as useTheme
26
+ x as useTheme
35
27
  };
@@ -1,21 +1,13 @@
1
1
  import { useApp as o } from "./useApp.js";
2
- import { provideSetting as m, useSetting as p } from "./useSetting.js";
3
- import { injectLayoutContext as h, provideLayoutContext as i, useStateHook as n } from "./useState.js";
4
- import { applyThemeClass as a, getBrowserPreferredTheme as g, initTheme as u, normalizeTheme as x, resolveTheme as f, setTheme as l, syncThemeFromSetting as y, toggleTheme as S, useTheme as d } 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
- a as applyThemeClass,
7
- g as getBrowserPreferredTheme,
8
- u as initTheme,
9
- h as injectLayoutContext,
10
- x as normalizeTheme,
11
- i as provideLayoutContext,
12
- m as provideSetting,
13
- f as resolveTheme,
14
- l as setTheme,
15
- y as syncThemeFromSetting,
16
- S as toggleTheme,
6
+ i as injectLayoutContext,
7
+ m as provideLayoutContext,
8
+ p as provideSetting,
17
9
  o as useApp,
18
- p as useSetting,
10
+ u as useSetting,
19
11
  n as useStateHook,
20
- d as useTheme
12
+ s as useTheme
21
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,19 +1,11 @@
1
1
  export type ThemeMode = "light" | "dark";
2
- export declare const normalizeTheme: (value: unknown) => ThemeMode | null;
3
- export declare const getBrowserPreferredTheme: () => ThemeMode;
4
- export declare const resolveTheme: (fallback?: ThemeMode) => ThemeMode;
5
- export declare const applyThemeClass: (value: ThemeMode) => void;
6
- export declare function initTheme(fallback?: ThemeMode): ThemeMode;
7
- export declare function setTheme(value: ThemeMode, options?: {
8
- persist?: boolean;
9
- }): void;
10
- export declare function toggleTheme(): void;
11
- export declare function syncThemeFromSetting(value?: ThemeMode): void;
12
2
  export declare function useTheme(): {
13
3
  theme: import('vue').Ref<ThemeMode, ThemeMode>;
14
4
  isDark: import('vue').ComputedRef<boolean>;
15
- initTheme: typeof initTheme;
16
- setTheme: typeof setTheme;
17
- toggleTheme: typeof toggleTheme;
18
- 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;
19
11
  };
@@ -1,48 +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
- c as applyThemeClass,
40
- h as getBrowserPreferredTheme,
41
- l as initTheme,
42
- d as normalizeTheme,
43
- T as resolveTheme,
44
- i as setTheme,
45
- k as syncThemeFromSetting,
46
- g as toggleTheme,
47
- w as useTheme
36
+ M as useTheme
48
37
  };