vuetify-nuxt-module 0.4.7 → 0.4.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.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.8"
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.8";
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,21 @@ 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
+ return des
234
+ }
235
+ ` : ""}
221
236
  `;
222
237
  }
223
238
  }
@@ -230,7 +245,8 @@ export function vuetifyConfiguration() {
230
245
  aliasEntries: [],
231
246
  aliases: aliases || {},
232
247
  components: new Set(components ? Array.isArray(components) ? components : [components] : []),
233
- labComponents: /* @__PURE__ */ new Set()
248
+ labComponents: /* @__PURE__ */ new Set(),
249
+ messages: ""
234
250
  };
235
251
  if (directives) {
236
252
  if (typeof directives === "boolean") {
@@ -348,11 +364,31 @@ export function vuetifyConfiguration() {
348
364
  else
349
365
  componentsEntry = `options.components = {${Array.from(config.labComponents).join(",")}}`;
350
366
  }
367
+ if (
368
+ /*! i18n && */
369
+ localeMessages
370
+ ) {
371
+ const useLocales = Array.isArray(localeMessages) ? [.../* @__PURE__ */ new Set([...localeMessages])] : [localeMessages];
372
+ config.imports.push(`import {${useLocales.join(",")}} from 'vuetify/locale'`);
373
+ config.messages = `
374
+ options.locale = options.locale || {}
375
+ options.locale.messages = options.locale.messages || {}
376
+ ${useLocales.map((locale) => {
377
+ return `
378
+ if ('${locale}' in options.locale.messages)
379
+ options.locale.messages['${locale}'] = deepCopy(options.locale.messages['${locale}'],${locale})
380
+ else
381
+ options.locale.messages['${locale}'] = ${locale}
382
+ `;
383
+ }).join("")}
384
+ `;
385
+ }
351
386
  return {
352
387
  imports: config.imports.length ? config.imports.join("\n") : "",
353
388
  components: componentsEntry,
354
389
  aliases: config.aliasEntries.length ? `options.aliases = {${config.aliasEntries.join(",")}}` : "",
355
- directives: config.directives
390
+ directives: config.directives,
391
+ messages: config.messages
356
392
  };
357
393
  }
358
394
  }
@@ -675,6 +711,19 @@ toKebabCase.cache = /* @__PURE__ */ new Map();
675
711
 
676
712
  function detectDate() {
677
713
  const result = [];
714
+ [
715
+ "date-fns",
716
+ "moment",
717
+ "luxon",
718
+ "dayjs",
719
+ "js-joda",
720
+ "date-fns-jalali",
721
+ "jalaali",
722
+ "hijri"
723
+ ].forEach((adapter) => {
724
+ if (isPackageExists(`@date-io/${adapter}`))
725
+ result.push(adapter);
726
+ });
678
727
  return result;
679
728
  }
680
729
  function cleanupBlueprint(vuetifyOptions) {
@@ -689,6 +738,30 @@ function cleanupBlueprint(vuetifyOptions) {
689
738
  vuetifyOptions.blueprint = blueprint;
690
739
  }
691
740
  }
741
+ function checkVuetifyPlugins(config) {
742
+ let plugin = config.plugins?.find((p) => p && typeof p === "object" && "name" in p && p.name === "vuetify:import");
743
+ if (plugin)
744
+ throw new Error("Remove vite-plugin-vuetify plugin from Vite Plugins entry in Nuxt config file!");
745
+ plugin = config.plugins?.find((p) => p && typeof p === "object" && "name" in p && p.name === "vuetify:styles");
746
+ if (plugin)
747
+ throw new Error("Remove vite-plugin-vuetify plugin from Vite Plugins entry in Nuxt config file!");
748
+ }
749
+ function resolveVuetifyComponents(resolver) {
750
+ const vuetifyBase = resolveVuetifyBase();
751
+ const componentsPromise = importMapResolver();
752
+ const labComponentsPromise = importMapLabResolver();
753
+ return {
754
+ vuetifyBase,
755
+ componentsPromise,
756
+ labComponentsPromise
757
+ };
758
+ async function importMapResolver() {
759
+ return JSON.parse(await readFile(resolver.resolve(vuetifyBase, "dist/json/importMap.json"), "utf-8")).components;
760
+ }
761
+ async function importMapLabResolver() {
762
+ return JSON.parse(await readFile(resolver.resolve(vuetifyBase, "dist/json/importMap-labs.json"), "utf-8")).components;
763
+ }
764
+ }
692
765
 
693
766
  async function mergeVuetifyModules(options, nuxt) {
694
767
  const moduleOptions = [];
@@ -781,7 +854,7 @@ const module = defineNuxtModule({
781
854
  nuxt.options.css.unshift("vuetify/styles/main.sass");
782
855
  else if (styles === true)
783
856
  nuxt.options.css.unshift("vuetify/styles");
784
- else if (typeof styles === "object" && styles?.configFile && typeof styles.configFile === "string")
857
+ else if (typeof styles === "object" && typeof styles?.configFile === "string")
785
858
  nuxt.options.css.unshift(styles.configFile);
786
859
  if (icons.enabled) {
787
860
  icons.local?.forEach((css) => nuxt.options.css.push(css));
@@ -802,15 +875,11 @@ const module = defineNuxtModule({
802
875
  nuxt.hook("prepare:types", ({ references }) => {
803
876
  references.push({ types: "vuetify-nuxt-module/configuration" });
804
877
  });
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();
878
+ const {
879
+ vuetifyBase,
880
+ componentsPromise,
881
+ labComponentsPromise
882
+ } = resolveVuetifyComponents(resolver);
814
883
  nuxt.hook("components:extend", async (c) => {
815
884
  const components = await componentsPromise;
816
885
  Object.keys(components).forEach((component) => {
@@ -820,7 +889,7 @@ const module = defineNuxtModule({
820
889
  kebabName: toKebabCase(component),
821
890
  export: component,
822
891
  filePath: `${resolver.resolve(vuetifyBase, `lib/${from}`)}`,
823
- shortPath: `components/${from}`,
892
+ shortPath: `vuetify/components/${from}`,
824
893
  chunkName: toKebabCase(component),
825
894
  prefetch: false,
826
895
  preload: false,
@@ -890,13 +959,5 @@ const module = defineNuxtModule({
890
959
  }
891
960
  }
892
961
  });
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
962
 
902
963
  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.8",
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",
@@ -125,4 +125,4 @@
125
125
  "installDependencies": false,
126
126
  "startCommand": "node .stackblitz.js && pnpm install && pnpm run dev"
127
127
  }
128
- }
128
+ }