@maz-ui/themes 4.1.4 → 4.1.5

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,10 +1,10 @@
1
- import { ref as d, onMounted as k, computed as s, toValue as w, watch as y, watchEffect as T, inject as C, getCurrentInstance as S } from "vue";
1
+ import { ref as f, onMounted as k, computed as s, toValue as w, watch as y, watchEffect as T, inject as C, getCurrentInstance as M } from "vue";
2
2
  import { setCookie as z } from "../utils/cookie-storage.js";
3
3
  import { generateCriticalCSS as E, generateFullCSS as L, injectCSS as p, CSS_IDS as v } from "../utils/css-generator.js";
4
- import { getColorMode as x, isSystemPrefersDark as D } from "../utils/get-color-mode.js";
5
- import { getPreset as I } from "../utils/get-preset.js";
6
- import { mergePresets as O } from "../utils/preset-merger.js";
7
- function $() {
4
+ import { getColorMode as x, isSystemPrefersDark as I } from "../utils/get-color-mode.js";
5
+ import { getPreset as O } from "../utils/get-preset.js";
6
+ import { mergePresets as $ } from "../utils/preset-merger.js";
7
+ function D() {
8
8
  return typeof document > "u" || typeof globalThis.window > "u";
9
9
  }
10
10
  function F() {
@@ -16,12 +16,12 @@ function R(e) {
16
16
  function U(e, o, r = {}) {
17
17
  const {
18
18
  internalWindow: u = F() ? globalThis : void 0,
19
- ...l
19
+ ...c
20
20
  } = r;
21
21
  let n;
22
- const c = d(!1);
22
+ const d = f(!1);
23
23
  k(() => {
24
- c.value = (u && "MutationObserver" in u) ?? !1;
24
+ d.value = (u && "MutationObserver" in u) ?? !1;
25
25
  });
26
26
  const m = () => {
27
27
  n && (n.disconnect(), n = void 0);
@@ -32,24 +32,24 @@ function U(e, o, r = {}) {
32
32
  }), P = y(
33
33
  b,
34
34
  (a) => {
35
- m(), c.value && a.size && (n = new MutationObserver(o), a.forEach((i) => n.observe(i, l)));
35
+ m(), d.value && a.size && (n = new MutationObserver(o), a.forEach((i) => n.observe(i, c)));
36
36
  },
37
37
  { immediate: !0, flush: "post" }
38
38
  );
39
39
  return {
40
- isSupported: c,
40
+ isSupported: d,
41
41
  stop: () => {
42
42
  P(), m();
43
43
  },
44
44
  takeRecords: () => n?.takeRecords()
45
45
  };
46
46
  }
47
- const t = d();
48
- function M(e) {
47
+ const t = f();
48
+ function S(e) {
49
49
  typeof document > "u" || !e || e.darkModeStrategy === "media" || e.mode === "light" || (e.isDark ? document.documentElement.classList.add("dark") : document.documentElement.classList.remove("dark"));
50
50
  }
51
51
  function j() {
52
- const e = S()?.appContext.app;
52
+ const e = M()?.appContext.app;
53
53
  e && t.value && (e.config.globalProperties.$mazThemeState = t.value);
54
54
  }
55
55
  function N(e) {
@@ -64,7 +64,7 @@ function N(e) {
64
64
  });
65
65
  return;
66
66
  }
67
- const o = x(e.colorMode), r = o === "auto" ? D() : o === "dark";
67
+ const o = x(e.colorMode), r = o === "auto" ? I() : o === "dark";
68
68
  g({
69
69
  currentPreset: e.currentPreset,
70
70
  colorMode: o,
@@ -82,45 +82,48 @@ function g(e) {
82
82
  o.addEventListener("change", r), r();
83
83
  }
84
84
  T(() => {
85
- t.value && (M(t.value), j());
85
+ t.value && (S(t.value), j());
86
86
  });
87
87
  }
88
88
  const W = s({
89
89
  get: () => t.value?.colorMode,
90
- set: (e) => f(e)
90
+ set: (e) => l(e)
91
91
  }), _ = s(() => t.value?.isDark ?? !1), A = s(() => t.value?.strategy), G = s(() => t.value?.mode), Q = s(() => t.value?.darkModeStrategy), h = s(() => t.value?.currentPreset), V = s(() => h.value?.name);
92
92
  async function Y(e) {
93
93
  if (!t.value)
94
94
  return;
95
- const o = typeof e == "string" ? await I(e) : e;
95
+ const o = typeof e == "string" ? await O(e) : e;
96
96
  if (!o || !t.value.currentPreset) {
97
97
  console.error("[@maz-ui/themes] No preset found - If you are using the buildtime strategy, you must provide a complete preset");
98
98
  return;
99
99
  }
100
- const r = "name" in o && o.name !== t.value.currentPreset.name ? o : O(t.value.currentPreset, o);
100
+ const r = "name" in o && o.name !== t.value.currentPreset.name ? o : $(t.value.currentPreset, o);
101
101
  if (t.value.currentPreset = r, t.value.strategy === "runtime" || t.value.strategy === "hybrid") {
102
102
  const u = {
103
103
  mode: t.value.mode,
104
104
  darkSelectorStrategy: t.value.darkModeStrategy,
105
105
  prefix: "maz"
106
- }, l = E(r, u), n = L(r, u);
107
- p(v.CRITICAL, l), p(v.FULL, n);
106
+ }, c = E(r, u), n = L(r, u);
107
+ p(v.CRITICAL, c), p(v.FULL, n);
108
108
  }
109
109
  }
110
- function f(e) {
111
- t.value && (t.value.colorMode = e, e === "auto" ? t.value.isDark = typeof globalThis.window < "u" && globalThis.matchMedia("(prefers-color-scheme: dark)").matches : t.value.isDark = e === "dark", M(t.value), z("maz-color-mode", e));
110
+ function l(e, o = !0) {
111
+ t.value && (t.value.colorMode = e, e === "auto" ? t.value.isDark = typeof globalThis.window < "u" && globalThis.matchMedia("(prefers-color-scheme: dark)").matches : t.value.isDark = e === "dark", o && S(t.value), z("maz-color-mode", e));
112
112
  }
113
113
  function q() {
114
- t.value && f(t.value.isDark ? "light" : "dark");
114
+ t.value && l(t.value.isDark ? "light" : "dark");
115
115
  }
116
116
  function oe() {
117
- const e = d();
117
+ const e = f();
118
118
  k(() => {
119
119
  e.value = document.documentElement;
120
120
  }), U(
121
121
  e,
122
122
  () => {
123
- !t.value || $() || (t.value.isDark = document.documentElement.classList.contains("dark"));
123
+ if (D() || !t.value)
124
+ return;
125
+ const r = document.documentElement.classList.contains("dark") ? "dark" : "light";
126
+ t.value.colorMode !== r && l(r, !1);
124
127
  },
125
128
  {
126
129
  attributes: !0
@@ -131,7 +134,7 @@ function oe() {
131
134
  if (o = C("mazThemeState", void 0), !o)
132
135
  throw new Error("mazThemeState not found");
133
136
  } catch {
134
- const r = S();
137
+ const r = M();
135
138
  r?.appContext?.app?.config?.globalProperties && (o = r.appContext.app.config.globalProperties.$mazThemeState);
136
139
  }
137
140
  if (o && (t.value ? (typeof document > "u" || typeof globalThis.window > "u") && (t.value = {
@@ -149,7 +152,7 @@ function oe() {
149
152
  isDark: _,
150
153
  strategy: A,
151
154
  updateTheme: Y,
152
- setColorMode: f,
155
+ setColorMode: l,
153
156
  toggleDarkMode: q,
154
157
  mode: G,
155
158
  darkModeStrategy: Q,
@@ -1,7 +1,7 @@
1
1
  import { ColorMode, DarkModeStrategy, Strategy, ThemeMode, ThemePreset, ThemePresetName, ThemePresetOverrides, ThemeState } from '../types';
2
2
  export declare function initThemeState(initialState: ThemeState): void;
3
3
  declare function updateTheme(preset: ThemePreset | ThemePresetOverrides | ThemePresetName): Promise<void>;
4
- declare function setColorMode(colorMode: ColorMode): void;
4
+ declare function setColorMode(colorMode: ColorMode, updateClass?: boolean): void;
5
5
  declare function toggleDarkMode(): void;
6
6
  export declare function useTheme(): {
7
7
  presetName: import('vue').ComputedRef<string | undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../../src/composables/useTheme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AA8DhJ,wBAAgB,cAAc,CAAC,YAAY,EAAE,UAAU,QAsBtD;AAcD,iBAAe,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,oBAAoB,GAAG,eAAe,iBA8BtF;AAED,iBAAS,YAAY,CAAC,SAAS,EAAE,SAAS,QAgBzC;AAED,iBAAS,cAAc,SAKtB;AAED,wBAAgB,QAAQ;;;;;;;;;;;EAuEvB"}
1
+ {"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../../src/composables/useTheme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,gBAAgB,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AA8DhJ,wBAAgB,cAAc,CAAC,YAAY,EAAE,UAAU,QAsBtD;AAcD,iBAAe,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,oBAAoB,GAAG,eAAe,iBA8BtF;AAED,iBAAS,YAAY,CAAC,SAAS,EAAE,SAAS,EAAE,WAAW,UAAO,QAkB7D;AAED,iBAAS,cAAc,SAKtB;AAED,wBAAgB,QAAQ;;;;;;;;;;;EA4EvB"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maz-ui/themes",
3
3
  "type": "module",
4
- "version": "4.1.4",
4
+ "version": "4.1.5",
5
5
  "description": "Theme system for Maz-UI with TypeScript support and CSS variables",
6
6
  "author": "Louis Mazel <me@loicmazuel.com>",
7
7
  "license": "MIT",
@@ -102,5 +102,5 @@
102
102
  "lint-staged": {
103
103
  "*.{js,ts,vue,mjs,mts,cjs,md,yml,json}": "cross-env NODE_ENV=production eslint --fix"
104
104
  },
105
- "gitHead": "47076f614176b9d1f95f83e797593a8264148a9b"
105
+ "gitHead": "37294d421e5683b80ddc8f8fd062ecafe240d9ed"
106
106
  }