vuetify-nuxt-module 0.4.7 → 0.4.9

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.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
  import * as vuetify from 'vuetify';
3
3
  import { VuetifyOptions, LocaleOptions, RtlOptions } from 'vuetify';
4
+ import * as vuetify_locale from 'vuetify/locale';
4
5
  import * as vuetify_labs_components from 'vuetify/labs/components';
5
6
  import * as vuetify_directives from 'vuetify/directives';
6
7
  import * as vuetify_components from 'vuetify/components';
@@ -90,6 +91,7 @@ type DirectiveName = keyof typeof vuetify_directives;
90
91
  type Directives = boolean | DirectiveName | DirectiveName[];
91
92
  type LabComponentName = keyof typeof vuetify_labs_components;
92
93
  type LabComponents = boolean | LabComponentName | LabComponentName[];
94
+ type VuetifyLocale = keyof typeof vuetify_locale;
93
95
  interface VOptions extends Partial<Omit<VuetifyOptions, 'ssr' | 'aliases' | 'components' | 'directives' | 'locale' | 'date' | 'icons'>> {
94
96
  aliases?: Record<string, ComponentName>;
95
97
  /**
@@ -105,10 +107,19 @@ interface VOptions extends Partial<Omit<VuetifyOptions, 'ssr' | 'aliases' | 'com
105
107
  * - `locale`
106
108
  * - `fallback`
107
109
  * - `rtl`
110
+ * - `messages`
108
111
  *
109
112
  * The adapter will be `vuetify`, if you want to use another adapter, check `date` option.
110
113
  */
111
114
  locale?: Omit<LocaleOptions, 'adapter'> & RtlOptions;
115
+ /**
116
+ * Include locale messages?
117
+ *
118
+ * When `@nuxtjs/i18n` Nuxt module is present, this option will be ignored.
119
+ *
120
+ * You can include the locales you want to use in your application, this module will load and configure the messages for you.
121
+ */
122
+ localeMessages?: VuetifyLocale | VuetifyLocale[];
112
123
  /**
113
124
  * Include the lab components?
114
125
  *
@@ -209,4 +220,4 @@ declare module '#app' {
209
220
 
210
221
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
211
222
 
212
- export { ComponentName, Components, DateAdapter, DateOptions, DirectiveName, Directives, FontAwesomeSvgIconSet, FontIconSet, IconFontName, IconSetName, IconsOptions, JSSVGIconSet, LabComponentName, LabComponents, MOptions, ModuleOptions, VOptions, _default as default };
223
+ export { ComponentName, Components, DateAdapter, DateOptions, DirectiveName, Directives, FontAwesomeSvgIconSet, FontIconSet, IconFontName, IconSetName, IconsOptions, JSSVGIconSet, LabComponentName, LabComponents, MOptions, ModuleOptions, VOptions, VuetifyLocale, _default as default };
package/dist/module.json CHANGED
@@ -4,5 +4,5 @@
4
4
  "compatibility": {
5
5
  "nuxt": "^3.0.0"
6
6
  },
7
- "version": "0.4.7"
7
+ "version": "0.4.9"
8
8
  }
package/dist/module.mjs CHANGED
@@ -1,12 +1,12 @@
1
- import { utimes, readFile } from 'node:fs/promises';
2
1
  import { useLogger, defineNuxtModule, isNuxt3, getNuxtVersion, createResolver, hasNuxtModule, extendWebpackConfig, addImports, addPlugin } from '@nuxt/kit';
3
2
  import defu from 'defu';
3
+ import { utimes, readFile } from 'node:fs/promises';
4
4
  import { resolveVuetifyBase, normalizePath, writeStyles, cacheDir } from '@vuetify/loader-shared';
5
5
  import { isAbsolute, join, relative } from 'pathe';
6
6
  import { normalizePath as normalizePath$1 } from 'vite';
7
7
  import { isPackageExists } from 'local-pkg';
8
8
 
9
- const version = "0.4.7";
9
+ const version = "0.4.9";
10
10
 
11
11
  function isSubdir(root, test) {
12
12
  const relative$1 = relative(root, test);
@@ -189,6 +189,7 @@ function vuetifyConfigurationPlugin(isDev, i18n, directives, labComponents, vuet
189
189
  directives: _directives,
190
190
  date: _date,
191
191
  icons: _icons,
192
+ localeMessages,
192
193
  components,
193
194
  aliases,
194
195
  ...newVuetifyOptions
@@ -208,6 +209,7 @@ function vuetifyConfigurationPlugin(isDev, i18n, directives, labComponents, vuet
208
209
  delete newVuetifyOptions.locale.fallback;
209
210
  }
210
211
  const result = await buildConfiguration();
212
+ const deepCopy = result.messages.length > 0;
211
213
  return `${result.imports}
212
214
 
213
215
  export const isDev = ${isDev}
@@ -216,8 +218,20 @@ export function vuetifyConfiguration() {
216
218
  ${result.directives}
217
219
  ${result.aliases}
218
220
  ${result.components}
221
+ ${result.messages}
219
222
  return options
220
223
  }
224
+ ${deepCopy ? `function deepCopy(src,des) {
225
+ for (const key in src) {
226
+ if (typeof src[key] === 'object') {
227
+ if (typeof des[key] !== 'object') des[key] = {}
228
+ deepCopy(src[key], des[key])
229
+ } else {
230
+ des[key] = src[key]
231
+ }
232
+ }
233
+ }
234
+ ` : ""}
221
235
  `;
222
236
  }
223
237
  }
@@ -230,7 +244,8 @@ export function vuetifyConfiguration() {
230
244
  aliasEntries: [],
231
245
  aliases: aliases || {},
232
246
  components: new Set(components ? Array.isArray(components) ? components : [components] : []),
233
- labComponents: /* @__PURE__ */ new Set()
247
+ labComponents: /* @__PURE__ */ new Set(),
248
+ messages: ""
234
249
  };
