@maz-ui/nuxt 4.9.3 → 5.0.0-canary.ef64a02.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/README.md CHANGED
@@ -167,7 +167,7 @@ export default defineNuxtConfig({
167
167
  // Theme System
168
168
  theme: {
169
169
  preset: 'ocean', // Choose: 'mazUi', 'ocean', 'pristine', 'obsidian'
170
- strategy: 'hybrid', // 'runtime' | 'buildtime' | 'hybrid'
170
+ strategy: 'runtime', // 'runtime' | 'buildtime'
171
171
  darkModeStrategy: 'class', // 'class' | 'media' | 'auto'
172
172
  },
173
173
 
package/dist/module.d.mts CHANGED
@@ -4,14 +4,6 @@ import { MazUiTranslationsOptions } from '@maz-ui/translations';
4
4
  import { VLazyImgOptions, VFullscreenImgOptions, VTooltipOptions } from 'maz-ui/directives';
5
5
  import { AosOptions, DialogOptions, ToastOptions } from 'maz-ui/plugins';
6
6
 
7
- interface MazUiNuxtThemeOptions extends MazUiThemeOptions {
8
- /**
9
- * Inject full CSS on server-side
10
- * @description Inject full CSS on server-side to prevent FOUC on client-side
11
- * @default true
12
- */
13
- injectAllCSSOnServer?: boolean;
14
- }
15
7
  interface MazUiNuxtOptions {
16
8
  /**
17
9
  * General configuration
@@ -43,13 +35,13 @@ interface MazUiNuxtOptions {
43
35
  * @description If false, the theme system will be completely disabled
44
36
  * @default {
45
37
  * preset: 'maz-ui',
46
- * strategy: 'hybrid',
38
+ * strategy: 'runtime',
47
39
  * darkModeStrategy: 'class',
48
40
  * prefix: 'maz',
49
41
  * colorMode: 'auto',
50
42
  * }
51
43
  */
52
- theme?: Omit<MazUiNuxtThemeOptions, 'preset'> & {
44
+ theme?: Omit<MazUiThemeOptions, 'preset'> & {
53
45
  /**
54
46
  * @default 'maz-ui'
55
47
  */
@@ -72,7 +64,7 @@ interface MazUiNuxtOptions {
72
64
  * @description Automatically injects Maz-UI base styles
73
65
  * @default true
74
66
  */
75
- injectMainCss?: boolean;
67
+ injectCss?: boolean;
76
68
  };
77
69
  /**
78
70
  * Components configuration
@@ -269,7 +261,7 @@ interface MazUiNuxtOptions {
269
261
  };
270
262
  }
271
263
 
272
- declare module '@nuxt/schema' {
264
+ declare module 'nuxt/schema' {
273
265
  interface NuxtConfig {
274
266
  mazUi?: MazUiNuxtOptions;
275
267
  }
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.0.0"
6
6
  },
7
- "version": "4.9.3",
7
+ "version": "5.0.0-canary.ef64a02.0",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -102,11 +102,11 @@ const defaults = {
102
102
  devtools: true
103
103
  },
104
104
  css: {
105
- injectMainCss: true
105
+ injectCss: true
106
106
  },
107
107
  theme: {
108
108
  preset: "maz-ui",
109
- strategy: "hybrid",
109
+ strategy: "runtime",
110
110
  darkModeStrategy: "class",
111
111
  colorMode: "auto",
112
112
  mode: "both"
@@ -167,8 +167,8 @@ const module$1 = defineNuxtModule({
167
167
  defaults
168
168
  );
169
169
  nuxt.options.runtimeConfig.public.mazUi = moduleOptions;
170
- if (moduleOptions.css.injectMainCss) {
171
- nuxt.options.css.unshift("maz-ui/dist/css/main.css");
170
+ if (moduleOptions.css.injectCss) {
171
+ nuxt.options.css.unshift("maz-ui/style.css");
172
172
  }
173
173
  addPlugin(resolve(_dirname, "./runtime/plugins/theme"));
174
174
  addPlugin(resolve(_dirname, "./runtime/plugins/translations"));
@@ -191,7 +191,7 @@ const module$1 = defineNuxtModule({
191
191
  });
192
192
  const injectAosCSS = typeof moduleOptions.plugins.aos === "object" && typeof moduleOptions.plugins.aos.injectCss === "boolean" ? moduleOptions.plugins.aos.injectCss : true;
193
193
  if (injectAosCSS) {
194
- nuxt.options.css = ["maz-ui/aos-styles", ...nuxt.options.css];
194
+ nuxt.options.css = ["maz-ui/aos.css", ...nuxt.options.css];
195
195
  }
196
196
  }
197
197
  if (moduleOptions.plugins.toast) {
@@ -44,43 +44,61 @@ function getColorModeBlockingScript(config) {
44
44
  return `(function(){try{var d=document.documentElement,m='${config.mode}',dc='${darkClass}';if(m==='light')return;var c=(document.cookie.match(/maz-color-mode=([^;]+)/)||[])[1];if(c==='light')return;if(c==='dark'||m==='dark'){d.classList.add(dc);return}var r=(document.cookie.match(/maz-resolved-color-mode=([^;]+)/)||[])[1];if(r==='light')return;if(r==='dark'){d.classList.add(dc);return}if(window.matchMedia&&window.matchMedia('(prefers-color-scheme:dark)').matches){d.classList.add(dc);document.cookie='maz-resolved-color-mode=dark;path=/;max-age=${cookieMaxAge};SameSite=Lax'}else{document.cookie='maz-resolved-color-mode=light;path=/;max-age=${cookieMaxAge};SameSite=Lax'}}catch(e){}})()`;
45
45
  }
46
46
  function injectThemeCSS(config) {
47
- const cssOptions = {
47
+ if (config.strategy === "buildtime")
48
+ return;
49
+ const css = generateCSS(config.preset, {
48
50
  mode: config.mode,
49
- darkSelectorStrategy: config.darkModeStrategy ?? "class",
51
+ darkSelectorStrategy: config.darkModeStrategy,
50
52
  prefix: "maz",
51
- darkClass: config.darkClass ?? "dark"
52
- };
53
- if (config.injectCriticalCSS && !config.injectAllCSSOnServer) {
54
- const criticalCSS = generateCSS(config.preset, {
55
- ...cssOptions,
56
- onlyCritical: true
57
- });
58
- useHead({
59
- style: [{ innerHTML: criticalCSS, id: CSS_ID }]
60
- });
53
+ darkClass: config.darkClass
54
+ });
55
+ useHead({
56
+ style: [{
57
+ innerHTML: css,
58
+ id: CSS_ID
59
+ }]
60
+ });
61
+ }
62
+ async function resolvePreset(options, persistPreset) {
63
+ const presetCookie = useCookie("maz-preset");
64
+ const savedName = persistPreset ? presetCookie.value : void 0;
65
+ const presetObject = options?.preset && typeof options.preset !== "string" ? options.preset : void 0;
66
+ if (savedName && presetObject && savedName === presetObject.name) {
67
+ return presetObject;
61
68
  }
62
- if (config.injectAllCSSOnServer) {
63
- const fullCSS = generateCSS(config.preset, cssOptions);
64
- useHead({
65
- style: [{ innerHTML: fullCSS, id: CSS_ID }]
66
- });
69
+ if (savedName) {
70
+ try {
71
+ return await getPreset(savedName);
72
+ } catch {
73
+ presetCookie.value = null;
74
+ }
67
75
  }
76
+ return getPreset(options?.preset);
68
77
  }
69
78
  export default defineNuxtPlugin(async ({ vueApp, $config }) => {
70
79
  const options = $config.public.mazUi.theme;
71
- let preset = await getPreset(options?.preset);
80
+ const persistPreset = options?.persistPreset !== false;
81
+ let preset = await resolvePreset(options, persistPreset);
72
82
  if (options?.overrides) {
73
83
  preset = mergePresets(preset, options.overrides);
74
84
  }
85
+ if (persistPreset) {
86
+ const presetCookie = useCookie("maz-preset", {
87
+ maxAge: 60 * 60 * 24 * 365,
88
+ sameSite: "lax",
89
+ path: "/"
90
+ });
91
+ if (presetCookie.value !== preset.name) {
92
+ presetCookie.value = preset.name;
93
+ }
94
+ }
75
95
  const config = {
76
- strategy: "hybrid",
96
+ strategy: "runtime",
77
97
  darkClass: "dark",
78
98
  darkModeStrategy: "class",
79
99
  mode: "both",
80
- injectAllCSSOnServer: false,
81
- injectCriticalCSS: true,
82
- injectFullCSS: true,
83
100
  overrides: {},
101
+ persistPreset: true,
84
102
  ...options,
85
103
  colorMode: getSavedColorMode() ?? options?.colorMode ?? "auto",
86
104
  preset
@@ -107,7 +125,5 @@ export default defineNuxtPlugin(async ({ vueApp, $config }) => {
107
125
  colorMode: getSavedColorMode() ?? config.colorMode,
108
126
  // @ts-expect-error _isDark is a private property
109
127
  _isDark: isDark
110
- // injectFullCSS: !config.injectAllCSSOnServer || shouldInjectCSSOnClient,
111
- // injectCriticalCSS: shouldInjectCSSOnClient,
112
128
  });
113
129
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maz-ui/nuxt",
3
3
  "type": "module",
4
- "version": "4.9.3",
4
+ "version": "5.0.0-canary.ef64a02.0",
5
5
  "description": "Nuxt module for Maz-UI",
6
6
  "author": "Louis Mazel <me@loicmazuel.com>",
7
7
  "license": "MIT",
@@ -48,24 +48,25 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@nuxt/devtools-kit": "^3.2.3",
51
- "@nuxt/kit": "^4.4.2",
51
+ "@nuxt/kit": "^4.4.4",
52
52
  "defu": "^6.1.7",
53
- "@maz-ui/themes": "4.9.2",
54
- "@maz-ui/utils": "4.7.6",
55
- "maz-ui": "4.9.3",
56
- "@maz-ui/translations": "4.9.2"
53
+ "@maz-ui/utils": "5.0.0-canary.ef64a02.0",
54
+ "@maz-ui/themes": "5.0.0-canary.ef64a02.0",
55
+ "maz-ui": "5.0.0-canary.ef64a02.0",
56
+ "@maz-ui/translations": "5.0.0-canary.ef64a02.0"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@nuxt/devtools": "^3.2.3",
60
60
  "@nuxt/module-builder": "^1.0.2",
61
- "@nuxt/schema": "^4.4.2",
62
- "@nuxt/test-utils": "^4.0.2",
63
- "nuxt": "^4.4.2"
61
+ "@nuxt/schema": "^4.4.4",
62
+ "@nuxt/test-utils": "^4.0.3",
63
+ "nuxt": "^4.4.4"
64
64
  },
65
65
  "lint-staged": {
66
66
  "*.{js,ts,mjs,mts,cjs,md,yml,json}": "cross-env NODE_ENV=production eslint --fix"
67
67
  },
68
68
  "scripts": {
69
+ "codegen": "nx dev",
69
70
  "build": "pnpm dev && nuxt-module-build build",
70
71
  "dev": "nuxt-module-build build --stub && nuxt-module-build prepare",
71
72
  "test:unit": "vitest run",