@maz-ui/nuxt 5.0.0-beta.5 → 5.0.0-beta.51

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
@@ -182,6 +182,13 @@ export default defineNuxtConfig({
182
182
  autoImport: true, // Auto-import all components globally
183
183
  },
184
184
 
185
+ // Global component defaults (instance prop > defaults[Component] > defaults.global > library default)
186
+ defaults: {
187
+ global: { roundedSize: 'lg' }, // cross-cutting (roundedSize, size)
188
+ MazBtn: { roundedSize: 'full' }, // per-component, wins over global
189
+ MazCard: { bordered: false, elevation: true },
190
+ },
191
+
185
192
  // Composables (customize what you need)
186
193
  composables: {
187
194
  useTheme: true,
@@ -264,7 +271,7 @@ This module is built specifically for Nuxt with perfect SSR and SSG support:
264
271
 
265
272
  ## Learn More
266
273
 
267
- - **[Full Documentation](https://maz-ui.com/guide/nuxt)**
274
+ - **[Full Documentation](https://maz-ui.com/ecosystem/nuxt)**
268
275
  - **[Report Issues](https://github.com/LouisMazel/maz-ui/issues)**
269
276
  - **[Discussions](https://github.com/LouisMazel/maz-ui/discussions)**
270
277
 
package/dist/module.d.mts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
  import { MazUiThemeOptions, ThemePreset, ThemePresetName } from '@maz-ui/themes';
3
3
  import { MazUiTranslationsOptions } from '@maz-ui/translations';
4
+ import { MazUiDefaultsOptions } from 'maz-ui/composables/useGlobalConfig';
4
5
  import { VLazyImgOptions, VFullscreenImgOptions, VTooltipOptions } from 'maz-ui/directives';
5
6
  import { AosOptions, DialogOptions, ToastOptions } from 'maz-ui/plugins';
6
7
 
@@ -55,6 +56,31 @@ interface MazUiNuxtOptions {
55
56
  * }
56
57
  */
57
58
  translations?: MazUiTranslationsOptions;
59
+ /**
60
+ * Global default prop values for components
61
+ * @description Set default prop values once for every component, with the priority:
62
+ * instance prop > `defaults[Component]` > `defaults.global` > library default.
63
+ * A global default never wins over a prop set on the component instance.
64
+ * @default {}
65
+ * @example {
66
+ * global: { roundedSize: 'lg' },
67
+ * MazBtn: { roundedSize: 'full' },
68
+ * MazCard: { bordered: false, elevation: true },
69
+ * }
70
+ */
71
+ defaults?: MazUiDefaultsOptions;
72
+ /**
73
+ * Source of the country flags of `MazSelectCountry` and `MazInputPhoneNumber`
74
+ * @description
75
+ * - `'cdn'`: images of the flagcdn.com CDN
76
+ * - `'local'`: square flags of `@maz-ui/icons`, one chunk per flag, loaded only when visible, without any request to a third party (works offline)
77
+ * - a URL template of your own files, with `{code}` (lowercase) or `{CODE}` (uppercase): `'/flags/{code}.svg'`
78
+ *
79
+ * Sets the default of the `flag-src` prop (`defaults.global.flagSrc`): a `flag-src` set on a component wins.
80
+ * Nothing is added to the build of the app unless this option is `'local'`.
81
+ * @default 'cdn'
82
+ */
83
+ flags?: 'cdn' | 'local' | (string & {});
58
84
  /**
59
85
  * CSS and styles configuration
60
86
  */
@@ -223,6 +249,12 @@ interface MazUiNuxtOptions {
223
249
  * @default true
224
250
  */
225
251
  useSwipe?: boolean;
252
+ /**
253
+ * Enable auto-import of usePullToRefresh composable
254
+ * @description Headless pull to refresh gesture on a scroll container
255
+ * @default true
256
+ */
257
+ usePullToRefresh?: boolean;
226
258
  };
227
259
  /**
228
260
  * Vue directives configuration
package/dist/module.json CHANGED
@@ -2,11 +2,11 @@
2
2
  "name": "maz-ui",
3
3
  "configKey": "mazUi",
4
4
  "compatibility": {
5
- "nuxt": ">=3.0.0"
5
+ "nuxt": ">=3.4.0 <5.0.0"
6
6
  },
7
- "version": "5.0.0-beta.5",
7
+ "version": "5.0.0-beta.51",
8
8
  "builder": {
9
- "@nuxt/module-builder": "1.0.2",
10
- "unbuild": "3.6.1"
9
+ "@nuxt/module-builder": "1.0.3",
10
+ "unbuild": "unknown"
11
11
  }
12
12
  }
package/dist/module.mjs CHANGED
@@ -25,6 +25,7 @@ const COMPONENT_NAMES = {
25
25
  MazChecklist: true,
26
26
  MazContainer: true,
27
27
  MazCircularProgressBar: true,
28
+ MazCodeHighlight: true,
28
29
  MazDialog: true,
29
30
  MazDialogConfirm: true,
30
31
  MazDrawer: true,
@@ -43,6 +44,7 @@ const COMPONENT_NAMES = {
43
44
  MazLazyImg: true,
44
45
  MazLink: true,
45
46
  MazLoadingBar: true,
47
+ MazMarkdownEditor: true,
46
48
  MazPagination: true,
47
49
  MazDatePicker: true,
48
50
  MazPullToRefresh: true,
@@ -57,6 +59,17 @@ const COMPONENT_NAMES = {
57
59
  MazSpinner: true,
58
60
  MazStepper: true,
59
61
  MazSwitch: true,
62
+ MazSidebar: true,
63
+ MazSidebarMenu: true,
64
+ MazSidebarMenuItem: true,
65
+ MazSidebarMenuSub: true,
66
+ MazSidebarFooter: true,
67
+ MazSidebarHeader: true,
68
+ MazSidebarContent: true,
69
+ MazSidebarGroup: true,
70
+ MazSidebarMenuButton: true,
71
+ MazSidebarSeparator: true,
72
+ MazSidebarTrigger: true,
60
73
  MazTable: true,
61
74
  MazTableCell: true,
62
75
  MazTableRow: true,
@@ -69,6 +82,7 @@ const COMPONENT_NAMES = {
69
82
  MazTimeline: true,
70
83
  MazTextarea: true,
71
84
  MazUiProvider: true,
85
+ MazWindowMockup: true,
72
86
  MazPopover: true
73
87
  };
74
88
  const _dirname = dirname(fileURLToPath(import.meta.url));
@@ -78,6 +92,7 @@ const pluginComposables = {
78
92
  };
79
93
  const mazUiComposables = {
80
94
  useIdleTimeout: true,
95
+ useDrag: true,
81
96
  useReadingTime: true,
82
97
  useFormField: true,
83
98
  useWindowSize: true,
@@ -93,7 +108,9 @@ const mazUiComposables = {
93
108
  useInstanceUniqId: true,
94
109
  useMountComponent: true,
95
110
  useSwipe: true,
96
- useMutationObserver: true
111
+ usePullToRefresh: true,
112
+ useMutationObserver: true,
113
+ useSidebar: true
97
114
  };
98
115
  const defaults = {
99
116
  general: {
@@ -116,6 +133,8 @@ const defaults = {
116
133
  fallbackLocale: "en",
117
134
  preloadFallback: true
118
135
  },
136
+ defaults: {},
137
+ flags: "cdn",
119
138
  components: {
120
139
  autoImport: true
121
140
  },
@@ -153,7 +172,7 @@ const module$1 = defineNuxtModule({
153
172
  name: "maz-ui",
154
173
  configKey: "mazUi",
155
174
  compatibility: {
156
- nuxt: ">=3.0.0"
175
+ nuxt: ">=3.4.0 <5.0.0"
157
176
  }
158
177
  },
159
178
  defaults,
@@ -170,9 +189,28 @@ const module$1 = defineNuxtModule({
170
189
  if (moduleOptions.css.injectCss) {
171
190
  nuxt.options.css.unshift("maz-ui/style.css");
172
191
  }
192
+ nuxt.options.postcss ??= { plugins: {}, order: [] };
193
+ nuxt.options.postcss.plugins ??= {};
194
+ const postcssPlugins = nuxt.options.postcss.plugins;
195
+ if (postcssPlugins.cssnano !== false) {
196
+ const current = typeof postcssPlugins.cssnano === "object" && postcssPlugins.cssnano !== null ? postcssPlugins.cssnano : {};
197
+ postcssPlugins.cssnano = { ...current, preset: ["default", { calc: false }] };
198
+ }
173
199
  addPlugin(resolve(_dirname, "./runtime/plugins/theme"));
174
200
  addPlugin(resolve(_dirname, "./runtime/plugins/translations"));
175
201
  addPlugin(resolve(_dirname, "./runtime/plugins/maz-link-component"));
202
+ const flags = moduleOptions.flags;
203
+ if (flags && flags !== "cdn" && flags !== "local") {
204
+ moduleOptions.defaults = {
205
+ ...moduleOptions.defaults,
206
+ global: { flagSrc: flags, ...moduleOptions.defaults.global }
207
+ };
208
+ }
209
+ if (flags === "local") {
210
+ addPlugin(resolve(_dirname, "./runtime/plugins/local-flags"));
211
+ } else if (Object.keys(moduleOptions.defaults).length > 0) {
212
+ addPlugin(resolve(_dirname, "./runtime/plugins/defaults"));
213
+ }
176
214
  if (moduleOptions.components.autoImport) {
177
215
  for (const name of Object.keys(COMPONENT_NAMES)) {
178
216
  addComponent({
@@ -0,0 +1,2 @@
1
+ declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,8 @@
1
+ import { GLOBAL_CONFIG_INJECTION_KEY } from "maz-ui/composables/useGlobalConfig";
2
+ import { defineNuxtPlugin } from "nuxt/app";
3
+ export default defineNuxtPlugin(({ vueApp, $config }) => {
4
+ const defaults = $config.public.mazUi?.defaults;
5
+ if (defaults && Object.keys(defaults).length > 0) {
6
+ vueApp.provide(GLOBAL_CONFIG_INJECTION_KEY, defaults);
7
+ }
8
+ });
@@ -0,0 +1,2 @@
1
+ declare const _default: import("nuxt/app").Plugin<Record<string, unknown>> & import("nuxt/app").ObjectPlugin<Record<string, unknown>>;
2
+ export default _default;
@@ -0,0 +1,13 @@
1
+ import { GLOBAL_CONFIG_INJECTION_KEY } from "maz-ui/composables/useGlobalConfig";
2
+ import { defineNuxtPlugin } from "nuxt/app";
3
+ async function loadCountryFlag(code) {
4
+ const { loadCountryFlag: loadCountryFlag2 } = await import("maz-ui/country-flags");
5
+ return loadCountryFlag2(code);
6
+ }
7
+ export default defineNuxtPlugin(({ vueApp, $config }) => {
8
+ const defaults = $config.public.mazUi?.defaults ?? {};
9
+ vueApp.provide(GLOBAL_CONFIG_INJECTION_KEY, {
10
+ ...defaults,
11
+ global: { flagSrc: loadCountryFlag, ...defaults.global }
12
+ });
13
+ });
@@ -1,5 +1,5 @@
1
1
  import { MazUiTheme } from "@maz-ui/themes/plugin";
2
- import { CSS_ID, generateCSS, getPreset, mergePresets } from "@maz-ui/themes/utils";
2
+ import { CSS_ID, generateCSS, getPreset, mergePresets, resolveColorSchemeContent } from "@maz-ui/themes/utils";
3
3
  import { getSystemColorMode } from "@maz-ui/themes/utils/get-color-mode";
4
4
  import { defineNuxtPlugin, useCookie, useHead, useRequestHeaders } from "nuxt/app";
5
5
  function getSavedColorMode() {
@@ -17,11 +17,11 @@ function getSavedResolvedColorMode() {
17
17
  return void 0;
18
18
  }
19
19
  function getInitialColorMode() {
20
- const resolvedColorMode = getSavedResolvedColorMode();
21
- if (resolvedColorMode) {
22
- return resolvedColorMode;
23
- }
24
20
  if (import.meta.server) {
21
+ const resolvedColorMode = getSavedResolvedColorMode();
22
+ if (resolvedColorMode) {
23
+ return resolvedColorMode;
24
+ }
25
25
  const headers = useRequestHeaders();
26
26
  if (headers["sec-ch-prefers-color-scheme"] === "dark") {
27
27
  return "dark";
@@ -30,13 +30,9 @@ function getInitialColorMode() {
30
30
  if (userAgent?.includes("dark")) {
31
31
  return "dark";
32
32
  }
33
- } else {
34
- const systemColorMode = getSystemColorMode();
35
- if (systemColorMode === "dark") {
36
- return "dark";
37
- }
33
+ return "auto";
38
34
  }
39
- return "auto";
35
+ return getSystemColorMode();
40
36
  }
41
37
  function getColorModeBlockingScript(config) {
42
38
  const darkClass = config.darkClass;
@@ -51,7 +47,7 @@ function injectThemeCSS(config) {
51
47
  darkSelectorStrategy: config.darkModeStrategy,
52
48
  prefix: "maz",
53
49
  darkClass: config.darkClass,
54
- scaleColorVariables: true
50
+ lightClass: config.lightClass
55
51
  });
56
52
  useHead({
57
53
  style: [{
@@ -60,26 +56,39 @@ function injectThemeCSS(config) {
60
56
  }]
61
57
  });
62
58
  }
59
+ function parseSavedPreset(raw) {
60
+ if (!raw) {
61
+ return null;
62
+ }
63
+ const separatorIndex = raw.indexOf(":");
64
+ if (separatorIndex === -1) {
65
+ return null;
66
+ }
67
+ const base = raw.slice(0, separatorIndex);
68
+ const active = raw.slice(separatorIndex + 1);
69
+ return base && active ? { base, active } : null;
70
+ }
63
71
  async function resolvePreset(options, persistPreset) {
64
- const presetCookie = useCookie("maz-preset");
65
- const savedName = persistPreset ? presetCookie.value : void 0;
66
72
  const presetObject = options?.preset && typeof options.preset !== "string" ? options.preset : void 0;
67
- if (savedName && presetObject && savedName === presetObject.name) {
68
- return presetObject;
73
+ const saved = persistPreset ? parseSavedPreset(useCookie("maz-preset").value) : null;
74
+ const basePreset = presetObject ?? await getPreset(options?.preset);
75
+ const baseName = basePreset.name;
76
+ if (!persistPreset) {
77
+ return { preset: basePreset, baseName };
69
78
  }
70
- if (savedName) {
79
+ if (saved && saved.base === baseName && saved.active !== baseName) {
71
80
  try {
72
- return await getPreset(savedName);
81
+ return { preset: await getPreset(saved.active), baseName };
73
82
  } catch {
74
- presetCookie.value = null;
75
83
  }
76
84
  }
77
- return getPreset(options?.preset);
85
+ return { preset: basePreset, baseName };
78
86
  }
79
87
  export default defineNuxtPlugin(async ({ vueApp, $config }) => {
80
88
  const options = $config.public.mazUi.theme;
81
89
  const persistPreset = options?.persistPreset !== false;
82
- let preset = await resolvePreset(options, persistPreset);
90
+ const resolved = await resolvePreset(options, persistPreset);
91
+ let preset = resolved.preset;
83
92
  if (options?.overrides) {
84
93
  preset = mergePresets(preset, options.overrides);
85
94
  }
@@ -89,13 +98,15 @@ export default defineNuxtPlugin(async ({ vueApp, $config }) => {
89
98
  sameSite: "lax",
90
99
  path: "/"
91
100
  });
92
- if (presetCookie.value !== preset.name) {
93
- presetCookie.value = preset.name;
101
+ const value = `${resolved.baseName}:${preset.name}`;
102
+ if (presetCookie.value !== value) {
103
+ presetCookie.value = value;
94
104
  }
95
105
  }
96
106
  const config = {
97
107
  strategy: "runtime",
98
108
  darkClass: "dark",
109
+ lightClass: "light",
99
110
  darkModeStrategy: "class",
100
111
  mode: "both",
101
112
  overrides: {},
@@ -105,15 +116,22 @@ export default defineNuxtPlugin(async ({ vueApp, $config }) => {
105
116
  preset
106
117
  };
107
118
  const isDark = config.colorMode === "auto" && config.mode === "both" ? getInitialColorMode() === "dark" : config.colorMode === "dark" || config.mode === "dark";
108
- if (isDark && config.darkModeStrategy === "class") {
109
- useHead({
110
- htmlAttrs: {
111
- class: config.darkClass
112
- }
113
- });
114
- }
115
119
  if (import.meta.server) {
120
+ if (isDark && config.darkModeStrategy === "class") {
121
+ useHead({
122
+ htmlAttrs: {
123
+ class: config.darkClass
124
+ }
125
+ });
126
+ }
116
127
  injectThemeCSS(config);
128
+ useHead({
129
+ meta: [{
130
+ name: "color-scheme",
131
+ content: resolveColorSchemeContent(config.mode, config.colorMode),
132
+ id: "maz-color-scheme"
133
+ }]
134
+ });
117
135
  if (config.colorMode === "auto" && config.mode === "both" && config.darkModeStrategy === "class") {
118
136
  useHead({
119
137
  script: [{ innerHTML: getColorModeBlockingScript(config), tagPosition: "head", id: "maz-color-mode-blocking" }],
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@maz-ui/nuxt",
3
3
  "type": "module",
4
- "version": "5.0.0-beta.5",
4
+ "version": "5.0.0-beta.51",
5
5
  "description": "Nuxt module for Maz-UI",
6
6
  "author": "Louis Mazel <me@loicmazuel.com>",
7
7
  "license": "MIT",
8
- "homepage": "https://maz-ui.com/guide/nuxt",
8
+ "homepage": "https://maz-ui.com/ecosystem/nuxt",
9
9
  "repository": {
10
10
  "type": "git",
11
11
  "url": "git+https://github.com/LouisMazel/maz-ui.git"
@@ -33,7 +33,8 @@
33
33
  "exports": {
34
34
  ".": {
35
35
  "types": "./dist/types.d.mts",
36
- "import": "./dist/module.mjs"
36
+ "import": "./dist/module.mjs",
37
+ "default": "./dist/module.mjs"
37
38
  }
38
39
  },
39
40
  "main": "./dist/module.mjs",
@@ -47,28 +48,28 @@
47
48
  "nuxt": ">=3.4.0 <5.0.0"
48
49
  },
49
50
  "dependencies": {
51
+ "@maz-ui/themes": "5.0.0-beta.46",
52
+ "@maz-ui/translations": "5.0.0-beta.50",
53
+ "@maz-ui/utils": "5.0.0-beta.46",
50
54
  "@nuxt/devtools-kit": "^3.2.3",
51
- "@nuxt/kit": "^4.4.4",
55
+ "@nuxt/kit": "^4.5.2",
52
56
  "defu": "^6.1.7",
53
- "@maz-ui/themes": "5.0.0-beta.5",
54
- "@maz-ui/utils": "5.0.0-beta.5",
55
- "@maz-ui/translations": "5.0.0-beta.5",
56
- "maz-ui": "5.0.0-beta.5"
57
+ "maz-ui": "5.0.0-beta.51"
57
58
  },
58
59
  "devDependencies": {
60
+ "@maz-ui/eslint-config": "5.0.0-beta.47",
59
61
  "@nuxt/devtools": "^3.2.3",
60
- "@nuxt/module-builder": "^1.0.2",
61
- "@nuxt/schema": "^4.4.4",
62
- "@nuxt/test-utils": "^4.0.3",
63
- "nuxt": "^4.4.4"
62
+ "@nuxt/module-builder": "^1.0.3",
63
+ "@nuxt/schema": "^4.5.2",
64
+ "@nuxt/test-utils": "^4.3.3",
65
+ "nuxt": "^4.5.2"
64
66
  },
65
67
  "lint-staged": {
66
68
  "*.{js,ts,mjs,mts,cjs,md,yml,json}": "cross-env NODE_ENV=production eslint --fix"
67
69
  },
68
70
  "scripts": {
69
- "codegen": "nx dev",
70
- "build": "pnpm dev && nuxt-module-build build",
71
- "dev": "nuxt-module-build build --stub && nuxt-module-build prepare",
71
+ "build": "pnpm dev && pnpm prepack",
72
+ "dev": "pnpm prepack --stub && nuxt-module-build prepare",
72
73
  "test:unit": "vitest run",
73
74
  "test:unit:watch": "vitest watch",
74
75
  "test:unit:coverage": "vitest run --coverage",