@maz-ui/themes 4.0.1 → 4.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.
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { initThemeState as T, useTheme as a } from "./useTheme.js";
|
|
1
2
|
import "vue";
|
|
2
3
|
import "../utils/cookie-storage.js";
|
|
3
4
|
import "../utils/css-generator.js";
|
|
4
5
|
import "../utils/get-color-mode.js";
|
|
5
6
|
import "../utils/get-preset.js";
|
|
6
7
|
import "../utils/preset-merger.js";
|
|
7
|
-
import { initThemeState as T, useTheme as a } from "./useTheme.js";
|
|
8
8
|
export {
|
|
9
9
|
T as initThemeState,
|
|
10
10
|
a as useTheme
|
|
@@ -1,20 +1,60 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { setCookie as
|
|
3
|
-
import { generateCriticalCSS as
|
|
4
|
-
import { getColorMode as
|
|
5
|
-
import { getPreset as
|
|
6
|
-
import { mergePresets as
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { ref as d, onMounted as k, computed as s, toValue as P, watch as y, watchEffect as w, inject as T, getCurrentInstance as S } from "vue";
|
|
2
|
+
import { setCookie as C } from "../utils/cookie-storage.js";
|
|
3
|
+
import { generateCriticalCSS as z, generateFullCSS as E, injectCSS as p, CSS_IDS as v } from "../utils/css-generator.js";
|
|
4
|
+
import { getColorMode as L, isSystemPrefersDark as x } from "../utils/get-color-mode.js";
|
|
5
|
+
import { getPreset as D } from "../utils/get-preset.js";
|
|
6
|
+
import { mergePresets as I } from "../utils/preset-merger.js";
|
|
7
|
+
function O() {
|
|
8
|
+
return typeof document > "u" || typeof globalThis.window > "u";
|
|
9
|
+
}
|
|
10
|
+
function $() {
|
|
11
|
+
return typeof document < "u";
|
|
12
|
+
}
|
|
13
|
+
function F(e) {
|
|
14
|
+
return !!e;
|
|
15
|
+
}
|
|
16
|
+
function R(e, o, r = {}) {
|
|
17
|
+
const {
|
|
18
|
+
internalWindow: u = $() ? globalThis : void 0,
|
|
19
|
+
...l
|
|
20
|
+
} = r;
|
|
21
|
+
let n;
|
|
22
|
+
const c = d(!1);
|
|
23
|
+
k(() => {
|
|
24
|
+
c.value = (u && "MutationObserver" in u) ?? !1;
|
|
25
|
+
});
|
|
26
|
+
const m = () => {
|
|
27
|
+
n && (n.disconnect(), n = void 0);
|
|
28
|
+
}, h = s(() => {
|
|
29
|
+
const a = P(e);
|
|
30
|
+
let i;
|
|
31
|
+
return a && "$el" in a ? i = a.$el : a && (i = a), new Set([i].filter(F));
|
|
32
|
+
}), b = y(
|
|
33
|
+
h,
|
|
34
|
+
(a) => {
|
|
35
|
+
m(), c.value && a.size && (n = new MutationObserver(o), a.forEach((i) => n.observe(i, l)));
|
|
36
|
+
},
|
|
37
|
+
{ immediate: !0, flush: "post" }
|
|
38
|
+
);
|
|
39
|
+
return {
|
|
40
|
+
isSupported: c,
|
|
41
|
+
stop: () => {
|
|
42
|
+
b(), m();
|
|
43
|
+
},
|
|
44
|
+
takeRecords: () => n?.takeRecords()
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
const t = d();
|
|
48
|
+
function M(e) {
|
|
9
49
|
typeof document > "u" || !e || e.darkModeStrategy === "media" || e.mode === "light" || (e.isDark ? document.documentElement.classList.add("dark") : document.documentElement.classList.remove("dark"));
|
|
10
50
|
}
|
|
11
|
-
function
|
|
12
|
-
const e =
|
|
13
|
-
e &&
|
|
51
|
+
function U() {
|
|
52
|
+
const e = S()?.appContext.app;
|
|
53
|
+
e && t.value && (e.config.globalProperties.$mazThemeState = t.value);
|
|
14
54
|
}
|
|
15
|
-
function
|
|
55
|
+
function j(e) {
|
|
16
56
|
if (e.currentPreset && e.colorMode !== void 0) {
|
|
17
|
-
|
|
57
|
+
g({
|
|
18
58
|
currentPreset: e.currentPreset,
|
|
19
59
|
colorMode: e.colorMode,
|
|
20
60
|
mode: e.mode,
|
|
@@ -24,86 +64,98 @@ function b(e) {
|
|
|
24
64
|
});
|
|
25
65
|
return;
|
|
26
66
|
}
|
|
27
|
-
const
|
|
28
|
-
|
|
67
|
+
const o = L(e.colorMode), r = o === "auto" ? x() : o === "dark";
|
|
68
|
+
g({
|
|
29
69
|
currentPreset: e.currentPreset,
|
|
30
|
-
colorMode:
|
|
70
|
+
colorMode: o,
|
|
31
71
|
mode: e.mode,
|
|
32
|
-
isDark:
|
|
72
|
+
isDark: r,
|
|
33
73
|
strategy: e.strategy,
|
|
34
74
|
darkModeStrategy: e.darkModeStrategy
|
|
35
75
|
});
|
|
36
76
|
}
|
|
37
|
-
function
|
|
38
|
-
if (
|
|
39
|
-
const
|
|
40
|
-
|
|
77
|
+
function g(e) {
|
|
78
|
+
if (t.value = e, typeof globalThis.window < "u" && t.value.colorMode === "auto") {
|
|
79
|
+
const o = globalThis.matchMedia("(prefers-color-scheme: dark)"), r = () => {
|
|
80
|
+
t.value && t.value.colorMode === "auto" && (t.value.isDark = o.matches);
|
|
41
81
|
};
|
|
42
|
-
|
|
82
|
+
o.addEventListener("change", r), r();
|
|
43
83
|
}
|
|
44
|
-
|
|
45
|
-
|
|
84
|
+
w(() => {
|
|
85
|
+
t.value && (M(t.value), U());
|
|
46
86
|
});
|
|
47
87
|
}
|
|
48
|
-
const
|
|
49
|
-
get: () =>
|
|
50
|
-
set: (e) =>
|
|
51
|
-
}),
|
|
52
|
-
async function
|
|
53
|
-
if (!
|
|
88
|
+
const N = s({
|
|
89
|
+
get: () => t.value?.colorMode,
|
|
90
|
+
set: (e) => f(e)
|
|
91
|
+
}), W = s(() => t.value?.isDark ?? !1), _ = s(() => t.value?.strategy), A = s(() => t.value?.mode), G = s(() => t.value?.darkModeStrategy), Q = s(() => t.value?.currentPreset?.name);
|
|
92
|
+
async function V(e) {
|
|
93
|
+
if (!t.value)
|
|
54
94
|
return;
|
|
55
|
-
const
|
|
56
|
-
if (!
|
|
95
|
+
const o = typeof e == "string" ? await D(e) : e;
|
|
96
|
+
if (!o || !t.value.currentPreset) {
|
|
57
97
|
console.error("[@maz-ui/themes] No preset found - If you are using the buildtime strategy, you must provide a complete preset");
|
|
58
98
|
return;
|
|
59
99
|
}
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
62
|
-
const
|
|
63
|
-
mode:
|
|
64
|
-
darkSelectorStrategy:
|
|
100
|
+
const r = "name" in o && o.name !== t.value.currentPreset.name ? o : I(t.value.currentPreset, o);
|
|
101
|
+
if (t.value.currentPreset = r, t.value.strategy === "runtime" || t.value.strategy === "hybrid") {
|
|
102
|
+
const u = {
|
|
103
|
+
mode: t.value.mode,
|
|
104
|
+
darkSelectorStrategy: t.value.darkModeStrategy,
|
|
65
105
|
prefix: "maz"
|
|
66
|
-
},
|
|
67
|
-
|
|
106
|
+
}, l = z(r, u), n = E(r, u);
|
|
107
|
+
p(v.CRITICAL, l), p(v.FULL, n);
|
|
68
108
|
}
|
|
69
109
|
}
|
|
70
|
-
function
|
|
71
|
-
|
|
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), C("maz-color-mode", e));
|
|
72
112
|
}
|
|
73
|
-
function
|
|
74
|
-
|
|
113
|
+
function Y() {
|
|
114
|
+
t.value && f(t.value.isDark ? "light" : "dark");
|
|
75
115
|
}
|
|
76
|
-
function
|
|
77
|
-
|
|
116
|
+
function te() {
|
|
117
|
+
const e = d();
|
|
118
|
+
k(() => {
|
|
119
|
+
e.value = document.documentElement;
|
|
120
|
+
}), R(
|
|
121
|
+
e,
|
|
122
|
+
() => {
|
|
123
|
+
!t.value || O() || (t.value.isDark = document.documentElement.classList.contains("dark"));
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
attributes: !0
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
let o;
|
|
78
130
|
try {
|
|
79
|
-
if (
|
|
131
|
+
if (o = T("mazThemeState", void 0), !o)
|
|
80
132
|
throw new Error("mazThemeState not found");
|
|
81
133
|
} catch {
|
|
82
|
-
const
|
|
83
|
-
|
|
134
|
+
const r = S();
|
|
135
|
+
r?.appContext?.app?.config?.globalProperties && (o = r.appContext.app.config.globalProperties.$mazThemeState);
|
|
84
136
|
}
|
|
85
|
-
if (
|
|
86
|
-
...
|
|
87
|
-
...
|
|
88
|
-
}) :
|
|
89
|
-
|
|
137
|
+
if (o && (t.value ? (typeof document > "u" || typeof globalThis.window > "u") && (t.value = {
|
|
138
|
+
...t.value,
|
|
139
|
+
...o
|
|
140
|
+
}) : j(o)), y(() => o?.currentPreset, (r) => {
|
|
141
|
+
t.value && r && (t.value.currentPreset = r);
|
|
90
142
|
}, {
|
|
91
143
|
once: !0
|
|
92
|
-
}), !
|
|
144
|
+
}), !t.value)
|
|
93
145
|
throw new Error("[@maz-ui/themes] You must install the MazUi or MazUiTheme plugin before using useTheme composable");
|
|
94
146
|
return {
|
|
95
|
-
presetName:
|
|
96
|
-
colorMode:
|
|
97
|
-
isDark:
|
|
98
|
-
strategy:
|
|
99
|
-
updateTheme:
|
|
100
|
-
setColorMode:
|
|
101
|
-
toggleDarkMode:
|
|
102
|
-
mode:
|
|
103
|
-
darkModeStrategy:
|
|
147
|
+
presetName: Q,
|
|
148
|
+
colorMode: N,
|
|
149
|
+
isDark: W,
|
|
150
|
+
strategy: _,
|
|
151
|
+
updateTheme: V,
|
|
152
|
+
setColorMode: f,
|
|
153
|
+
toggleDarkMode: Y,
|
|
154
|
+
mode: A,
|
|
155
|
+
darkModeStrategy: G
|
|
104
156
|
};
|
|
105
157
|
}
|
|
106
158
|
export {
|
|
107
|
-
|
|
108
|
-
|
|
159
|
+
g as initThemeState,
|
|
160
|
+
te as useTheme
|
|
109
161
|
};
|
|
@@ -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;
|
|
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;AAaD,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;;;;;;;;;;EAsEvB"}
|
|
@@ -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;AAGtG,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;AAmCD,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,kBAGR,GACA,MAAM,CAwCR;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,cAGR,GACA,MAAM,CA4CR;AAoHD,oBAAY,OAAO;IACjB,IAAI,mBAAmB;IACvB,QAAQ,uBAAuB;CAChC;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,
|
|
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;AAGtG,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;AAmCD,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,kBAGR,GACA,MAAM,CAwCR;AAED,wBAAgB,eAAe,CAC7B,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,cAGR,GACA,MAAM,CA4CR;AAoHD,oBAAY,OAAO;IACjB,IAAI,mBAAmB;IACvB,QAAQ,uBAAuB;CAChC;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CA2BxD;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAS3C"}
|
|
@@ -27,164 +27,178 @@ const h = [
|
|
|
27
27
|
"base-font-size",
|
|
28
28
|
"border-width"
|
|
29
29
|
], S = ["primary", "secondary", "accent", "destructive", "success", "warning", "info", "contrast", "background", "foreground", "border", "muted", "overlay", "shadow"];
|
|
30
|
-
function j(
|
|
30
|
+
function j(r, t = {
|
|
31
31
|
mode: "both",
|
|
32
32
|
darkSelectorStrategy: "class"
|
|
33
33
|
}) {
|
|
34
34
|
const {
|
|
35
|
-
criticalColors:
|
|
36
|
-
criticalFoundation:
|
|
37
|
-
mode:
|
|
38
|
-
darkSelectorStrategy:
|
|
35
|
+
criticalColors: e = h,
|
|
36
|
+
criticalFoundation: o = C,
|
|
37
|
+
mode: n,
|
|
38
|
+
darkSelectorStrategy: l,
|
|
39
39
|
prefix: i = "maz"
|
|
40
|
-
} =
|
|
41
|
-
let
|
|
40
|
+
} = t, s = y(r.foundation, o);
|
|
41
|
+
let c = `@layer maz-ui-theme {
|
|
42
42
|
`;
|
|
43
|
-
if (
|
|
44
|
-
const a = m(
|
|
45
|
-
|
|
43
|
+
if (n === "light" || n === "both") {
|
|
44
|
+
const a = m(r.colors.light, e);
|
|
45
|
+
c += f({
|
|
46
46
|
selector: ":root",
|
|
47
47
|
colors: a,
|
|
48
|
-
foundation:
|
|
48
|
+
foundation: s,
|
|
49
49
|
prefix: i
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
-
if (
|
|
53
|
-
const a = m(
|
|
54
|
-
|
|
55
|
-
selector:
|
|
56
|
-
mediaQuery:
|
|
52
|
+
if (n === "dark" || n === "both") {
|
|
53
|
+
const a = m(r.colors.dark, e);
|
|
54
|
+
c += f({
|
|
55
|
+
selector: l === "media" ? ":root" : ".dark",
|
|
56
|
+
mediaQuery: l === "media" ? "@media (prefers-color-scheme: dark)" : void 0,
|
|
57
57
|
colors: a,
|
|
58
|
-
foundation:
|
|
58
|
+
foundation: s,
|
|
59
59
|
prefix: i
|
|
60
60
|
});
|
|
61
61
|
}
|
|
62
|
-
return
|
|
63
|
-
`,
|
|
62
|
+
return c += `}
|
|
63
|
+
`, c;
|
|
64
64
|
}
|
|
65
|
-
function p(
|
|
65
|
+
function p(r, t = {
|
|
66
66
|
mode: "both",
|
|
67
67
|
darkSelectorStrategy: "class"
|
|
68
68
|
}) {
|
|
69
69
|
const {
|
|
70
|
-
excludeCritical:
|
|
71
|
-
mode:
|
|
72
|
-
darkSelectorStrategy:
|
|
73
|
-
prefix:
|
|
70
|
+
excludeCritical: e = h,
|
|
71
|
+
mode: o,
|
|
72
|
+
darkSelectorStrategy: n,
|
|
73
|
+
prefix: l = "maz",
|
|
74
74
|
includeColorScales: i = !0
|
|
75
|
-
} =
|
|
76
|
-
let
|
|
75
|
+
} = t, s = k(r.foundation, C);
|
|
76
|
+
let c = `@layer maz-ui-theme {
|
|
77
77
|
`;
|
|
78
|
-
if (
|
|
79
|
-
const a = g(
|
|
80
|
-
|
|
78
|
+
if (o === "light" || o === "both") {
|
|
79
|
+
const a = g(r.colors.light, e);
|
|
80
|
+
c += f({
|
|
81
81
|
selector: ":root",
|
|
82
82
|
colors: a,
|
|
83
|
-
foundation:
|
|
84
|
-
prefix:
|
|
83
|
+
foundation: s,
|
|
84
|
+
prefix: l,
|
|
85
85
|
includeScales: i,
|
|
86
|
-
preset:
|
|
86
|
+
preset: r
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
|
-
if (
|
|
90
|
-
const a = g(
|
|
91
|
-
|
|
92
|
-
selector:
|
|
93
|
-
mediaQuery:
|
|
89
|
+
if (o === "dark" || o === "both") {
|
|
90
|
+
const a = g(r.colors.dark, e);
|
|
91
|
+
c += f({
|
|
92
|
+
selector: n === "media" ? ":root" : ".dark",
|
|
93
|
+
mediaQuery: n === "media" ? "@media (prefers-color-scheme: dark)" : void 0,
|
|
94
94
|
colors: a,
|
|
95
|
-
foundation:
|
|
95
|
+
foundation: o === "dark" ? s : void 0,
|
|
96
96
|
// Appearance only if dark mode only
|
|
97
|
-
prefix:
|
|
97
|
+
prefix: l,
|
|
98
98
|
includeScales: i,
|
|
99
|
-
preset:
|
|
99
|
+
preset: r,
|
|
100
100
|
isDark: !0
|
|
101
101
|
});
|
|
102
102
|
}
|
|
103
|
-
return
|
|
104
|
-
`,
|
|
103
|
+
return c += `}
|
|
104
|
+
`, c;
|
|
105
105
|
}
|
|
106
|
-
function m(
|
|
106
|
+
function m(r, t) {
|
|
107
107
|
return Object.fromEntries(
|
|
108
|
-
|
|
108
|
+
t.filter((e) => r[e]).map((e) => [e, r[e]])
|
|
109
109
|
);
|
|
110
110
|
}
|
|
111
|
-
function y(
|
|
112
|
-
return
|
|
113
|
-
|
|
111
|
+
function y(r, t) {
|
|
112
|
+
return r ? Object.fromEntries(
|
|
113
|
+
t.filter((e) => r[e]).map((e) => [e, r[e]])
|
|
114
114
|
) : {};
|
|
115
115
|
}
|
|
116
|
-
function g(
|
|
116
|
+
function g(r, t) {
|
|
117
117
|
return Object.fromEntries(
|
|
118
|
-
Object.entries(
|
|
118
|
+
Object.entries(r).filter(([e]) => !t.includes(e))
|
|
119
119
|
);
|
|
120
120
|
}
|
|
121
|
-
function k(
|
|
122
|
-
return
|
|
123
|
-
Object.entries(
|
|
121
|
+
function k(r, t) {
|
|
122
|
+
return r ? Object.fromEntries(
|
|
123
|
+
Object.entries(r).filter(([e]) => !t.includes(e))
|
|
124
124
|
) : {};
|
|
125
125
|
}
|
|
126
126
|
function f({
|
|
127
|
-
selector:
|
|
128
|
-
mediaQuery:
|
|
129
|
-
colors:
|
|
130
|
-
foundation:
|
|
131
|
-
prefix:
|
|
132
|
-
includeScales:
|
|
127
|
+
selector: r,
|
|
128
|
+
mediaQuery: t,
|
|
129
|
+
colors: e,
|
|
130
|
+
foundation: o,
|
|
131
|
+
prefix: n,
|
|
132
|
+
includeScales: l = !1,
|
|
133
133
|
preset: i,
|
|
134
|
-
isDark:
|
|
134
|
+
isDark: s = !1
|
|
135
135
|
}) {
|
|
136
|
-
const
|
|
137
|
-
if (
|
|
138
|
-
d &&
|
|
139
|
-
}),
|
|
140
|
-
d &&
|
|
141
|
-
}),
|
|
142
|
-
const u =
|
|
143
|
-
|
|
136
|
+
const c = [];
|
|
137
|
+
if (e && Object.entries(e).forEach(([u, d]) => {
|
|
138
|
+
d && c.push(` --${n}-${u}: ${d};`);
|
|
139
|
+
}), o && Object.entries(o).forEach(([u, d]) => {
|
|
140
|
+
d && c.push(` --${n}-${u}: ${d};`);
|
|
141
|
+
}), l && i) {
|
|
142
|
+
const u = s ? i.colors.dark : i.colors.light, d = $(u, n);
|
|
143
|
+
c.push(...d);
|
|
144
144
|
}
|
|
145
|
-
const a =
|
|
145
|
+
const a = c.join(`
|
|
146
146
|
`);
|
|
147
|
-
return
|
|
148
|
-
${
|
|
149
|
-
${
|
|
147
|
+
return t ? `
|
|
148
|
+
${t} {
|
|
149
|
+
${r} {
|
|
150
150
|
${a.replace(/^/gm, " ")}
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
` : `
|
|
154
|
-
${
|
|
154
|
+
${r} {
|
|
155
155
|
${a}
|
|
156
156
|
}
|
|
157
157
|
`;
|
|
158
158
|
}
|
|
159
|
-
function
|
|
160
|
-
const
|
|
161
|
-
return S.forEach((
|
|
162
|
-
const
|
|
163
|
-
if (
|
|
164
|
-
const
|
|
165
|
-
Object.entries(
|
|
166
|
-
|
|
159
|
+
function $(r, t) {
|
|
160
|
+
const e = [];
|
|
161
|
+
return S.forEach((o) => {
|
|
162
|
+
const n = r[o];
|
|
163
|
+
if (n) {
|
|
164
|
+
const l = b(n);
|
|
165
|
+
Object.entries(l).forEach(([i, s]) => {
|
|
166
|
+
e.push(` --${t}-${o}-${i}: ${s};`);
|
|
167
167
|
});
|
|
168
168
|
}
|
|
169
|
-
}),
|
|
169
|
+
}), e;
|
|
170
170
|
}
|
|
171
|
-
var
|
|
172
|
-
function v(
|
|
171
|
+
var E = /* @__PURE__ */ ((r) => (r.FULL = "maz-theme-full", r.CRITICAL = "maz-theme-critical", r))(E || {});
|
|
172
|
+
function v(r, t) {
|
|
173
173
|
if (typeof document > "u")
|
|
174
174
|
return;
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
const e = document.querySelectorAll(`#${r}`);
|
|
176
|
+
if (!e || e.length === 0) {
|
|
177
|
+
const o = document.createElement("style");
|
|
178
|
+
o.id = r, document.head.appendChild(o), o.textContent = t;
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (e.length === 1) {
|
|
182
|
+
e[0].textContent = t;
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (e.length > 1) {
|
|
186
|
+
for (let o = 0; o < e.length - 1; o++)
|
|
187
|
+
e[o].remove();
|
|
188
|
+
e[e.length - 1].textContent = t;
|
|
189
|
+
}
|
|
177
190
|
}
|
|
178
|
-
function
|
|
191
|
+
function x(r) {
|
|
179
192
|
if (typeof document > "u")
|
|
180
193
|
return;
|
|
181
|
-
const
|
|
182
|
-
|
|
194
|
+
const t = document.querySelectorAll(`#${r}`);
|
|
195
|
+
for (const e of t)
|
|
196
|
+
e && e.remove();
|
|
183
197
|
}
|
|
184
198
|
export {
|
|
185
|
-
|
|
199
|
+
E as CSS_IDS,
|
|
186
200
|
j as generateCriticalCSS,
|
|
187
201
|
p as generateFullCSS,
|
|
188
202
|
v as injectCSS,
|
|
189
|
-
|
|
203
|
+
x as removeCSS
|
|
190
204
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maz-ui/themes",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0
|
|
4
|
+
"version": "4.1.0",
|
|
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": "
|
|
105
|
+
"gitHead": "2f2ef4e0c3db8e64b814aa3c7c5a409e06af48af"
|
|
106
106
|
}
|