235
250
  if (directives) {
236
251
  if (typeof directives === "boolean") {
@@ -348,11 +363,28 @@ export function vuetifyConfiguration() {
348
363
  else
349
364
  componentsEntry = `options.components = {${Array.from(config.labComponents).join(",")}}`;
350
365
  }
366
+ if (!i18n && localeMessages) {
367
+ const useLocales = Array.isArray(localeMessages) ? [.../* @__PURE__ */ new Set([...localeMessages])] : [localeMessages];
368
+ config.imports.push(`import {${useLocales.join(",")}} from 'vuetify/locale'`);
369
+ config.messages = `
370
+ options.locale = options.locale || {}
371
+ options.locale.messages = options.locale.messages || {}
372
+ ${useLocales.map((locale) => {
373
+ return `
374
+ if ('${locale}' in options.locale.messages)
375
+ deepCopy(options.locale.messages['${locale}'],${locale})
376
+
377
+ options.locale.messages['${locale}'] = ${locale}
378
+ `;
379
+ }).join("")}
380
+ `;
381
+ }
351
382
  return {
352
383
  imports: config.imports.length ? config.imports.join("\n") : "",
353
384
  components: componentsEntry,
354
385
  aliases: config.aliasEntries.length ? `options.aliases = {${config.aliasEntries.join(",")}}` : "",
355
- directives: config.directives
386
+ directives: config.directives,
387
+ messages: config.messages
356
388
  };
357
389
  }
358
390
  }
@@ -675,6 +707,19 @@ toKebabCase.cache = /* @__PURE__ */ new Map();
675
707
 
676
708
  function detectDate() {
677
709
  const result = [];
710
+ [
711
+ "date-fns",
712
+ "moment",
713
+ "luxon",
714
+ "dayjs",
715
+ "js-joda",
716
+ "date-fns-jalali",
717
+ "jalaali",
718
+ "hijri"
719
+ ].forEach((adapter) => {
720
+ if (isPackageExists(`@date-io/${adapter}`))
721
+ result.push(adapter);
722
+ });
678
723
  return result;
679
724
  }
680
725
  function cleanupBlueprint(vuetifyOptions) {
@@ -689,6 +734,30 @@ function cleanupBlueprint(vuetifyOptions) {
689
734
  vuetifyOptions.blueprint = blueprint;
690
735
  }
691
736
  }
737
+ function checkVuetifyPlugins(config) {
738
+ let plugin = config.plugins?.find((p) => p && typeof p === "object" && "name" in p && p.name === "vuetify:import");
739
+ if (plugin)
740
+ throw new Error("Remove vite-plugin-vuetify plugin from Vite Plugins entry in Nuxt config file!");
741
+ plugin = config.plugins?.find((p) => p && typeof p === "object" && "name" in p && p.name === "vuetify:styles");
742
+ if (plugin)
743
+ throw new Error("Remove vite-plugin-vuetify plugin from Vite Plugins entry in Nuxt config file!");
744
+ }
745
+ function resolveVuetifyComponents(resolver) {
746
+ const vuetifyBase = resolveVuetifyBase();
747
+ const componentsPromise = importMapResolver();
748
+ const labComponentsPromise = importMapLabResolver();
749
+ return {
750
+ vuetifyBase,
751
+ componentsPromise,
752
+ labComponentsPromise
753
+ };
754
+ async function importMapResolver() {
755
+ return JSON.parse(await readFile(resolver.resolve(vuetifyBase, "dist/json/importMap.json"), "utf-8")).components;
756
+ }
757
+ async function importMapLabResolver() {
758
+ return JSON.parse(await readFile(resolver.resolve(vuetifyBase, "dist/json/importMap-labs.json"), "utf-8")).components;
759
+ }
760
+ }
692
761
 
