@maz-ui/themes 4.0.0-beta.19 → 4.0.0-beta.22

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @maz-ui/themes
2
2
 
3
- High-performance and typed theme system for Maz-UI, inspired by Shadcn and PrimeVue.
3
+ High-performance and typed theme system for Maz-UI.
4
4
 
5
5
  ## Features
6
6
 
@@ -1,52 +1,56 @@
1
- import { generateCriticalCSS as c, generateFullCSS as m } from "../utils/css-generator.js";
2
- function o(t) {
1
+ import { generateCriticalCSS as o, generateFullCSS as d } from "../utils/css-generator.js";
2
+ function s(t) {
3
3
  const {
4
4
  preset: e,
5
- mode: i = "both",
5
+ mode: a = "both",
6
+ darkSelector: l = "class",
6
7
  prefix: r = "maz",
7
- criticalOnly: n = !1
8
- } = t, l = {
9
- mode: i,
8
+ criticalOnly: i = !1
9
+ } = t, c = {
10
+ mode: a,
11
+ darkSelectorStrategy: l,
10
12
  prefix: r
11
13
  };
12
- if (n)
13
- return c(e, l);
14
- const a = c(e, l), s = m(e, l);
15
- return `${a}
16
- ${s}`;
14
+ if (i)
15
+ return o(e, c);
16
+ const n = o(e, c), m = d(e, c);
17
+ return `${n}
18
+ ${m}`;
17
19
  }
18
20
  function u(t, e = {}) {
19
21
  const {
20
- mode: i = "both",
22
+ mode: a = "both",
23
+ darkSelector: l = "class",
21
24
  prefix: r = "maz",
22
- criticalOnly: n = !1
25
+ criticalOnly: i = !1
23
26
  } = e;
24
- return t.reduce((l, a) => (l[a.name] = o({
25
- preset: a,
26
- mode: i,
27
+ return t.reduce((c, n) => (c[n.name] = s({
28
+ preset: n,
29
+ mode: a,
30
+ darkSelector: l,
27
31
  prefix: r,
28
- criticalOnly: n
29
- }), l), {});
32
+ criticalOnly: i
33
+ }), c), {});
30
34
  }
31
35
  function f(t, e = {}) {
32
- const { id: i = "maz-theme", media: r } = e;
33
- let n = `<style id="${i}"`;
34
- return r && (n += ` media="${r}"`), n += `>
36
+ const { id: a = "maz-theme", media: l } = e;
37
+ let r = `<style id="${a}"`;
38
+ return l && (r += ` media="${l}"`), r += `>
35
39
  ${t}
36
- </style>`, n;
40
+ </style>`, r;
37
41
  }
38
- function S(t, e = {}) {
39
- const { prefix: i = "maz", darkSelector: r = "class" } = e, n = { prefix: i, darkSelector: r };
42
+ function h(t, e = {}) {
43
+ const { prefix: a = "maz", darkSelector: l = "class" } = e, r = { prefix: a, darkSelectorStrategy: l };
40
44
  return {
41
- critical: c(t, { ...n, mode: "both" }),
42
- full: m(t, { ...n, mode: "both" }),
43
- lightOnly: o({ preset: t, mode: "light", ...e }),
44
- darkOnly: o({ preset: t, mode: "dark", ...e })
45
+ critical: o(t, { ...r, mode: "both" }),
46
+ full: d(t, { ...r, mode: "both" }),
47
+ lightOnly: s({ preset: t, mode: "light", ...e }),
48
+ darkOnly: s({ preset: t, mode: "dark", ...e })
45
49
  };
46
50
  }
47
51
  export {
48
- S as buildSeparateThemeFiles,
49
- o as buildThemeCSS,
52
+ h as buildSeparateThemeFiles,
53
+ s as buildThemeCSS,
50
54
  f as createThemeStylesheet,
51
55
  u as generateThemeBundle
52
56
  };
@@ -1,23 +1,23 @@
1
- import { ref as n, computed as a, watchEffect as p, inject as v, getCurrentInstance as d } from "vue";
2
- import { setCookie as k } from "../utils/cookie-storage.js";
3
- import { generateCriticalCSS as y, generateFullCSS as M, injectCSS as u, CSS_IDS as l } from "../utils/css-generator.js";
4
- import { getColorMode as S, getSystemPrefersDark as P } from "../utils/get-color-mode.js";
5
- import { getPreset as h } from "../utils/get-preset.js";
6
- import { mergePresets as C } from "../utils/preset-merger.js";
7
- function T() {
1
+ import { ref as M, computed as a, watchEffect as P, inject as h, getCurrentInstance as v, watch as C } from "vue";
2
+ import { setCookie as T } from "../utils/cookie-storage.js";
3
+ import { generateCriticalCSS as b, generateFullCSS as w, injectCSS as s, CSS_IDS as u } from "../utils/css-generator.js";
4
+ import { getColorMode as z, isSystemPrefersDark as L } from "../utils/get-color-mode.js";
5
+ import { getPreset as x } from "../utils/get-preset.js";
6
+ import { mergePresets as D } from "../utils/preset-merger.js";
7
+ function E() {
8
8
  return typeof document > "u" || typeof globalThis.window > "u";
9
9
  }
10
- const r = n();
11
- function m() {
12
- typeof document > "u" || !r.value || r.value.darkModeStrategy === "media" || (r.value.isDark ? document.documentElement.classList.add("dark") : document.documentElement.classList.remove("dark"));
10
+ const r = M();
11
+ function k(e) {
12
+ typeof document > "u" || !e || e.darkModeStrategy === "media" || e.mode === "light" || (e.isDark ? document.documentElement.classList.add("dark") : document.documentElement.classList.remove("dark"));
13
13
  }
14
- function b() {
15
- const e = d()?.appContext.app;
14
+ function F() {
15
+ const e = v()?.appContext.app;
16
16
  e && r.value && (e.config.globalProperties.$mazThemeState = r.value);
17
17
  }
18
- function w(e) {
18
+ function I(e) {
19
19
  if (e.currentPreset && e.colorMode !== void 0) {
20
- c({
20
+ l({
21
21
  currentPreset: e.currentPreset,
22
22
  colorMode: e.colorMode,
23
23
  mode: e.mode,
@@ -27,8 +27,8 @@ function w(e) {
27
27
  });
28
28
  return;
29
29
  }
30
- const t = S(e.colorMode), o = t === "auto" ? P() === "dark" : t === "dark";
31
- c({
30
+ const t = z(e.colorMode), o = t === "auto" ? L() : t === "dark";
31
+ l({
32
32
  currentPreset: e.currentPreset,
33
33
  colorMode: t,
34
34
  mode: e.mode,
@@ -37,61 +37,73 @@ function w(e) {
37
37
  darkModeStrategy: e.darkModeStrategy
38
38
  });
39
39
  }
40
- function c(e) {
40
+ function l(e) {
41
41
  if (r.value = e, typeof globalThis.window < "u" && r.value.colorMode === "auto") {
42
42
  const t = globalThis.matchMedia("(prefers-color-scheme: dark)"), o = () => {
43
43
  r.value && r.value.colorMode === "auto" && (r.value.isDark = t.matches);
44
44
  };
45
45
  t.addEventListener("change", o), o();
46
46
  }
47
- p(() => {
48
- r.value && (m(), b());
47
+ P(() => {
48
+ r.value && (k(r.value), F());
49
49
  });
50
50
  }
51
- const z = a(() => r.value?.currentPreset), D = a({
51
+ const c = a({
52
52
  get: () => r.value?.colorMode,
53
- set: (e) => i(e)
54
- }), L = a(() => r.value?.isDark ?? !1), x = a(() => r.value?.strategy);
55
- async function E(e) {
53
+ set: (e) => n(e)
54
+ }), d = a(() => r.value?.isDark ?? !1), m = a(() => r.value?.strategy), f = a(() => r.value?.mode), g = a(() => r.value?.darkModeStrategy), p = a(() => r.value?.currentPreset.name);
55
+ async function U(e) {
56
56
  if (!r.value)
57
57
  return;
58
- const t = typeof e == "string" ? await h(e) : e, o = "name" in t && t.name !== r.value.currentPreset.name ? t : C(r.value.currentPreset, t);
58
+ const t = typeof e == "string" ? await x(e) : e, o = "name" in t && t.name !== r.value.currentPreset.name ? t : D(r.value.currentPreset, t);
59
59
  if (r.value.currentPreset = o, r.value.strategy === "runtime" || r.value.strategy === "hybrid") {
60
- const s = {
60
+ const i = {
61
61
  mode: r.value.mode,
62
+ darkSelectorStrategy: r.value.darkModeStrategy,
62
63
  prefix: "maz"
63
- }, f = y(o, s), g = M(o, s);
64
- u(f, l.CRITICAL), u(g, l.FULL);
64
+ }, y = b(o, i), S = w(o, i);
65
+ s(y, u.CRITICAL), s(S, u.FULL);
65
66
  }
66
67
  }
67
- function i(e) {
68
- r.value && (r.value.colorMode = e, e === "auto" ? r.value.isDark = typeof globalThis.window < "u" && globalThis.matchMedia("(prefers-color-scheme: dark)").matches : r.value.isDark = e === "dark", m(), k("maz-color-mode", e));
68
+ function n(e) {
69
+ r.value && (r.value.colorMode = e, e === "auto" ? r.value.isDark = typeof globalThis.window < "u" && globalThis.matchMedia("(prefers-color-scheme: dark)").matches : r.value.isDark = e === "dark", k(r.value), T("maz-color-mode", e));
69
70
  }
70
- function F() {
71
- r.value && i(r.value.isDark ? "light" : "dark");
71
+ function j() {
72
+ r.value && n(r.value.isDark ? "light" : "dark");
72
73
  }
73
- function G() {
74
+ function Q() {
74
75
  let e;
75
76
  try {
76
- if (e = v("mazThemeState", void 0), !e)
77
+ if (e = h("mazThemeState", void 0), !e)
77
78
  throw new Error("mazThemeState not found");
78
79
  } catch {
79
- const t = d();
80
+ const t = v();
80
81
  t?.appContext?.app?.config?.globalProperties && (e = t.appContext.app.config.globalProperties.$mazThemeState);
81
82
  }
82
- return e && (r.value ? T() && (r.value.colorMode = e.colorMode, r.value.mode = e.mode, r.value.isDark = e.isDark, r.value.currentPreset = e.currentPreset) : w(e)), r.value ? {
83
- currentPreset: z,
84
- colorMode: D,
85
- isDark: L,
86
- strategy: x,
87
- updateTheme: E,
88
- setColorMode: i,
89
- toggleDarkMode: F
83
+ return e && (r.value ? E() && (r.value = {
84
+ ...r.value,
85
+ ...e
86
+ }) : I(e)), C(() => e?.currentPreset, (t) => {
87
+ r.value && t && (r.value.currentPreset = t);
88
+ }, {
89
+ once: !0
90
+ }), r.value ? {
91
+ presetName: p,
92
+ colorMode: c,
93
+ isDark: d,
94
+ strategy: m,
95
+ updateTheme: U,
96
+ setColorMode: n,
97
+ toggleDarkMode: j,
98
+ mode: f,
99
+ darkModeStrategy: g
90
100
  } : (console.error("[@maz-ui/themes] You must install the MazUi or MazUiTheme plugin before using useTheme composable"), {
91
- currentPreset: n({}),
92
- colorMode: n("light"),
93
- isDark: a(() => !1),
94
- strategy: a(() => "hybrid"),
101
+ presetName: p,
102
+ colorMode: c,
103
+ isDark: d,
104
+ strategy: m,
105
+ mode: f,
106
+ darkModeStrategy: g,
95
107
  updateTheme: () => Promise.resolve(),
96
108
  setColorMode: () => {
97
109
  },
@@ -100,6 +112,6 @@ function G() {
100
112
  });
101
113
  }
102
114
  export {
103
- c as initThemeState,
104
- G as useTheme
115
+ l as initThemeState,
116
+ Q as useTheme
105
117
  };
package/dist/plugin.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { reactive as l } from "vue";
2
2
  import { generateCriticalCSS as m, injectCSS as i, CSS_IDS as s, generateFullCSS as u } from "./utils/css-generator.js";
3
- import { getColorMode as S, getSystemPrefersDark as f } from "./utils/get-color-mode.js";
4
- import { getPreset as C } from "./utils/get-preset.js";
3
+ import { getColorMode as S, isSystemPrefersDark as f } from "./utils/get-color-mode.js";
4
+ import { getPreset as y } from "./utils/get-preset.js";
5
5
  function g(r, t) {
6
6
  typeof document > "u" || r !== "class" || (t ? document.documentElement.classList.add("dark") : document.documentElement.classList.remove("dark"));
7
7
  }
@@ -9,11 +9,12 @@ function k(r, t) {
9
9
  if (typeof document > "u")
10
10
  return;
11
11
  const e = {
12
- mode: t.mode
12
+ mode: t.mode,
13
+ darkSelectorStrategy: t.darkModeStrategy
13
14
  };
14
15
  if (t.injectCriticalCSS) {
15
- const a = m(r, e);
16
- i(a, s.CRITICAL);
16
+ const d = m(r, e);
17
+ i(d, s.CRITICAL);
17
18
  }
18
19
  if (!t.injectFullCSS)
19
20
  return;
@@ -22,7 +23,7 @@ function k(r, t) {
22
23
  i(o, s.FULL);
23
24
  }, { timeout: 100 });
24
25
  }
25
- function y(r, t) {
26
+ function C(r, t) {
26
27
  r.provide("mazThemeState", t), r.config.globalProperties.$mazThemeState = t;
27
28
  }
28
29
  const j = {
@@ -30,34 +31,35 @@ const j = {
30
31
  const e = {
31
32
  preset: "maz-ui",
32
33
  strategy: "runtime",
34
+ overrides: {},
33
35
  darkModeStrategy: "class",
34
- colorMode: t.mode !== "both" ? t.mode : t.colorMode,
36
+ colorMode: (t.mode !== "both" ? t.mode : t.colorMode) ?? "auto",
35
37
  injectCriticalCSS: !0,
36
38
  injectFullCSS: !0,
37
39
  mode: "both",
38
40
  ...t
39
- }, o = e.mode !== "both" ? e.mode : S(e.colorMode), a = o === "auto" && e.mode === "both" ? f() === "dark" : o === "dark" || e.mode === "dark", n = l({
41
+ }, o = e.mode !== "both" ? e.mode : S(e.colorMode), d = o === "auto" && e.mode === "both" ? f() : o === "dark" || e.mode === "dark", c = l({
40
42
  // @ts-expect-error - empty currentPreset to avoid error
41
43
  currentPreset: {},
42
44
  mode: e.mode,
43
45
  colorMode: o,
44
- isDark: a,
46
+ isDark: d,
45
47
  strategy: e.strategy,
46
48
  darkModeStrategy: e.darkModeStrategy
47
49
  });
48
- g(e.darkModeStrategy, a), y(r, n);
49
- const d = await C(e.preset), c = e.overrides ? {
50
- ...d,
50
+ g(e.darkModeStrategy, d), C(r, c);
51
+ const a = await y(e.preset), n = Object.keys(e.overrides).length > 0 ? {
52
+ ...a,
51
53
  foundation: {
52
- ...d.foundation,
54
+ ...a.foundation,
53
55
  ...e.overrides.foundation
54
56
  },
55
57
  colors: {
56
- light: { ...d.colors.light, ...e.overrides.colors?.light },
57
- dark: { ...d.colors.dark, ...e.overrides.colors?.dark }
58
+ light: { ...a.colors.light, ...e.overrides.colors?.light },
59
+ dark: { ...a.colors.dark, ...e.overrides.colors?.dark }
58
60
  }
59
- } : d;
60
- n.currentPreset = c, e.strategy !== "buildtime" && k(c, e);
61
+ } : a;
62
+ c.currentPreset = n, e.strategy !== "buildtime" && k(n, e);
61
63
  }
62
64
  };
63
65
  export {
@@ -12,8 +12,8 @@ const r = {
12
12
  foreground: "0 0% 10%",
13
13
  primary: "220 10% 15%",
14
14
  "primary-foreground": "0 0% 100%",
15
- contrast: "220 10% 92%",
16
- "contrast-foreground": "0 0% 10%",
15
+ contrast: "0 0% 15%",
16
+ "contrast-foreground": "0 0% 95%",
17
17
  secondary: "220 10% 92%",
18
18
  "secondary-foreground": "0 0% 10%",
19
19
  muted: "0 0% 60%",
@@ -36,8 +36,8 @@ const r = {
36
36
  foreground: "0 0% 95%",
37
37
  primary: "0 0% 95%",
38
38
  "primary-foreground": "0 0% 10%",
39
- contrast: "0 0% 15%",
40
- "contrast-foreground": "0 0% 95%",
39
+ contrast: "220 10% 92%",
40
+ "contrast-foreground": "0 0% 10%",
41
41
  secondary: "0 0% 18%",
42
42
  "secondary-foreground": "0 0% 95%",
43
43
  muted: "0 0% 60%",
@@ -1,137 +1,15 @@
1
- import { ColorMode, Strategy, ThemePreset, ThemePresetName, ThemePresetOverrides, ThemeState } from '../types';
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
4
  declare function setColorMode(colorMode: ColorMode): void;
5
5
  declare function toggleDarkMode(): void;
6
6
  export declare function useTheme(): {
7
- currentPreset: import('vue').Ref<{
8
- name: string;
9
- colors: {
10
- light: {
11
- background: import('..').HSL;
12
- foreground: import('..').HSL;
13
- primary: import('..').HSL;
14
- 'primary-foreground': import('..').HSL;
15
- secondary: import('..').HSL;
16
- 'secondary-foreground': import('..').HSL;
17
- accent: import('..').HSL;
18
- 'accent-foreground': import('..').HSL;
19
- info: import('..').HSL;
20
- 'info-foreground': import('..').HSL;
21
- contrast: import('..').HSL;
22
- 'contrast-foreground': import('..').HSL;
23
- destructive: import('..').HSL;
24
- 'destructive-foreground': import('..').HSL;
25
- success: import('..').HSL;
26
- 'success-foreground': import('..').HSL;
27
- warning: import('..').HSL;
28
- 'warning-foreground': import('..').HSL;
29
- overlay: import('..').HSL;
30
- muted: import('..').HSL;
31
- border: import('..').HSL;
32
- shadow: import('..').HSL;
33
- };
34
- dark: {
35
- background: import('..').HSL;
36
- foreground: import('..').HSL;
37
- primary: import('..').HSL;
38
- 'primary-foreground': import('..').HSL;
39
- secondary: import('..').HSL;
40
- 'secondary-foreground': import('..').HSL;
41
- accent: import('..').HSL;
42
- 'accent-foreground': import('..').HSL;
43
- info: import('..').HSL;
44
- 'info-foreground': import('..').HSL;
45
- contrast: import('..').HSL;
46
- 'contrast-foreground': import('..').HSL;
47
- destructive: import('..').HSL;
48
- 'destructive-foreground': import('..').HSL;
49
- success: import('..').HSL;
50
- 'success-foreground': import('..').HSL;
51
- warning: import('..').HSL;
52
- 'warning-foreground': import('..').HSL;
53
- overlay: import('..').HSL;
54
- muted: import('..').HSL;
55
- border: import('..').HSL;
56
- shadow: import('..').HSL;
57
- };
58
- };
59
- foundation: {
60
- 'base-font-size'?: import('..').SizeUnit | undefined;
61
- radius: import('..').SizeUnit;
62
- 'border-width': import('..').SizeUnit;
63
- 'font-family'?: string | undefined;
64
- };
65
- }, ThemePreset | {
66
- name: string;
67
- colors: {
68
- light: {
69
- background: import('..').HSL;
70
- foreground: import('..').HSL;
71
- primary: import('..').HSL;
72
- 'primary-foreground': import('..').HSL;
73
- secondary: import('..').HSL;
74
- 'secondary-foreground': import('..').HSL;
75
- accent: import('..').HSL;
76
- 'accent-foreground': import('..').HSL;
77
- info: import('..').HSL;
78
- 'info-foreground': import('..').HSL;
79
- contrast: import('..').HSL;
80
- 'contrast-foreground': import('..').HSL;
81
- destructive: import('..').HSL;
82
- 'destructive-foreground': import('..').HSL;
83
- success: import('..').HSL;
84
- 'success-foreground': import('..').HSL;
85
- warning: import('..').HSL;
86
- 'warning-foreground': import('..').HSL;
87
- overlay: import('..').HSL;
88
- muted: import('..').HSL;
89
- border: import('..').HSL;
90
- shadow: import('..').HSL;
91
- };
92
- dark: {
93
- background: import('..').HSL;
94
- foreground: import('..').HSL;
95
- primary: import('..').HSL;
96
- 'primary-foreground': import('..').HSL;
97
- secondary: import('..').HSL;
98
- 'secondary-foreground': import('..').HSL;
99
- accent: import('..').HSL;
100
- 'accent-foreground': import('..').HSL;
101
- info: import('..').HSL;
102
- 'info-foreground': import('..').HSL;
103
- contrast: import('..').HSL;
104
- 'contrast-foreground': import('..').HSL;
105
- destructive: import('..').HSL;
106
- 'destructive-foreground': import('..').HSL;
107
- success: import('..').HSL;
108
- 'success-foreground': import('..').HSL;
109
- warning: import('..').HSL;
110
- 'warning-foreground': import('..').HSL;
111
- overlay: import('..').HSL;
112
- muted: import('..').HSL;
113
- border: import('..').HSL;
114
- shadow: import('..').HSL;
115
- };
116
- };
117
- foundation: {
118
- 'base-font-size'?: import('..').SizeUnit | undefined;
119
- radius: import('..').SizeUnit;
120
- 'border-width': import('..').SizeUnit;
121
- 'font-family'?: string | undefined;
122
- };
123
- }>;
124
- colorMode: import('vue').Ref<ColorMode, ColorMode>;
125
- isDark: import('vue').ComputedRef<boolean>;
126
- strategy: import('vue').ComputedRef<Strategy>;
127
- updateTheme: typeof updateTheme;
128
- setColorMode: typeof setColorMode;
129
- toggleDarkMode: typeof toggleDarkMode;
130
- } | {
131
- currentPreset: import('vue').ComputedRef<ThemePreset>;
7
+ presetName: import('vue').ComputedRef<string>;
132
8
  colorMode: import('vue').WritableComputedRef<ColorMode, ColorMode>;
133
9
  isDark: import('vue').ComputedRef<boolean>;
134
10
  strategy: import('vue').ComputedRef<Strategy>;
11
+ mode: import('vue').ComputedRef<ThemeMode>;
12
+ darkModeStrategy: import('vue').ComputedRef<DarkModeStrategy>;
135
13
  updateTheme: typeof updateTheme;
136
14
  setColorMode: typeof setColorMode;
137
15
  toggleDarkMode: typeof toggleDarkMode;
@@ -1 +1 @@
1
- {"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../../src/composables/useTheme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,eAAe,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AA2DnH,wBAAgB,cAAc,CAAC,YAAY,EAAE,UAAU,QAsBtD;AAYD,iBAAe,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,oBAAoB,GAAG,eAAe,iBAyBtF;AAED,iBAAS,YAAY,CAAC,SAAS,EAAE,SAAS,QAgBzC;AAED,iBAAS,cAAc,SAKtB;AAED,wBAAgB,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAqCwB,OAAO,WAAW;kBAChC,OAAO,YAAY;oBACjB,OAAO,cAAc;;;;;;;;;EAaxD"}
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;AA4DhJ,wBAAgB,cAAc,CAAC,YAAY,EAAE,UAAU,QAsBtD;AAaD,iBAAe,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,oBAAoB,GAAG,eAAe,iBAyBtF;AAED,iBAAS,YAAY,CAAC,SAAS,EAAE,SAAS,QAgBzC;AAED,iBAAS,cAAc,SAKtB;AAED,wBAAgB,QAAQ;;;;;;;iBA+CwB,OAAO,WAAW;kBAChC,OAAO,YAAY;oBACjB,OAAO,cAAc;EAexD"}
@@ -31,7 +31,7 @@ export interface MazUiThemeOptions extends Omit<ThemeConfig, 'prefix'> {
31
31
  export declare const MazUiTheme: {
32
32
  install(app: App, options?: MazUiThemeOptions): Promise<void>;
33
33
  };
34
- declare module '@vue/runtime-core' {
34
+ declare module 'vue' {
35
35
  interface ComponentCustomProperties {
36
36
  /**
37
37
  * Maz theme plugin options
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC9B,OAAO,KAAK,EAAoB,WAAW,EAAe,UAAU,EAAE,MAAM,SAAS,CAAA;AAWrF,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC;IACpE;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAE3B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAiDD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU;iBACF,GAAG,YAAW,iBAAiB;CAwDnD,CAAA;AAED,OAAO,QAAQ,mBAAmB,CAAC;IACjC,UAAU,yBAAyB;QACjC;;;;;;;;;;;;;;WAcG;QACH,cAAc,EAAE,UAAU,CAAA;KAC3B;CACF"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC9B,OAAO,KAAK,EAAoB,WAAW,EAAe,UAAU,EAAE,MAAM,SAAS,CAAA;AAarF,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC;IACpE;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAE3B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,OAAO,CAAA;CACxB;AAiDD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,UAAU;iBACF,GAAG,YAAW,iBAAiB;CAyDnD,CAAA;AAED,OAAO,QAAQ,KAAK,CAAC;IACnB,UAAU,yBAAyB;QACjC;;;;;;;;;;;;;;WAcG;QACH,cAAc,EAAE,UAAU,CAAA;KAC3B;CACF"}
@@ -5,9 +5,9 @@ export interface CriticalCSSOptions {
5
5
  /** Critical foundation variables to include */
6
6
  criticalFoundation?: (keyof ThemeFoundation)[];
7
7
  /** Theme mode to generate */
8
- mode?: ThemeMode;
8
+ mode: ThemeMode;
9
9
  /** Dark mode selector: 'class' (.dark) | 'media' (@media) */
10
- darkSelectorStrategy?: DarkModeStrategy;
10
+ darkSelectorStrategy: DarkModeStrategy;
11
11
  /** CSS variables prefix */
12
12
  prefix?: string;
13
13
  }
@@ -15,9 +15,9 @@ export interface FullCSSOptions {
15
15
  /** Critical variables to exclude (to avoid duplication) */
16
16
  excludeCritical?: (keyof ThemeColors | keyof ThemeFoundation)[];
17
17
  /** Theme mode to generate */
18
- mode?: ThemeMode;
18
+ mode: ThemeMode;
19
19
  /** Dark mode selector: 'class' (.dark) | 'media' (@media) */
20
- darkSelectorStrategy?: DarkModeStrategy;
20
+ darkSelectorStrategy: DarkModeStrategy;
21
21
  /** CSS variables prefix */
22
22
  prefix?: string;
23
23
  /** Include color scales (50-900) */
@@ -1 +1 @@
1
- {"version":3,"file":"css-generator.d.ts","sourceRoot":"","sources":["../../../src/utils/css-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,eAAe,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAOtG,MAAM,WAAW,kBAAkB;IACjC,0CAA0C;IAC1C,cAAc,CAAC,EAAE,CAAC,MAAM,WAAW,CAAC,EAAE,CAAA;IACtC,+CAA+C;IAC/C,kBAAkB,CAAC,EAAE,CAAC,MAAM,eAAe,CAAC,EAAE,CAAA;IAC9C,6BAA6B;IAC7B,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,6DAA6D;IAC7D,oBAAoB,CAAC,EAAE,gBAAgB,CAAA;IACvC,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,2DAA2D;IAC3D,eAAe,CAAC,EAAE,CAAC,MAAM,WAAW,GAAG,MAAM,eAAe,CAAC,EAAE,CAAA;IAC/D,6BAA6B;IAC7B,IAAI,CAAC,EAAE,SAAS,CAAA;IAChB,6DAA6D;IAC7D,oBAAoB,CAAC,EAAE,gBAAgB,CAAA;IACvC,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,oCAAoC;IACpC,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B;AAoCD;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,kBAAuB,GAC/B,MAAM,CAsCR;AAMD;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,cAAmB,GAC3B,MAAM,CA0CR;AA+ID,oBAAY,OAAO;IACjB,IAAI,mBAAmB;IACvB,QAAQ,uBAAuB;CAChC;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,GAAG,IAAI,CAaxD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAQ3C"}
1
+ {"version":3,"file":"css-generator.d.ts","sourceRoot":"","sources":["../../../src/utils/css-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,eAAe,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAOtG,MAAM,WAAW,kBAAkB;IACjC,0CAA0C;IAC1C,cAAc,CAAC,EAAE,CAAC,MAAM,WAAW,CAAC,EAAE,CAAA;IACtC,+CAA+C;IAC/C,kBAAkB,CAAC,EAAE,CAAC,MAAM,eAAe,CAAC,EAAE,CAAA;IAC9C,6BAA6B;IAC7B,IAAI,EAAE,SAAS,CAAA;IACf,6DAA6D;IAC7D,oBAAoB,EAAE,gBAAgB,CAAA;IACtC,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,cAAc;IAC7B,2DAA2D;IAC3D,eAAe,CAAC,EAAE,CAAC,MAAM,WAAW,GAAG,MAAM,eAAe,CAAC,EAAE,CAAA;IAC/D,6BAA6B;IAC7B,IAAI,EAAE,SAAS,CAAA;IACf,6DAA6D;IAC7D,oBAAoB,EAAE,gBAAgB,CAAA;IACtC,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,oCAAoC;IACpC,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAC7B;AAoCD;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,kBAGR,GACA,MAAM,CAwCR;AAMD;;;GAGG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,cAGR,GACA,MAAM,CA4CR;AA+ID,oBAAY,OAAO;IACjB,IAAI,mBAAmB;IACvB,QAAQ,uBAAuB;CAChC;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,OAAO,GAAG,IAAI,CAaxD;AAED;;GAEG;AACH,wBAAgB,SAAS,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAQ3C"}
@@ -1,4 +1,4 @@
1
1
  import { ColorMode } from '../types';
2
2
  export declare function getColorMode(colorMode?: ColorMode): ColorMode;
3
- export declare function getSystemPrefersDark(): "light" | "dark";
3
+ export declare function isSystemPrefersDark(): boolean;
4
4
  //# sourceMappingURL=get-color-mode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get-color-mode.d.ts","sourceRoot":"","sources":["../../../src/utils/get-color-mode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAGzC,wBAAgB,YAAY,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAW7D;AAED,wBAAgB,oBAAoB,qBAInC"}
1
+ {"version":3,"file":"get-color-mode.d.ts","sourceRoot":"","sources":["../../../src/utils/get-color-mode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAGzC,wBAAgB,YAAY,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAW7D;AAED,wBAAgB,mBAAmB,YAElC"}
@@ -26,67 +26,89 @@ const h = [
26
26
  "font-family",
27
27
  "base-font-size",
28
28
  "border-width"
29
- ], y = ["primary", "secondary", "accent", "destructive", "success", "warning", "info", "contrast", "background", "foreground", "border", "muted", "overlay", "shadow"];
30
- function j(e, o = {}) {
29
+ ], S = ["primary", "secondary", "accent", "destructive", "success", "warning", "info", "contrast", "background", "foreground", "border", "muted", "overlay", "shadow"];
30
+ function j(e, o = {
31
+ mode: "both",
32
+ darkSelectorStrategy: "class"
33
+ }) {
31
34
  const {
32
35
  criticalColors: r = h,
33
36
  criticalFoundation: c = C,
34
- mode: n = "both",
35
- darkSelectorStrategy: a = "class",
37
+ mode: t,
38
+ darkSelectorStrategy: s,
36
39
  prefix: i = "maz"
37
- } = o, d = m(e.colors.light, r), s = m(e.colors.dark, r), l = S(e.foundation, c);
38
- let t = `@layer maz-ui-theme {
40
+ } = o, l = y(e.foundation, c);
41
+ let n = `@layer maz-ui-theme {
39
42
  `;
40
- return (n === "light" || n === "both") && (t += f({
41
- selector: ":root",
42
- colors: d,
43
- foundation: l,
44
- prefix: i
45
- })), (n === "dark" || n === "both") && (t += f({
46
- selector: a === "media" ? ":root" : ".dark",
47
- mediaQuery: a === "media" ? "@media (prefers-color-scheme: dark)" : void 0,
48
- colors: s,
49
- foundation: l,
50
- prefix: i
51
- })), t += `}
52
- `, t;
43
+ if (t === "light" || t === "both") {
44
+ const a = m(e.colors.light, r);
45
+ n += f({
46
+ selector: ":root",
47
+ colors: a,
48
+ foundation: l,
49
+ prefix: i
50
+ });
51
+ }
52
+ if (t === "dark" || t === "both") {
53
+ const a = m(e.colors.dark, r);
54
+ n += f({
55
+ selector: s === "media" ? ":root" : ".dark",
56
+ mediaQuery: s === "media" ? "@media (prefers-color-scheme: dark)" : void 0,
57
+ colors: a,
58
+ foundation: l,
59
+ prefix: i
60
+ });
61
+ }
62
+ return n += `}
63
+ `, n;
53
64
  }
54
- function p(e, o = {}) {
65
+ function p(e, o = {
66
+ mode: "both",
67
+ darkSelectorStrategy: "class"
68
+ }) {
55
69
  const {
56
70
  excludeCritical: r = h,
57
- mode: c = "both",
58
- darkSelectorStrategy: n = "class",
59
- prefix: a = "maz",
71
+ mode: c,
72
+ darkSelectorStrategy: t,
73
+ prefix: s = "maz",
60
74
  includeColorScales: i = !0
61
- } = o, d = g(e.colors.light, r), s = g(e.colors.dark, r), l = k(e.foundation, C);
62
- let t = `@layer maz-ui-theme {
75
+ } = o, l = k(e.foundation, C);
76
+ let n = `@layer maz-ui-theme {
63
77
  `;
64
- return (c === "light" || c === "both") && (t += f({
65
- selector: ":root",
66
- colors: d,
67
- foundation: l,
68
- prefix: a,
69
- includeScales: i,
70
- preset: e
71
- })), (c === "dark" || c === "both") && (t += f({
72
- selector: n === "media" ? ":root" : ".dark",
73
- mediaQuery: n === "media" ? "@media (prefers-color-scheme: dark)" : void 0,
74
- colors: s,
75
- foundation: c === "dark" ? l : void 0,
76
- // Appearance only if dark mode only
77
- prefix: a,
78
- includeScales: i,
79
- preset: e,
80
- isDark: !0
81
- })), t += `}
82
- `, t;
78
+ if (c === "light" || c === "both") {
79
+ const a = g(e.colors.light, r);
80
+ n += f({
81
+ selector: ":root",
82
+ colors: a,
83
+ foundation: l,
84
+ prefix: s,
85
+ includeScales: i,
86
+ preset: e
87
+ });
88
+ }
89
+ if (c === "dark" || c === "both") {
90
+ const a = g(e.colors.dark, r);
91
+ n += f({
92
+ selector: t === "media" ? ":root" : ".dark",
93
+ mediaQuery: t === "media" ? "@media (prefers-color-scheme: dark)" : void 0,
94
+ colors: a,
95
+ foundation: c === "dark" ? l : void 0,
96
+ // Appearance only if dark mode only
97
+ prefix: s,
98
+ includeScales: i,
99
+ preset: e,
100
+ isDark: !0
101
+ });
102
+ }
103
+ return n += `}
104
+ `, n;
83
105
  }
84
106
  function m(e, o) {
85
107
  return Object.fromEntries(
86
108
  o.filter((r) => e[r]).map((r) => [r, e[r]])
87
109
  );
88
110
  }
89
- function S(e, o) {
111
+ function y(e, o) {
90
112
  return e ? Object.fromEntries(
91
113
  o.filter((r) => e[r]).map((r) => [r, e[r]])
92
114
  ) : {};
@@ -106,42 +128,42 @@ function f({
106
128
  mediaQuery: o,
107
129
  colors: r,
108
130
  foundation: c,
109
- prefix: n,
110
- includeScales: a = !1,
131
+ prefix: t,
132
+ includeScales: s = !1,
111
133
  preset: i,
112
- isDark: d = !1
134
+ isDark: l = !1
113
135
  }) {
114
- const s = [];
115
- if (r && Object.entries(r).forEach(([t, u]) => {
116
- u && s.push(` --${n}-${t}: ${u};`);
117
- }), c && Object.entries(c).forEach(([t, u]) => {
118
- u && s.push(` --${n}-${t}: ${u};`);
119
- }), a && i) {
120
- const t = d ? i.colors.dark : i.colors.light, u = E(t, n);
121
- s.push(...u);
136
+ const n = [];
137
+ if (r && Object.entries(r).forEach(([u, d]) => {
138
+ d && n.push(` --${t}-${u}: ${d};`);
139
+ }), c && Object.entries(c).forEach(([u, d]) => {
140
+ d && n.push(` --${t}-${u}: ${d};`);
141
+ }), s && i) {
142
+ const u = l ? i.colors.dark : i.colors.light, d = E(u, t);
143
+ n.push(...d);
122
144
  }
123
- const l = s.join(`
145
+ const a = n.join(`
124
146
  `);
125
147
  return o ? `
126
148
  ${o} {
127
149
  ${e} {
128
- ${l.replace(/^/gm, " ")}
150
+ ${a.replace(/^/gm, " ")}
129
151
  }
130
152
  }
131
153
  ` : `
132
154
  ${e} {
133
- ${l}
155
+ ${a}
134
156
  }
135
157
  `;
136
158
  }
137
159
  function E(e, o) {
138
160
  const r = [];
139
- return y.forEach((c) => {
140
- const n = e[c];
141
- if (n) {
142
- const a = b(n);
143
- Object.entries(a).forEach(([i, d]) => {
144
- r.push(` --${o}-${c}-${i}: ${d};`);
161
+ return S.forEach((c) => {
162
+ const t = e[c];
163
+ if (t) {
164
+ const s = b(t);
165
+ Object.entries(s).forEach(([i, l]) => {
166
+ r.push(` --${o}-${c}-${i}: ${l};`);
145
167
  });
146
168
  }
147
169
  }), r;
@@ -1,14 +1,14 @@
1
- import { getCookie as t } from "./cookie-storage.js";
2
- function a(e) {
1
+ import { getCookie as r } from "./cookie-storage.js";
2
+ function o(e) {
3
3
  if (e && ["light", "dark"].includes(e))
4
4
  return e;
5
- const r = t("maz-color-mode");
6
- return r && ["light", "dark"].includes(r) ? r : i();
5
+ const t = r("maz-color-mode");
6
+ return t && ["light", "dark"].includes(t) ? t : "auto";
7
7
  }
8
- function i() {
9
- return typeof globalThis.window < "u" && typeof globalThis.matchMedia == "function" && globalThis.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
8
+ function n() {
9
+ return typeof globalThis.window < "u" && typeof globalThis.matchMedia == "function" && globalThis.matchMedia("(prefers-color-scheme: dark)").matches;
10
10
  }
11
11
  export {
12
- a as getColorMode,
13
- i as getSystemPrefersDark
12
+ o as getColorMode,
13
+ n as isSystemPrefersDark
14
14
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maz-ui/themes",
3
3
  "type": "module",
4
- "version": "4.0.0-beta.19",
4
+ "version": "4.0.0-beta.22",
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",
@@ -100,5 +100,5 @@
100
100
  "lint-staged": {
101
101
  "*.{js,ts,vue,mjs,mts,cjs,md,yml,json}": "cross-env NODE_ENV=production eslint --fix"
102
102
  },
103
- "gitHead": "80c4301de259a3f8d432c8da0994da8d51c5b564"
103
+ "gitHead": "372f6e17aca4c1391167abe40af57fd2175a82a5"
104
104
  }