@maz-ui/themes 4.4.0 → 4.7.0-beta.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/build/index.d.ts.map +1 -0
- package/dist/composables/index.js +1 -1
- package/dist/composables/useTheme.d.ts.map +1 -0
- package/dist/composables/useTheme.js +14 -6
- package/dist/define-preset.d.ts.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +4 -128
- package/dist/presets/index.d.ts.map +1 -0
- package/dist/presets/mazUi.d.ts.map +1 -0
- package/dist/presets/obsidian.d.ts.map +1 -0
- package/dist/presets/ocean.d.ts.map +1 -0
- package/dist/presets/pristine.d.ts.map +1 -0
- package/dist/types/index.d.ts +190 -9
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/color-utils.d.ts.map +1 -0
- package/dist/utils/cookie-storage.d.ts.map +1 -0
- package/dist/utils/cookie-storage.js +1 -1
- package/dist/utils/css-generator.d.ts.map +1 -0
- package/dist/utils/css-generator.js +1 -1
- package/dist/utils/get-color-mode.d.ts.map +1 -0
- package/dist/utils/get-color-mode.js +1 -1
- package/dist/utils/get-preset.d.ts.map +1 -0
- package/dist/{types/utils → utils}/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +7 -0
- package/dist/utils/inject-theme-css.d.ts +4 -0
- package/dist/utils/inject-theme-css.d.ts.map +1 -0
- package/dist/utils/inject-theme-css.js +29 -0
- package/dist/utils/inject.d.ts +7 -0
- package/dist/utils/inject.d.ts.map +1 -0
- package/dist/utils/inject.js +11 -0
- package/dist/utils/no-transition.d.ts.map +1 -0
- package/dist/utils/no-transition.js +1 -1
- package/dist/utils/preset-merger.d.ts.map +1 -0
- package/dist/utils/setup-theme.d.ts +30 -0
- package/dist/utils/setup-theme.d.ts.map +1 -0
- package/dist/utils/setup-theme.js +135 -0
- package/dist/utils/update-document-class.d.ts.map +1 -0
- package/package.json +15 -20
- package/dist/chunks/isServer.BAlEcRRr.js +0 -6
- package/dist/plugin/index.js +0 -11
- package/dist/types/build/index.d.ts.map +0 -1
- package/dist/types/composables/useTheme.d.ts.map +0 -1
- package/dist/types/define-preset.d.ts.map +0 -1
- package/dist/types/plugin.d.ts.map +0 -1
- package/dist/types/presets/index.d.ts.map +0 -1
- package/dist/types/presets/mazUi.d.ts.map +0 -1
- package/dist/types/presets/obsidian.d.ts.map +0 -1
- package/dist/types/presets/ocean.d.ts.map +0 -1
- package/dist/types/presets/pristine.d.ts.map +0 -1
- package/dist/types/types/index.d.ts +0 -191
- package/dist/types/types/index.d.ts.map +0 -1
- package/dist/types/utils/color-utils.d.ts.map +0 -1
- package/dist/types/utils/cookie-storage.d.ts.map +0 -1
- package/dist/types/utils/css-generator.d.ts.map +0 -1
- package/dist/types/utils/get-color-mode.d.ts.map +0 -1
- package/dist/types/utils/get-preset.d.ts.map +0 -1
- package/dist/types/utils/index.d.ts.map +0 -1
- package/dist/types/utils/no-transition.d.ts.map +0 -1
- package/dist/types/utils/preset-merger.d.ts.map +0 -1
- package/dist/types/utils/update-document-class.d.ts.map +0 -1
- /package/dist/{types/build → build}/index.d.ts +0 -0
- /package/dist/{types/composables → composables}/useTheme.d.ts +0 -0
- /package/dist/{types/define-preset.d.ts → define-preset.d.ts} +0 -0
- /package/dist/{types/plugin.d.ts → plugin.d.ts} +0 -0
- /package/dist/{types/presets → presets}/index.d.ts +0 -0
- /package/dist/{types/presets → presets}/mazUi.d.ts +0 -0
- /package/dist/{types/presets → presets}/obsidian.d.ts +0 -0
- /package/dist/{types/presets → presets}/ocean.d.ts +0 -0
- /package/dist/{types/presets → presets}/pristine.d.ts +0 -0
- /package/dist/{types/utils → utils}/color-utils.d.ts +0 -0
- /package/dist/{types/utils → utils}/cookie-storage.d.ts +0 -0
- /package/dist/{types/utils → utils}/css-generator.d.ts +0 -0
- /package/dist/{types/utils → utils}/get-color-mode.d.ts +0 -0
- /package/dist/{types/utils → utils}/get-preset.d.ts +0 -0
- /package/dist/{types/utils → utils}/no-transition.d.ts +0 -0
- /package/dist/{types/utils → utils}/preset-merger.d.ts +0 -0
- /package/dist/{types/utils → utils}/update-document-class.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/build/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAG3C,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,WAAW,CAAA;IACnB,6BAA6B;IAC7B,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAA;IAChC,6DAA6D;IAC7D,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;IAChC,2BAA2B;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,iCAAiC;IACjC,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,sBAAsB;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB;AAED,wBAAgB,aAAa,CAAC,OAAO,EAAE,iBAAiB,GAAG,MAAM,CA0BhE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,WAAW,EAAE,EAAE,OAAO,GAAE;IACnE,8BAA8B;IAC9B,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,CAAA;IAChC,oCAAoC;IACpC,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;IAChC,gCAAgC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,wCAAwC;IACxC,YAAY,CAAC,EAAE,OAAO,CAAA;CAClB,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAkB9B;AAED,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE;IAC1D,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,MAAM,CAAA;CACV,GAAG,MAAM,CAYd;AAED,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,WAAW,EAAE,OAAO,GAAE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,YAAY,CAAC,EAAE,OAAO,GAAG,OAAO,CAAA;IAChC,SAAS,CAAC,EAAE,MAAM,CAAA;CACd,GAAG;IACP,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAWA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTheme.d.ts","sourceRoot":"","sources":["../../src/composables/useTheme.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,eAAe,EAAE,oBAAoB,EAAc,MAAM,UAAU,CAAA;AAwBzG,iBAAe,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,oBAAoB,GAAG,eAAe,iBA4BtF;AAED,iBAAS,YAAY,CAAC,SAAS,EAAE,SAAS,QAOzC;AAED,iBAAS,cAAc,SAEtB;AAiCD,wBAAgB,QAAQ;IAkBpB;;OAEG;;IAEH;;OAEG;;IAEH;;;OAGG;;IAEH;;OAEG;;IAEH;;OAEG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;;OAGG;;IAEH;;OAEG;;EAGN"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ref, computed, inject, getCurrentInstance } from "vue";
|
|
1
|
+
import { isServer } from "@maz-ui/utils/helpers/isServer";
|
|
2
|
+
import { ref, computed, inject, watch, getCurrentInstance } from "vue";
|
|
3
3
|
import { setCookie } from "../utils/cookie-storage.js";
|
|
4
4
|
import { generateCSS, injectCSS, CSS_ID } from "../utils/css-generator.js";
|
|
5
5
|
import { getPreset } from "../utils/get-preset.js";
|
|
@@ -33,11 +33,14 @@ function setColorMode(colorMode2) {
|
|
|
33
33
|
function toggleDarkMode() {
|
|
34
34
|
setColorMode(isDark.value ? "light" : "dark");
|
|
35
35
|
}
|
|
36
|
+
let stopInjectedWatch;
|
|
36
37
|
function setThemeStateFromGlobalProperties() {
|
|
37
|
-
themeState.value = void 0;
|
|
38
|
+
themeState.value = void 0, stopInjectedWatch?.(), stopInjectedWatch = void 0;
|
|
38
39
|
try {
|
|
39
40
|
const injectedState = inject("mazThemeState", void 0);
|
|
40
|
-
if (themeState.value = injectedState?.value,
|
|
41
|
+
if (themeState.value = injectedState?.value, injectedState && (stopInjectedWatch = watch(injectedState, (newState) => {
|
|
42
|
+
newState && (themeState.value = newState);
|
|
43
|
+
}, { deep: !0 })), !themeState.value)
|
|
41
44
|
throw new Error("mazThemeState not found");
|
|
42
45
|
} catch {
|
|
43
46
|
const instance = getCurrentInstance();
|
|
@@ -45,8 +48,13 @@ function setThemeStateFromGlobalProperties() {
|
|
|
45
48
|
}
|
|
46
49
|
}
|
|
47
50
|
function useTheme() {
|
|
48
|
-
|
|
49
|
-
|
|
51
|
+
isServer() && (themeState.value = void 0);
|
|
52
|
+
try {
|
|
53
|
+
if (themeState.value || setThemeStateFromGlobalProperties(), !themeState.value)
|
|
54
|
+
throw new Error("[@maz-ui/themes] no theme state found");
|
|
55
|
+
} catch {
|
|
56
|
+
throw new Error("[@maz-ui/themes] You must install the MazUi or MazUiTheme plugin, or wrap your components in a MazUiProvider, before using useTheme composable");
|
|
57
|
+
}
|
|
50
58
|
return {
|
|
51
59
|
/**
|
|
52
60
|
* Current theme preset
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"define-preset.d.ts","sourceRoot":"","sources":["../src/define-preset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAIjF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AAEH,wBAAgB,YAAY,CAAC,OAAO,EAAE;IACpC,IAAI,EAAE,WAAW,CAAA;IACjB,SAAS,EAAE,oBAAoB,CAAA;CAChC,GAAG,WAAW,CAAA;AAEf,wBAAgB,YAAY,CAAC,OAAO,EAAE;IACpC,IAAI,EAAE,eAAe,CAAA;IACrB,SAAS,EAAE,oBAAoB,CAAA;CAChC,GAAG,OAAO,CAAC,WAAW,CAAC,CAAA"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './build';
|
|
2
|
+
export * from './composables/useTheme';
|
|
3
|
+
export * from './define-preset';
|
|
4
|
+
export * from './plugin';
|
|
5
|
+
export * from './presets';
|
|
6
|
+
export * from './types';
|
|
7
|
+
export * from './utils/color-utils';
|
|
8
|
+
export * from './utils/css-generator';
|
|
9
|
+
export * from './utils/inject-theme-css';
|
|
10
|
+
export * from './utils/preset-merger';
|
|
11
|
+
export * from './utils/setup-theme';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,wBAAwB,CAAA;AACtC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,UAAU,CAAA;AACxB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,qBAAqB,CAAA;AACnC,cAAc,uBAAuB,CAAA;AACrC,cAAc,0BAA0B,CAAA;AACxC,cAAc,uBAAuB,CAAA;AACrC,cAAc,qBAAqB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,9 @@ import { definePreset } from "./define-preset.js";
|
|
|
4
4
|
import { MazUiTheme } from "./plugin.js";
|
|
5
5
|
import { adjustColorLightness, formatHSL, generateColorScale, getContrastColor, parseHSL } from "./utils/color-utils.js";
|
|
6
6
|
import { CSS_ID, generateCSS, injectCSS, removeCSS } from "./utils/css-generator.js";
|
|
7
|
+
import { injectThemeCSS } from "./utils/inject-theme-css.js";
|
|
7
8
|
import { deepMerge, mergePresets } from "./utils/preset-merger.js";
|
|
9
|
+
import { defaultOptions, setupTheme } from "./utils/setup-theme.js";
|
|
8
10
|
import { mazUi } from "./presets/mazUi.js";
|
|
9
11
|
import { obsidian } from "./presets/obsidian.js";
|
|
10
12
|
import { ocean } from "./presets/ocean.js";
|
|
@@ -17,6 +19,7 @@ export {
|
|
|
17
19
|
buildThemeCSS,
|
|
18
20
|
createThemeStylesheet,
|
|
19
21
|
deepMerge,
|
|
22
|
+
defaultOptions,
|
|
20
23
|
definePreset,
|
|
21
24
|
formatHSL,
|
|
22
25
|
generateCSS,
|
|
@@ -24,6 +27,7 @@ export {
|
|
|
24
27
|
generateThemeBundle,
|
|
25
28
|
getContrastColor,
|
|
26
29
|
injectCSS,
|
|
30
|
+
injectThemeCSS,
|
|
27
31
|
mazUi,
|
|
28
32
|
mergePresets,
|
|
29
33
|
obsidian,
|
|
@@ -31,5 +35,6 @@ export {
|
|
|
31
35
|
parseHSL,
|
|
32
36
|
pristine,
|
|
33
37
|
removeCSS,
|
|
38
|
+
setupTheme,
|
|
34
39
|
useTheme
|
|
35
40
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../src/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAO,MAAM,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AAC3C,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AAItD,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;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,CAAC,iBAAiB,CAAC,CAKlD,CAAA;AAED,OAAO,QAAQ,KAAK,CAAC;IACnB,UAAU,yBAAyB;QACjC;;;;;;;;;;;;;;WAcG;QACH,cAAc,EAAE,GAAG,CAAC,UAAU,CAAC,CAAA;KAChC;CACF"}
|
package/dist/plugin.js
CHANGED
|
@@ -1,133 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { generateCSS, injectCSS, CSS_ID } from "./utils/css-generator.js";
|
|
4
|
-
import { getSavedColorMode, getSystemColorMode, getColorMode } from "./utils/get-color-mode.js";
|
|
5
|
-
import { updateDocumentClass } from "./utils/update-document-class.js";
|
|
6
|
-
import { getPreset } from "./utils/get-preset.js";
|
|
7
|
-
import { mergePresets } from "./utils/preset-merger.js";
|
|
8
|
-
function isClient() {
|
|
9
|
-
return typeof document < "u";
|
|
10
|
-
}
|
|
11
|
-
function truthyFilter(value) {
|
|
12
|
-
return !!value;
|
|
13
|
-
}
|
|
14
|
-
function useMutationObserver(target, callback, options = {}) {
|
|
15
|
-
const {
|
|
16
|
-
internalWindow = isClient() ? globalThis : void 0,
|
|
17
|
-
...mutationOptions
|
|
18
|
-
} = options;
|
|
19
|
-
let observer;
|
|
20
|
-
const isSupported = ref((internalWindow && "MutationObserver" in internalWindow) ?? !1);
|
|
21
|
-
isSupported.value || onMounted(() => {
|
|
22
|
-
isSupported.value = (internalWindow && "MutationObserver" in internalWindow) ?? !1;
|
|
23
|
-
});
|
|
24
|
-
const cleanup = () => {
|
|
25
|
-
observer && (observer.disconnect(), observer = void 0);
|
|
26
|
-
}, targets = computed(() => {
|
|
27
|
-
const value = toValue(target);
|
|
28
|
-
let element;
|
|
29
|
-
return value && "$el" in value ? element = value.$el : value && (element = value), new Set([element].filter(truthyFilter));
|
|
30
|
-
}), stopWatch = watch(
|
|
31
|
-
[targets, isSupported],
|
|
32
|
-
([newTargets, isSupported2]) => {
|
|
33
|
-
cleanup(), isSupported2 && newTargets.size && (observer = new MutationObserver(callback), newTargets.forEach((el) => observer?.observe(el, mutationOptions)));
|
|
34
|
-
},
|
|
35
|
-
{ immediate: !0, flush: "post" }
|
|
36
|
-
);
|
|
37
|
-
return {
|
|
38
|
-
isSupported,
|
|
39
|
-
stop: () => {
|
|
40
|
-
stopWatch(), cleanup();
|
|
41
|
-
},
|
|
42
|
-
takeRecords: () => observer?.takeRecords()
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
function injectThemeCSS(finalPreset, config) {
|
|
46
|
-
if (typeof document > "u")
|
|
47
|
-
return;
|
|
48
|
-
const cssOptions = {
|
|
49
|
-
mode: config.mode,
|
|
50
|
-
darkSelectorStrategy: config.darkModeStrategy,
|
|
51
|
-
darkClass: config.darkClass
|
|
52
|
-
};
|
|
53
|
-
if (config.injectCriticalCSS) {
|
|
54
|
-
const criticalCSS = generateCSS(finalPreset, {
|
|
55
|
-
...cssOptions,
|
|
56
|
-
onlyCritical: !0
|
|
57
|
-
});
|
|
58
|
-
injectCSS(CSS_ID, criticalCSS);
|
|
59
|
-
}
|
|
60
|
-
if (!config.injectFullCSS)
|
|
61
|
-
return;
|
|
62
|
-
const fullCSS = generateCSS(finalPreset, cssOptions);
|
|
63
|
-
config.strategy === "runtime" ? injectCSS(CSS_ID, fullCSS) : config.strategy === "hybrid" && (typeof requestIdleCallback < "u" ? requestIdleCallback(() => {
|
|
64
|
-
injectCSS(CSS_ID, fullCSS);
|
|
65
|
-
}, { timeout: 100 }) : nextTick(() => {
|
|
66
|
-
injectCSS(CSS_ID, fullCSS);
|
|
67
|
-
}));
|
|
68
|
-
}
|
|
69
|
-
function injectThemeState(app, themeState) {
|
|
70
|
-
app.provide("mazThemeState", themeState), app.config.globalProperties.$mazThemeState = themeState;
|
|
71
|
-
}
|
|
72
|
-
function watchColorSchemeFromMedia(themeState) {
|
|
73
|
-
if (!isServer()) {
|
|
74
|
-
if (themeState.value && themeState.value.colorMode === "auto") {
|
|
75
|
-
const mediaQuery = globalThis.matchMedia("(prefers-color-scheme: dark)"), updateFromMedia = () => {
|
|
76
|
-
if (themeState.value.colorMode === "auto") {
|
|
77
|
-
const newColorMode = mediaQuery.matches ? "dark" : "light";
|
|
78
|
-
updateDocumentClass(newColorMode === "dark", themeState.value), themeState.value.isDark = newColorMode === "dark";
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
mediaQuery.addEventListener("change", updateFromMedia);
|
|
82
|
-
}
|
|
83
|
-
watch(() => themeState.value.colorMode, (colorMode) => {
|
|
84
|
-
updateDocumentClass(
|
|
85
|
-
colorMode === "auto" ? getSystemColorMode() === "dark" : colorMode === "dark",
|
|
86
|
-
themeState.value
|
|
87
|
-
);
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
function watchMutationClassOnHtmlElement(themeState) {
|
|
92
|
-
isServer() || useMutationObserver(
|
|
93
|
-
document.documentElement,
|
|
94
|
-
() => {
|
|
95
|
-
if (isServer() || !themeState.value)
|
|
96
|
-
return;
|
|
97
|
-
const activeColorMode = document.documentElement.classList.contains(themeState.value.darkClass) ? "dark" : "light";
|
|
98
|
-
themeState.value.isDark = activeColorMode === "dark", themeState.value.colorMode !== activeColorMode && themeState.value.colorMode !== "auto" && (themeState.value.colorMode = activeColorMode);
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
attributes: !0
|
|
102
|
-
}
|
|
103
|
-
);
|
|
104
|
-
}
|
|
1
|
+
import { setupTheme } from "./utils/setup-theme.js";
|
|
2
|
+
import { injectThemeState } from "./utils/inject.js";
|
|
105
3
|
const MazUiTheme = {
|
|
106
4
|
async install(app, options) {
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
overrides: {},
|
|
110
|
-
darkModeStrategy: "class",
|
|
111
|
-
preset: void 0,
|
|
112
|
-
injectCriticalCSS: !0,
|
|
113
|
-
injectFullCSS: !0,
|
|
114
|
-
mode: "both",
|
|
115
|
-
darkClass: "dark",
|
|
116
|
-
...options,
|
|
117
|
-
colorMode: getSavedColorMode() ?? options.colorMode ?? (options.mode === "dark" ? "dark" : "auto")
|
|
118
|
-
}, isDark = config.colorMode === "auto" && config.mode === "both" ? getSystemColorMode() === "dark" || getColorMode(config.colorMode) === "dark" : getColorMode(config.colorMode) === "dark" || config.mode === "dark", themeState = ref({
|
|
119
|
-
strategy: config.strategy,
|
|
120
|
-
darkClass: config.darkClass,
|
|
121
|
-
darkModeStrategy: config.darkModeStrategy,
|
|
122
|
-
colorMode: config.colorMode,
|
|
123
|
-
mode: config.mode,
|
|
124
|
-
preset: void 0,
|
|
125
|
-
// @ts-expect-error _isDark is a private property
|
|
126
|
-
isDark: options._isDark || isDark
|
|
127
|
-
});
|
|
128
|
-
injectThemeState(app, themeState), updateDocumentClass(themeState.value.isDark, themeState.value);
|
|
129
|
-
const preset = config.strategy === "buildtime" ? config.preset : await getPreset(config.preset), finalPreset = Object.keys(config.overrides).length > 0 && preset ? mergePresets(preset, config.overrides) : preset;
|
|
130
|
-
finalPreset && (themeState.value.preset = finalPreset), !(config.strategy === "buildtime" || !finalPreset) && (injectThemeCSS(finalPreset, config), watchColorSchemeFromMedia(themeState), watchMutationClassOnHtmlElement(themeState));
|
|
5
|
+
const { themeState } = await setupTheme(options);
|
|
6
|
+
injectThemeState({ app, themeState });
|
|
131
7
|
}
|
|
132
8
|
};
|
|
133
9
|
export {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/presets/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mazUi.d.ts","sourceRoot":"","sources":["../../src/presets/mazUi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,eAAO,MAAM,KAAK,EAAE,WA0DnB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"obsidian.d.ts","sourceRoot":"","sources":["../../src/presets/obsidian.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,eAAO,MAAM,QAAQ,EAAE,WA2DtB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ocean.d.ts","sourceRoot":"","sources":["../../src/presets/ocean.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,eAAO,MAAM,KAAK,EAAE,WA0DnB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pristine.d.ts","sourceRoot":"","sources":["../../src/presets/pristine.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAE3C,eAAO,MAAM,QAAQ,EAAE,WA0DtB,CAAA"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,10 +1,191 @@
|
|
|
1
|
-
export
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
export type HSL = `${number} ${number}% ${number}%`;
|
|
2
|
+
export type SizeUnit = `${number}${'rem' | 'px' | 'em' | 'vw' | 'vh' | 'vmin' | 'vmax' | '%'}`;
|
|
3
|
+
export interface ThemeColors {
|
|
4
|
+
'background': HSL;
|
|
5
|
+
'foreground': HSL;
|
|
6
|
+
'primary': HSL;
|
|
7
|
+
'primary-foreground': HSL;
|
|
8
|
+
'secondary': HSL;
|
|
9
|
+
'secondary-foreground': HSL;
|
|
10
|
+
'accent': HSL;
|
|
11
|
+
'accent-foreground': HSL;
|
|
12
|
+
'info': HSL;
|
|
13
|
+
'info-foreground': HSL;
|
|
14
|
+
'contrast': HSL;
|
|
15
|
+
'contrast-foreground': HSL;
|
|
16
|
+
'destructive': HSL;
|
|
17
|
+
'destructive-foreground': HSL;
|
|
18
|
+
'success': HSL;
|
|
19
|
+
'success-foreground': HSL;
|
|
20
|
+
'warning': HSL;
|
|
21
|
+
'warning-foreground': HSL;
|
|
22
|
+
'overlay': HSL;
|
|
23
|
+
'muted': HSL;
|
|
24
|
+
'border': HSL;
|
|
25
|
+
'shadow': HSL;
|
|
26
|
+
}
|
|
27
|
+
export interface ThemeFoundation {
|
|
28
|
+
'base-font-size'?: SizeUnit;
|
|
29
|
+
'radius': SizeUnit;
|
|
30
|
+
'border-width': SizeUnit;
|
|
31
|
+
'font-family'?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface ThemePresetOverrides {
|
|
34
|
+
/**
|
|
35
|
+
* Theme name
|
|
36
|
+
* @default undefined
|
|
37
|
+
*/
|
|
38
|
+
name?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Theme colors
|
|
41
|
+
* @default undefined
|
|
42
|
+
*/
|
|
43
|
+
colors?: {
|
|
44
|
+
light?: Partial<ThemeColors>;
|
|
45
|
+
dark?: Partial<ThemeColors>;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Theme foundation
|
|
49
|
+
* @default undefined
|
|
50
|
+
*/
|
|
51
|
+
foundation?: Partial<ThemeFoundation>;
|
|
52
|
+
}
|
|
53
|
+
export interface ThemePreset {
|
|
54
|
+
/**
|
|
55
|
+
* Theme name
|
|
56
|
+
*/
|
|
57
|
+
name: string;
|
|
58
|
+
colors: {
|
|
59
|
+
light: ThemeColors;
|
|
60
|
+
dark: ThemeColors;
|
|
61
|
+
};
|
|
62
|
+
foundation: ThemeFoundation;
|
|
63
|
+
}
|
|
64
|
+
export type ThemePresetName = 'mazUi' | 'ocean' | 'pristine' | 'obsidian' | 'maz-ui';
|
|
65
|
+
export type ColorMode = 'light' | 'dark' | 'auto';
|
|
66
|
+
export type ThemeMode = 'light' | 'dark' | 'both';
|
|
67
|
+
export type DarkModeStrategy = 'class' | 'media';
|
|
68
|
+
export type Strategy = 'runtime' | 'buildtime' | 'hybrid';
|
|
69
|
+
interface BaseThemeConfig {
|
|
70
|
+
/**
|
|
71
|
+
* CSS variables prefix
|
|
72
|
+
* @description Prefix for CSS variables
|
|
73
|
+
* @default 'maz'
|
|
74
|
+
* @private
|
|
75
|
+
*/
|
|
76
|
+
prefix?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Theme preset to use - Optional if you use buildtime strategy
|
|
79
|
+
* @description Can be a predefined preset name or a custom preset object
|
|
80
|
+
* @default undefined
|
|
81
|
+
*/
|
|
82
|
+
preset?: ThemePreset;
|
|
83
|
+
/**
|
|
84
|
+
* Custom preset overrides
|
|
85
|
+
* @description Allows customizing specific parts of the preset without redefining it entirely
|
|
86
|
+
* @default undefined
|
|
87
|
+
*/
|
|
88
|
+
overrides?: ThemePresetOverrides;
|
|
89
|
+
/**
|
|
90
|
+
* CSS generation strategy
|
|
91
|
+
* @description
|
|
92
|
+
* - `runtime`: CSS generated (critical and full) injected immediately
|
|
93
|
+
* - `buildtime`: CSS generated at build time and included in bundle
|
|
94
|
+
* - `hybrid`: Critical CSS injected inline, full CSS loaded asynchronously (recommended)
|
|
95
|
+
* @default 'hybrid'
|
|
96
|
+
*/
|
|
97
|
+
strategy?: Strategy;
|
|
98
|
+
/**
|
|
99
|
+
* Dark mode class
|
|
100
|
+
* @description Class added to the document root when dark mode is active
|
|
101
|
+
* @default 'dark'
|
|
102
|
+
*/
|
|
103
|
+
darkClass?: string;
|
|
104
|
+
/**
|
|
105
|
+
* Dark mode handling
|
|
106
|
+
* @description
|
|
107
|
+
* - `class`: Dark mode activated with `.dark` class
|
|
108
|
+
* - `media`: Dark mode based on `prefers-color-scheme` (automatic detection of system preferences)
|
|
109
|
+
* @default 'class'
|
|
110
|
+
*/
|
|
111
|
+
darkModeStrategy?: DarkModeStrategy;
|
|
112
|
+
/**
|
|
113
|
+
* Initial color mode to use
|
|
114
|
+
* @description
|
|
115
|
+
* - `light`: Light mode
|
|
116
|
+
* - `dark`: Dark mode
|
|
117
|
+
* - `auto`: Automatic detection of system preferences
|
|
118
|
+
* @default 'auto'
|
|
119
|
+
*/
|
|
120
|
+
colorMode?: ColorMode;
|
|
121
|
+
/**
|
|
122
|
+
* Supported color modes to use
|
|
123
|
+
* @description
|
|
124
|
+
* - `light`: Will inject only light CSS variables
|
|
125
|
+
* - `dark`: Will inject only dark CSS variables
|
|
126
|
+
* - `both`: Will inject both light and dark CSS variables
|
|
127
|
+
* @default 'both'
|
|
128
|
+
*/
|
|
129
|
+
mode?: ThemeMode;
|
|
130
|
+
}
|
|
131
|
+
export type ThemeConfig = (BaseThemeConfig & {
|
|
132
|
+
strategy?: Exclude<Strategy, 'buildtime'>;
|
|
133
|
+
}) | (Omit<BaseThemeConfig, 'preset'> & {
|
|
134
|
+
preset?: ThemePreset;
|
|
135
|
+
strategy: 'buildtime';
|
|
136
|
+
});
|
|
137
|
+
export interface ColorScale {
|
|
138
|
+
50: string;
|
|
139
|
+
100: string;
|
|
140
|
+
200: string;
|
|
141
|
+
300: string;
|
|
142
|
+
400: string;
|
|
143
|
+
500: string;
|
|
144
|
+
600: string;
|
|
145
|
+
700: string;
|
|
146
|
+
800: string;
|
|
147
|
+
900: string;
|
|
148
|
+
950: string;
|
|
149
|
+
}
|
|
150
|
+
export interface ThemeState {
|
|
151
|
+
/**
|
|
152
|
+
* Current preset
|
|
153
|
+
* @description The preset used
|
|
154
|
+
*/
|
|
155
|
+
preset?: ThemePreset;
|
|
156
|
+
/**
|
|
157
|
+
* Color mode
|
|
158
|
+
* @description The color mode chosen
|
|
159
|
+
* @values 'light', 'dark', 'auto'
|
|
160
|
+
*/
|
|
161
|
+
colorMode: ColorMode;
|
|
162
|
+
/**
|
|
163
|
+
* Whether the current color mode is dark
|
|
164
|
+
*/
|
|
165
|
+
isDark: boolean;
|
|
166
|
+
/**
|
|
167
|
+
* Theme mode
|
|
168
|
+
* @description The theme mode chosen
|
|
169
|
+
* @values 'light', 'dark', 'both'
|
|
170
|
+
*/
|
|
171
|
+
mode: ThemeMode;
|
|
172
|
+
/**
|
|
173
|
+
* CSS generation strategy
|
|
174
|
+
* @description The strategy used to generate CSS
|
|
175
|
+
* @values 'runtime', 'buildtime', 'hybrid'
|
|
176
|
+
*/
|
|
177
|
+
strategy: Strategy;
|
|
178
|
+
/**
|
|
179
|
+
* Dark mode strategy
|
|
180
|
+
* @description The strategy used to handle dark mode
|
|
181
|
+
* @values 'class', 'media'
|
|
182
|
+
*/
|
|
183
|
+
darkModeStrategy: DarkModeStrategy;
|
|
184
|
+
/**
|
|
185
|
+
* Dark class
|
|
186
|
+
* @description The class added to the document root when dark mode is active
|
|
187
|
+
*/
|
|
188
|
+
darkClass: string;
|
|
189
|
+
}
|
|
190
|
+
export {};
|
|
10
191
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"color-utils.d.ts","sourceRoot":"","sources":["../../src/utils/color-utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAUzE;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAKjE;AAkCD,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAyChE;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAG1D;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAIlF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cookie-storage.d.ts","sourceRoot":"","sources":["../../src/utils/cookie-storage.ts"],"names":[],"mappings":"AAEA,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAUpD;AAED,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAK1D"}
|
|
@@ -0,0 +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;AAItG,MAAM,WAAW,UAAU;IACzB,2CAA2C;IAC3C,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,gFAAgF;IAChF,cAAc,CAAC,EAAE,CAAC,MAAM,WAAW,CAAC,EAAE,CAAA;IACtC,qFAAqF;IACrF,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;IACf,2EAA2E;IAC3E,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,sBAAsB;IACtB,SAAS,EAAE,MAAM,CAAA;CAClB;AAmCD,wBAAgB,WAAW,CACzB,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,UAKR,GACA,MAAM,CAwCR;AA0KD,eAAO,MAAM,MAAM,kBAAkB,CAAA;AAErC,wBAAgB,SAAS,CAAC,EAAE,oBAAS,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CA2BxD;AAED,wBAAgB,SAAS,CAAC,EAAE,SAAS,GAAG,IAAI,CAS3C"}
|
|
@@ -0,0 +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;AAIzC,wBAAgB,iBAAiB,IAAI,SAAS,GAAG,SAAS,CAOzD;AAED,wBAAgB,YAAY,CAAC,SAAS,CAAC,EAAE,SAAS,GAAG,SAAS,CAW7D;AAED,wBAAgB,kBAAkB,qBAMjC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-preset.d.ts","sourceRoot":"","sources":["../../src/utils/get-preset.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAElF,wBAAgB,cAAc,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,WAAW,GAAG,oBAAoB,GAAG,MAAM,IAAI,WAAW,CAEnH;AAED,wBAAsB,SAAS,CAAC,MAAM,CAAC,EAAE,eAAe,GAAG,WAAW,wBA0BrE"}
|
|
@@ -2,7 +2,10 @@ export * from './color-utils';
|
|
|
2
2
|
export * from './cookie-storage';
|
|
3
3
|
export * from './css-generator';
|
|
4
4
|
export * from './get-preset';
|
|
5
|
+
export * from './inject';
|
|
6
|
+
export * from './inject-theme-css';
|
|
5
7
|
export * from './no-transition';
|
|
6
8
|
export * from './preset-merger';
|
|
9
|
+
export * from './setup-theme';
|
|
7
10
|
export * from './update-document-class';
|
|
8
11
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,UAAU,CAAA;AACxB,cAAc,oBAAoB,CAAA;AAClC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,yBAAyB,CAAA"}
|
package/dist/utils/index.js
CHANGED
|
@@ -2,13 +2,17 @@ import { adjustColorLightness, formatHSL, generateColorScale, getContrastColor,
|
|
|
2
2
|
import { getCookie, setCookie } from "./cookie-storage.js";
|
|
3
3
|
import { CSS_ID, generateCSS, injectCSS, removeCSS } from "./css-generator.js";
|
|
4
4
|
import { getPreset, isPresetObject } from "./get-preset.js";
|
|
5
|
+
import { injectThemeState } from "./inject.js";
|
|
6
|
+
import { injectThemeCSS } from "./inject-theme-css.js";
|
|
5
7
|
import { noTransition } from "./no-transition.js";
|
|
6
8
|
import { deepMerge, mergePresets } from "./preset-merger.js";
|
|
9
|
+
import { defaultOptions, setupTheme } from "./setup-theme.js";
|
|
7
10
|
import { updateDocumentClass } from "./update-document-class.js";
|
|
8
11
|
export {
|
|
9
12
|
CSS_ID,
|
|
10
13
|
adjustColorLightness,
|
|
11
14
|
deepMerge,
|
|
15
|
+
defaultOptions,
|
|
12
16
|
formatHSL,
|
|
13
17
|
generateCSS,
|
|
14
18
|
generateColorScale,
|
|
@@ -16,11 +20,14 @@ export {
|
|
|
16
20
|
getCookie,
|
|
17
21
|
getPreset,
|
|
18
22
|
injectCSS,
|
|
23
|
+
injectThemeCSS,
|
|
24
|
+
injectThemeState,
|
|
19
25
|
isPresetObject,
|
|
20
26
|
mergePresets,
|
|
21
27
|
noTransition,
|
|
22
28
|
parseHSL,
|
|
23
29
|
removeCSS,
|
|
24
30
|
setCookie,
|
|
31
|
+
setupTheme,
|
|
25
32
|
updateDocumentClass
|
|
26
33
|
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { MazUiThemeOptions } from '../plugin';
|
|
2
|
+
import { ThemePreset } from '../types';
|
|
3
|
+
export declare function injectThemeCSS(finalPreset: ThemePreset, config: Required<Omit<MazUiThemeOptions, 'preset'>> & Pick<MazUiThemeOptions, 'preset'>): void;
|
|
4
|
+
//# sourceMappingURL=inject-theme-css.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inject-theme-css.d.ts","sourceRoot":"","sources":["../../src/utils/inject-theme-css.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAK3C,wBAAgB,cAAc,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,QAuC/I"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { nextTick } from "vue";
|
|
2
|
+
import { generateCSS, injectCSS, CSS_ID } from "./css-generator.js";
|
|
3
|
+
function injectThemeCSS(finalPreset, config) {
|
|
4
|
+
if (typeof document > "u")
|
|
5
|
+
return;
|
|
6
|
+
const cssOptions = {
|
|
7
|
+
mode: config.mode,
|
|
8
|
+
darkSelectorStrategy: config.darkModeStrategy,
|
|
9
|
+
darkClass: config.darkClass
|
|
10
|
+
};
|
|
11
|
+
if (config.injectCriticalCSS) {
|
|
12
|
+
const criticalCSS = generateCSS(finalPreset, {
|
|
13
|
+
...cssOptions,
|
|
14
|
+
onlyCritical: !0
|
|
15
|
+
});
|
|
16
|
+
injectCSS(CSS_ID, criticalCSS);
|
|
17
|
+
}
|
|
18
|
+
if (!config.injectFullCSS)
|
|
19
|
+
return;
|
|
20
|
+
const fullCSS = generateCSS(finalPreset, cssOptions);
|
|
21
|
+
config.strategy === "runtime" ? injectCSS(CSS_ID, fullCSS) : config.strategy === "hybrid" && (typeof requestIdleCallback < "u" ? requestIdleCallback(() => {
|
|
22
|
+
injectCSS(CSS_ID, fullCSS);
|
|
23
|
+
}, { timeout: 100 }) : nextTick(() => {
|
|
24
|
+
injectCSS(CSS_ID, fullCSS);
|
|
25
|
+
}));
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
injectThemeCSS
|
|
29
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inject.d.ts","sourceRoot":"","sources":["../../src/utils/inject.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAE1C,wBAAgB,gBAAgB,CAAC,EAC/B,GAAG,EACH,UAAU,GACX,EAAE;IACD,GAAG,CAAC,EAAE,GAAG,CAAA;IACT,UAAU,EAAE,GAAG,CAAC,UAAU,CAAC,CAAA;CAC5B,QAOA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
function injectThemeState({
|
|
2
|
+
app,
|
|
3
|
+
themeState
|
|
4
|
+
}) {
|
|
5
|
+
if (!app)
|
|
6
|
+
throw new Error("[@maz-ui/themes](injectThemeState) No app provided");
|
|
7
|
+
app.provide("mazThemeState", themeState), app.config.globalProperties.$mazThemeState = themeState;
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
injectThemeState
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"no-transition.d.ts","sourceRoot":"","sources":["../../src/utils/no-transition.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,EAAE,EAAE,MAAM,IAAI,QAmB1C"}
|