693
762
  async function mergeVuetifyModules(options, nuxt) {
694
763
  const moduleOptions = [];
@@ -781,7 +850,7 @@ const module = defineNuxtModule({
781
850
  nuxt.options.css.unshift("vuetify/styles/main.sass");
782
851
  else if (styles === true)
783
852
  nuxt.options.css.unshift("vuetify/styles");
784
- else if (typeof styles === "object" && styles?.configFile && typeof styles.configFile === "string")
853
+ else if (typeof styles === "object" && typeof styles?.configFile === "string")
785
854
  nuxt.options.css.unshift(styles.configFile);
786
855
  if (icons.enabled) {
787
856
  icons.local?.forEach((css) => nuxt.options.css.push(css));
@@ -802,15 +871,11 @@ const module = defineNuxtModule({
802
871
  nuxt.hook("prepare:types", ({ references }) => {
803
872
  references.push({ types: "vuetify-nuxt-module/configuration" });
804
873
  });
805
- const vuetifyBase = resolveVuetifyBase();
806
- async function importMapResolver() {
807
- return JSON.parse(await readFile(resolver.resolve(vuetifyBase, "dist/json/importMap.json"), "utf-8")).components;
808
- }
809
- async function importMapLabResolver() {
810
- return JSON.parse(await readFile(resolver.resolve(vuetifyBase, "dist/json/importMap-labs.json"), "utf-8")).components;
811
- }
812
- const componentsPromise = importMapResolver();
813
- const labComponentsPromise = importMapLabResolver();
874
+ const {
875
+ vuetifyBase,
876
+ componentsPromise,
877
+ labComponentsPromise
878
+ } = resolveVuetifyComponents(resolver);
814
879
  nuxt.hook("components:extend", async (c) => {
815
880
  const components = await componentsPromise;
816
881
  Object.keys(components).forEach((component) => {
@@ -820,7 +885,7 @@ const module = defineNuxtModule({
820
885
  kebabName: toKebabCase(component),
821
886
  export: component,
822
887
  filePath: `${resolver.resolve(vuetifyBase, `lib/${from}`)}`,
823
- shortPath: `components/${from}`,
888
+ shortPath: `vuetify/components/${from}`,
824
889
  chunkName: toKebabCase(component),
825
890
  prefetch: false,
826
891
  preload: false,
@@ -890,13 +955,5 @@ const module = defineNuxtModule({
890
955
  }
891
956
  }
892
957
  });
893
- function checkVuetifyPlugins(config) {
894
- let plugin = config.plugins?.find((p) => p && typeof p === "object" && "name" in p && p.name === "vuetify:import");
895
- if (plugin)
896
- throw new Error("Remove vite-plugin-vuetify plugin from Vite Plugins entry in Nuxt config file!");
897
- plugin = config.plugins?.find((p) => p && typeof p === "object" && "name" in p && p.name === "vuetify:styles");
898
- if (plugin)
899
- throw new Error("Remove vite-plugin-vuetify plugin from Vite Plugins entry in Nuxt config file!");
900
- }
901
958
 
902
959
  export { module as default };
package/dist/types.d.ts CHANGED
@@ -12,4 +12,4 @@ declare module 'nuxt/schema' {
12
12
  }
13
13
 
14
14
 
15
- export { ComponentName, Components, DateAdapter, DateOptions, DirectiveName, Directives, FontAwesomeSvgIconSet, FontIconSet, IconFontName, IconSetName, IconsOptions, JSSVGIconSet, LabComponentName, LabComponents, MOptions, ModuleOptions, VOptions, default } from './module'
15
+ export { ComponentName, Components, DateAdapter, DateOptions, DirectiveName, Directives, FontAwesomeSvgIconSet, FontIconSet, IconFontName, IconSetName, IconsOptions, JSSVGIconSet, LabComponentName, LabComponents, MOptions, ModuleOptions, VOptions, VuetifyLocale, default } from './module'
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "vuetify-nuxt-module",
3
3
  "type": "module",
4
- "version": "0.4.7",
5
- "packageManager": "pnpm@8.6.8",
4
+ "version": "0.4.9",
5
+ "packageManager": "pnpm@8.6.9",
6
6
  "description": "Zero-Config Nuxt Module for Vuetify",
7
7
  "author": "userquin <userquin@gmail.com>",
8
8
  "license": "MIT",
@@ -59,13 +59,13 @@
59
59
  "peerDependencies": {
60
60
  "@nuxt/kit": "^3.6.2",
61
61
  "vite-plugin-vuetify": "^1.0.2",
62
- "vuetify": "^3.3.6"
62
+ "vuetify": "^3.3.9"
63
63
  },
64
64
  "dependencies": {
65
65
  "@nuxt/kit": "^3.6.2",
66
66
  "defu": "^6.1.2",
67
67
  "vite-plugin-vuetify": "^1.0.2",
68
- "vuetify": "^3.3.6"
68
+ "vuetify": "^3.3.9"
69
69
  },
70
70
  "devDependencies": {
71
71
  "@antfu/eslint-config": "^0.39.6",