@maz-ui/nuxt 4.0.0-beta.6 → 4.0.0-beta.8

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/module.d.mts CHANGED
@@ -272,7 +272,7 @@ declare module '@nuxt/schema' {
272
272
  mazUi: MazUiNuxtOptions;
273
273
  }
274
274
  interface PublicRuntimeConfig {
275
- mazUi: MazUiNuxtOptions;
275
+ mazUi: Required<MazUiNuxtOptions>;
276
276
  }
277
277
  }
278
278
  declare const _default: _nuxt_schema.NuxtModule<MazUiNuxtOptions, MazUiNuxtOptions, false>;
package/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=3.0.0"
6
6
  },
7
- "version": "4.0.0-beta.6",
7
+ "version": "4.0.0-beta.8",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.1",
10
10
  "unbuild": "3.5.0"
package/dist/module.mjs CHANGED
@@ -22,7 +22,7 @@ const COMPONENT_NAMES = {
22
22
  MazChecklist: true,
23
23
  MazCircularProgressBar: true,
24
24
  MazDialog: true,
25
- MazDialogPromise: true,
25
+ MazDialogConfirm: true,
26
26
  MazDrawer: true,
27
27
  MazDropdown: true,
28
28
  MazDropzone: true,
@@ -63,6 +63,27 @@ const COMPONENT_NAMES = {
63
63
  MazPopover: true
64
64
  };
65
65
  const _dirname = dirname(fileURLToPath(import.meta.url));
66
+ const pluginComposables = {
67
+ useTheme: true,
68
+ useTranslations: true
69
+ };
70
+ const mazUiComposables = {
71
+ useIdleTimeout: true,
72
+ useReadingTime: true,
73
+ useFormField: true,
74
+ useWindowSize: true,
75
+ useBreakpoints: true,
76
+ useUserVisibility: true,
77
+ useStringMatching: true,
78
+ useTimer: true,
79
+ useFormValidator: true,
80
+ useDisplayNames: true,
81
+ useFreezeValue: true,
82
+ useInjectStrict: true,
83
+ useInstanceUniqId: true,
84
+ useMountComponent: true,
85
+ useSwipe: true
86
+ };
66
87
  const defaults = {
67
88
  general: {
68
89
  autoImportPrefix: "",
@@ -79,7 +100,9 @@ const defaults = {
79
100
  colorMode: "auto"
80
101
  },
81
102
  translations: {
82
- locale: "en"
103
+ locale: "en",
104
+ fallbackLocale: "en",
105
+ preloadFallback: true
83
106
  },
84
107
  components: {
85
108
  autoImport: true
@@ -91,23 +114,8 @@ const defaults = {
91
114
  wait: false
92
115
  },
93
116
  composables: {
94
- useTheme: true,
95
- useIdleTimeout: true,
96
- useReadingTime: true,
97
- useTranslations: true,
98
- useFormField: true,
99
- useWindowSize: true,
100
- useBreakpoints: true,
101
- useUserVisibility: true,
102
- useStringMatching: true,
103
- useTimer: true,
104
- useFormValidator: true,
105
- useDisplayNames: true,
106
- useFreezeValue: true,
107
- useInjectStrict: true,
108
- useInstanceUniqId: true,
109
- useMountComponent: true,
110
- useSwipe: true
117
+ ...pluginComposables,
118
+ ...mazUiComposables
111
119
  },
112
120
  directives: {
113
121
  vZoomImg: false,
@@ -117,16 +125,15 @@ const defaults = {
117
125
  vTooltip: false
118
126
  }
119
127
  };
120
- function addComposableImport({
128
+ function addMazUiComposableImport({
121
129
  name,
122
130
  from,
123
- prefix = "",
124
- typed = true
131
+ prefix = ""
125
132
  }) {
126
133
  addImports({
127
134
  from,
128
135
  name,
129
- typeFrom: typed ? `maz-ui/dist/types/composables/${name}.d.ts` : void 0,
136
+ typeFrom: "maz-ui/dist/types/composables/index.d.ts",
130
137
  as: `use${capitalize(prefix)}${name.replace("use", "")}`
131
138
  });
132
139
  }
@@ -142,8 +149,16 @@ const module = defineNuxtModule({
142
149
  /* eslint-disable complexity, sonarjs/cognitive-complexity */
143
150
  setup(options, nuxt) {
144
151
  const { resolve } = createResolver(import.meta.url);
145
- nuxt.options.build.transpile = ["maz-ui", "@maz-ui/themes", ...nuxt.options.build.transpile];
146
- const moduleOptions = defu(nuxt.options.runtimeConfig.public.mazUi, options, defaults);
152
+ nuxt.options.build.transpile = [
153
+ "maz-ui",
154
+ "@maz-ui/themes",
155
+ ...nuxt.options.build.transpile
156
+ ];
157
+ const moduleOptions = defu(
158
+ nuxt.options.runtimeConfig.public.mazUi,
159
+ options,
160
+ defaults
161
+ );
147
162
  nuxt.options.runtimeConfig.public.mazUi = moduleOptions;
148
163
  if (moduleOptions.css.injectMainCss) {
149
164
  nuxt.options.css = ["maz-ui/dist/css/main.css", ...nuxt.options.css];
@@ -158,13 +173,13 @@ const module = defineNuxtModule({
158
173
  });
159
174
  }
160
175
  }
176
+ const autoImportPrefix = moduleOptions.general.autoImportPrefix;
161
177
  if (moduleOptions.plugins.aos) {
162
178
  addPlugin(resolve(_dirname, "./runtime/plugins/aos"));
163
- addComposableImport({
179
+ addMazUiComposableImport({
164
180
  name: "useAos",
165
- typed: false,
166
181
  from: resolve(_dirname, "./runtime/composables/useAos"),
167
- prefix: moduleOptions.general?.autoImportPrefix
182
+ prefix: autoImportPrefix
168
183
  });
169
184
  const injectAosCSS = typeof moduleOptions.plugins.aos === "object" && typeof moduleOptions.plugins.aos.injectCss === "boolean" ? moduleOptions.plugins.aos.injectCss : true;
170
185
  if (injectAosCSS) {
@@ -173,29 +188,26 @@ const module = defineNuxtModule({
173
188
  }
174
189
  if (moduleOptions.plugins.toast) {
175
190
  addPlugin(resolve(_dirname, "./runtime/plugins/toast"));
176
- addComposableImport({
191
+ addMazUiComposableImport({
177
192
  name: "useToast",
178
- typed: false,
179
193
  from: resolve(_dirname, "./runtime/composables/useToast"),
180
- prefix: moduleOptions.general?.autoImportPrefix
194
+ prefix: autoImportPrefix
181
195
  });
182
196
  }
183
197
  if (moduleOptions.plugins.dialog) {
184
198
  addPlugin(resolve(_dirname, "./runtime/plugins/dialog"));
185
- addComposableImport({
199
+ addMazUiComposableImport({
186
200
  name: "useDialog",
187
- typed: false,
188
201
  from: resolve(_dirname, "./runtime/composables/useDialog"),
189
- prefix: moduleOptions.general?.autoImportPrefix
202
+ prefix: autoImportPrefix
190
203
  });
191
204
  }
192
205
  if (moduleOptions.plugins.wait) {
193
206
  addPlugin(resolve(_dirname, "./runtime/plugins/wait"));
194
- addComposableImport({
207
+ addMazUiComposableImport({
195
208
  name: "useWait",
196
- typed: false,
197
209
  from: resolve(_dirname, "./runtime/composables/useWait"),
198
- prefix: moduleOptions.general?.autoImportPrefix
210
+ prefix: autoImportPrefix
199
211
  });
200
212
  }
201
213
  if (moduleOptions.directives.vZoomImg) {
@@ -213,125 +225,26 @@ const module = defineNuxtModule({
213
225
  if (moduleOptions.directives.vTooltip) {
214
226
  addPlugin(resolve(_dirname, "./runtime/plugins/v-tooltip"));
215
227
  }
216
- if (moduleOptions.composables.useIdleTimeout) {
217
- addComposableImport({
218
- name: "useIdleTimeout",
219
- from: "maz-ui/composables/useIdleTimeout",
220
- prefix: moduleOptions.general?.autoImportPrefix
221
- });
222
- }
223
- if (moduleOptions.composables.useReadingTime) {
224
- addComposableImport({
225
- name: "useReadingTime",
226
- from: "maz-ui/composables/useReadingTime",
227
- prefix: moduleOptions.general?.autoImportPrefix
228
- });
229
- }
230
- if (moduleOptions.composables.useWindowSize) {
231
- addComposableImport({
232
- name: "useWindowSize",
233
- from: "maz-ui/composables/useWindowSize",
234
- prefix: moduleOptions.general?.autoImportPrefix
235
- });
236
- }
237
- if (moduleOptions.composables.useBreakpoints) {
238
- addImports({
239
- from: "maz-ui/composables/useBreakpoints",
240
- name: "useBreakpoints",
241
- as: "useBreakpoints"
242
- });
243
- }
244
- if (moduleOptions.composables.useUserVisibility) {
245
- addComposableImport({
246
- name: "useUserVisibility",
247
- from: "maz-ui/composables/useUserVisibility",
248
- prefix: moduleOptions.general?.autoImportPrefix
249
- });
250
- }
251
- if (moduleOptions.composables.useStringMatching) {
252
- addComposableImport({
253
- name: "useStringMatching",
254
- from: "maz-ui/composables/useStringMatching",
255
- prefix: moduleOptions.general?.autoImportPrefix
256
- });
257
- }
258
- if (moduleOptions.composables.useTimer) {
259
- addComposableImport({
260
- name: "useTimer",
261
- from: "maz-ui/composables/useTimer",
262
- prefix: moduleOptions.general?.autoImportPrefix
263
- });
264
- }
265
- if (moduleOptions.composables.useFreezeValue) {
266
- addComposableImport({
267
- name: "useFreezeValue",
268
- from: "maz-ui/composables/useFreezeValue",
269
- prefix: moduleOptions.general?.autoImportPrefix
270
- });
271
- }
272
- if (moduleOptions.composables.useInjectStrict) {
273
- addComposableImport({
274
- name: "useInjectStrict",
275
- from: "maz-ui/composables/useInjectStrict",
276
- prefix: moduleOptions.general?.autoImportPrefix
277
- });
278
- }
279
- if (moduleOptions.composables.useInstanceUniqId) {
280
- addComposableImport({
281
- name: "useInstanceUniqId",
282
- from: "maz-ui/composables/useInstanceUniqId",
283
- prefix: moduleOptions.general?.autoImportPrefix
284
- });
285
- }
286
- if (moduleOptions.composables.useMountComponent) {
287
- addComposableImport({
288
- name: "useMountComponent",
289
- from: "maz-ui/composables/useMountComponent",
290
- prefix: moduleOptions.general?.autoImportPrefix
291
- });
292
- }
293
- if (moduleOptions.composables.useSwipe) {
294
- addComposableImport({
295
- name: "useSwipe",
296
- from: "maz-ui/composables/useSwipe",
297
- prefix: moduleOptions.general?.autoImportPrefix
298
- });
299
- }
300
- if (moduleOptions.composables.useFormValidator) {
301
- addComposableImport({
302
- name: "useFormValidator",
303
- from: "maz-ui/composables/useFormValidator",
304
- prefix: moduleOptions.general?.autoImportPrefix
305
- });
306
- }
307
- if (moduleOptions.composables.useFormField) {
308
- addComposableImport({
309
- name: "useFormField",
310
- from: "maz-ui/composables/useFormField",
311
- prefix: moduleOptions.general?.autoImportPrefix
312
- });
313
- }
314
- if (moduleOptions.composables.useDisplayNames) {
315
- addComposableImport({
316
- name: "useDisplayNames",
317
- from: "maz-ui/composables/useDisplayNames",
318
- prefix: moduleOptions.general?.autoImportPrefix
228
+ const allowedMazUiComposables = Object.keys(moduleOptions.composables).filter((composable) => mazUiComposables[composable]);
229
+ for (const composable of allowedMazUiComposables) {
230
+ addMazUiComposableImport({
231
+ name: composable,
232
+ from: `maz-ui/composables`,
233
+ prefix: autoImportPrefix
319
234
  });
320
235
  }
321
236
  if (moduleOptions.composables.useTheme) {
322
- addComposableImport({
237
+ addImports({
323
238
  name: "useTheme",
324
- typed: false,
325
- from: "@maz-ui/themes/composables/useTheme",
326
- prefix: moduleOptions.general?.autoImportPrefix
239
+ from: "@maz-ui/themes",
240
+ as: `use${capitalize(autoImportPrefix)}Theme`
327
241
  });
328
242
  }
329
243
  if (moduleOptions.composables.useTranslations) {
330
- addComposableImport({
244
+ addImports({
331
245
  name: "useTranslations",
332
- typed: false,
333
246
  from: "@maz-ui/translations",
334
- prefix: moduleOptions.general?.autoImportPrefix
247
+ as: `use${capitalize(autoImportPrefix)}Translations`
335
248
  });
336
249
  }
337
250
  if (moduleOptions.general.defaultMazIconPath) {
@@ -1,6 +1,21 @@
1
- import { MazTranslations } from "@maz-ui/translations";
1
+ import {
2
+ MazTranslations
3
+ } from "@maz-ui/translations";
2
4
  import { defineNuxtPlugin } from "nuxt/app";
3
- export default defineNuxtPlugin(({ vueApp, $config }) => {
4
- const translationsOptions = $config.public.mazUi?.translations;
5
- vueApp.use(MazTranslations, translationsOptions);
5
+ export default defineNuxtPlugin(async ({ vueApp, $config }) => {
6
+ const translationsOptions = $config.public.mazUi.translations || {};
7
+ const i18n = MazTranslations.install(vueApp, translationsOptions);
8
+ if (process.server) {
9
+ const locale = translationsOptions.locale || "en";
10
+ const fallbackLocale = translationsOptions.fallbackLocale || "en";
11
+ try {
12
+ await i18n.setLocale(locale);
13
+ if (locale !== fallbackLocale && translationsOptions.preloadFallback !== false) {
14
+ await i18n.setLocale(fallbackLocale);
15
+ await i18n.setLocale(locale);
16
+ }
17
+ } catch (error) {
18
+ console.warn("Failed to preload locale:", error);
19
+ }
20
+ }
6
21
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@maz-ui/nuxt",
3
3
  "type": "module",
4
- "version": "4.0.0-beta.6",
4
+ "version": "4.0.0-beta.8",
5
5
  "description": "Nuxt module for Maz-UI",
6
6
  "author": "Louis Mazel <me@loicmazuel.com>",
7
7
  "license": "MIT",
@@ -46,21 +46,18 @@
46
46
  ],
47
47
  "scripts": {
48
48
  "prepack": "nuxt-module-build build",
49
- "build": "pnpm prepare && nuxt-module-build build",
50
- "prepare": "nuxt-module-build build --stub && nuxt-module-build prepare",
51
- "dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare",
49
+ "build": "pnpm dev && nuxt-module-build build",
50
+ "dev": "nuxt-module-build build --stub && nuxt-module-build prepare",
52
51
  "lint": "cross-env NODE_ENV=production eslint .",
53
52
  "lint:fix": "pnpm lint --fix",
54
- "format": "prettier --ignore-path .gitignore . --write",
55
- "typecheck": "vue-tsc --noEmit --skipLibCheck",
56
- "release": "npm run lint && npm run prepack && changelogen --release && npm publish && git push --follow-tags"
53
+ "typecheck": "vue-tsc --noEmit --skipLibCheck"
57
54
  },
58
55
  "dependencies": {
59
- "@maz-ui/themes": "4.0.0-beta.6",
60
- "@maz-ui/translations": "4.0.0-beta.6",
56
+ "@maz-ui/themes": "4.0.0-beta.8",
57
+ "@maz-ui/translations": "4.0.0-beta.8",
61
58
  "@nuxt/kit": "^3.17.4",
62
59
  "defu": "^6.1.4",
63
- "maz-ui": "4.0.0-beta.6"
60
+ "maz-ui": "4.0.0-beta.8"
64
61
  },
65
62
  "devDependencies": {
66
63
  "@nuxt/devtools": "^2.4.1",
@@ -73,8 +70,7 @@
73
70
  "vitest": "^3.2.4"
74
71
  },
75
72
  "lint-staged": {
76
- "*": "prettier -w -u",
77
73
  "*.{js,ts,mjs,mts,cjs,md}": "cross-env NODE_ENV=production eslint --fix"
78
74
  },
79
- "gitHead": "bbff6fcfca7d47dd8f8024b69ac787b66ba0b65e"
75
+ "gitHead": "fef4d097f7e992f20980cc628216f070a516644e"
80
76
  }