vuetify-nuxt-module 0.2.4 → 0.4.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
@@ -40,7 +40,7 @@
40
40
  - 🌍 **I18n Ready**: install [@nuxtjs/i18n](https://v8.i18n.nuxtjs.org/) Nuxt module, and you're ready to use Vuetify [internationalization](https://vuetifyjs.com/en/features/internationalization/) features
41
41
  - 📆 **Date Components**: use Vuetify components [that require date functionality](https://vuetifyjs.com/en/features/dates/) installing and configuring one of the [@date-io](https://github.com/dmtrKovalenko/date-io#projects) adapters
42
42
  - ⚙️ **Auto-Import Vuetify Composables**: you don't need to import Vuetify composables manually, they are automatically imported for you
43
- - 🎨 **Vuetify Blueprints (WIP)**: use [Vuetify Blueprints](https://vuetifyjs.com/en/features/blueprints/) to quickly scaffold components
43
+ - 🎨 **Vuetify Blueprints**: use [Vuetify Blueprints](https://vuetifyjs.com/en/features/blueprints/) to quickly scaffold components
44
44
  - 🦾 **Type Strong**: written in [TypeScript](https://www.typescriptlang.org/)
45
45
 
46
46
  ## 📦 Install
@@ -84,6 +84,34 @@ export default defineNuxtConfig({
84
84
  })
85
85
  ```
86
86
 
87
+ ## 🔥 Components, Directives, Lab Components
88
+
89
+ The module will enable automatic tree shaking for Vuetify components.
90
+
91
+ You don't need to install any Vuetify Vite Plugin (the module will throw an error if any Vuetify Vite Plugin is installed in your Nuxt configuration):
92
+ - the module will provide auto-import support via `vuetify/dist/json/importMap.json` json file and Nuxt `components:extend` hook.
93
+ - the module will register a custom Vite Plugin for Vuetify styles: it is just a copy from the original Vuetify Vite Styles Plugin, changing some virtual names mappings and handling SSR flags.
94
+
95
+ ### Global Components
96
+
97
+ If you need to add some global component, use `vuetifyOptions.components` module option, it has been declared properly to have better DX.
98
+
99
+ Check the [components definition](https://github.com/userquin/vuetify-nuxt-module/blob/main/src/types.ts#L80-L81).
100
+
101
+ You can also provide [Aliasing & Virtual Components](https://vuetifyjs.com/en/features/aliasing/#virtual-component-defaults) via `vuetifyOptions.aliases` module option to register components with a different name, only available for global components. The components require to be registered globally.
102
+
103
+ ### Directives
104
+
105
+ By default, the module will not register any Vuetify directive. If you need to register some directive, use `vuetifyOptions.directives` module option, it has been declared properly to have better DX.
106
+
107
+ You can register all the directives or only the ones you need: check the [directives definition](https://github.com/userquin/vuetify-nuxt-module/blob/main/src/types.ts#L82-L83).
108
+
109
+ ### Labs Components
110
+
111
+ The module provides support to use Vuetify [labs components](https://vuetifyjs.com/en/labs/introduction/) via `vuetifyOptions.labsComponents` module option, it has been declared properly to have better DX.
112
+
113
+ You can register all the labs components or only the ones you need: check the [labsComponent definition](https://github.com/userquin/vuetify-nuxt-module/blob/main/src/types.ts#L84-L85).
114
+
87
115
  ## 😃 Font Icons
88
116
 
89
117
  This module supports the following font icons libraries:
@@ -175,7 +203,7 @@ vuetify: {
175
203
 
176
204
  ### fa-svg
177
205
 
178
- You only need to add `@fortawesome/fontawesome-svg-core`, `@fortawesome/vue-fontawesome`, and `@fortawesome/free-solid-svg-icons` dependencies to your project and configure the default set:
206
+ You only need to add `@fortawesome/fontawesome-svg-core`, `@fortawesome/vue-fontawesome` and `@fortawesome/free-solid-svg-icons` dependencies to your project and configure the default set:
179
207
  ```ts
180
208
  vuetify: {
181
209
  vuetifyOptions: {
@@ -194,7 +222,7 @@ vuetify: {
194
222
  defaultSet: 'fa-svg',
195
223
  svg: {
196
224
  fa: {
197
- libraries: [/* default export? */ false, /* export name */ 'fas', /* import */ '@fortawesome/free-solid-svg-icons']
225
+ libraries: [/* default export? */ false, /* export name */ 'fas', /* library */ '@fortawesome/free-solid-svg-icons']
198
226
  }
199
227
  }
200
228
  }
@@ -210,7 +238,7 @@ vuetify: {
210
238
  vuetifyOptions: {
211
239
  icons: {
212
240
  defaultSet: 'mdi'
213
- sets: [{ name: 'mdi' }, { name: 'fa' }]
241
+ sets: ['mdi', 'fa']
214
242
  }
215
243
  }
216
244
  }
@@ -248,7 +276,7 @@ If you want to use a custom date adapter, you can configure it using `vuetifyOpt
248
276
  import { adapter, dateConfiguration, i18n } from 'virtual:vuetify-date-configuration'
249
277
  ```
250
278
 
251
- Check out [vuetify-date](./src/runtime/plugins/vuetify-date.mts) plugin for an example of a custom date adapter and how to access to the configuration.
279
+ Check out [vuetify-date](https://github.com/userquin/vuetify-nuxt-module/blob/main/src/runtime/plugins/vuetify-date.mts) plugin for an example of a custom date adapter and how to access to the configuration.
252
280
 
253
281
  ## ⚙️ Auto-Import Vuetify Composables
254
282
 
@@ -274,14 +302,20 @@ If you are using another composables that collide with the Vuetify ones, enable
274
302
 
275
303
  ## 🎨 Vuetify Blueprints
276
304
 
277
- **WIP**
305
+ The module supports Vuetify Blueprints, just add it to the `vuetifyOptions.blueprint` module option, but with some limitations:
306
+ - `ssr` will be ignored, this flag can be only configured internally by the module via the Nuxt ssr option.
307
+ - `components` will be ignored, configure them using the `vuetifyOptions.components` module option
308
+ - `directives` will be ignored, configure them using the `vuetifyOptions.directives` module option.
309
+ - `locale` will be ignored, configure it using the `vuetifyOptions.locale` module option.
310
+ - `date` will be ignored, configure it using the `vuetifyOptions.date` module option.
311
+ - `icons` will be ignored, configure it using the `vuetifyOptions.icons` module option.
278
312
 
279
313
  ## 👀 Full config
280
314
 
281
- Check out the type declaration [src/types.ts](./src/types.ts).
315
+ Check out the type declaration [src/types.ts](https://github.com/userquin/vuetify-nuxt-module/blob/main/src/types.ts).
282
316
 
283
- The virtual modules can be found in [configuration.d.ts](./configuration.d.ts) file.
317
+ The virtual modules can be found in [configuration.d.ts](https://github.com/userquin/vuetify-nuxt-module/blob/main/configuration.d.ts) file.
284
318
 
285
319
  ## 📄 License
286
320
 
287
- [MIT](./LICENSE) License © 2023-PRESENT [Joaquín Sánchez](https://github.com/userquin)
321
+ [MIT](https://github.com/userquin/vuetify-nuxt-module/blob/main/LICENSE) License © 2023-PRESENT [Joaquín Sánchez](https://github.com/userquin)
package/dist/module.d.ts CHANGED
@@ -1,8 +1,10 @@
1
1
  import * as _nuxt_schema from '@nuxt/schema';
2
2
  import * as vuetify from 'vuetify';
3
- import { VuetifyOptions } from 'vuetify';
3
+ import { VuetifyOptions, LocaleOptions, RtlOptions } from 'vuetify';
4
+ import * as vuetify_labs_components from 'vuetify/labs/components';
5
+ import * as vuetify_directives from 'vuetify/directives';
6
+ import * as vuetify_components from 'vuetify/components';
4
7
 
5
- type BooleanOrArrayString = boolean | string[];
6
8
  type DateAdapter = 'vuetify' | 'date-fns' | 'moment' | 'luxon' | 'dayjs' | 'js-joda' | 'date-fns-jalali' | 'jalaali' | 'hijri' | 'custom';
7
9
  /**
8
10
  * Date configuration.
@@ -30,16 +32,14 @@ interface DateOptions {
30
32
  *
31
33
  * When `@nuxtjs/i18n` Nuxt module is present, this option will be ignored, locales will be extracted from the available locales.
32
34
  */
33
- locale: Record<string, any>;
35
+ locale?: Record<string, any>;
34
36
  }
35
37
  type IconSetName = 'mdi' | 'fa' | 'fa4' | 'md' | 'mdi-svg' | 'fa-svg' | 'custom';
36
- interface IconSet {
37
- name: IconSetName;
38
- }
39
- interface JSSVGIconSet extends IconSet {
38
+ type IconFontName = 'mdi' | 'fa' | 'fa4' | 'md';
39
+ interface JSSVGIconSet {
40
40
  aliases?: Record<string, string>;
41
41
  }
42
- interface FontAwesomeSvgIconSet extends IconSet {
42
+ interface FontAwesomeSvgIconSet {
43
43
  /**
44
44
  * The libraries to import and register with the corresponding name.
45
45
  *
@@ -53,7 +53,8 @@ interface FontAwesomeSvgIconSet extends IconSet {
53
53
  */
54
54
  libraries?: [defaultExport: boolean, name: string, library: string][];
55
55
  }
56
- interface FontIconSet extends IconSet {
56
+ interface FontIconSet {
57
+ name: IconFontName;
57
58
  /**
58
59
  * Use CDN?
59
60
  *
@@ -68,13 +69,37 @@ interface FontIconSet extends IconSet {
68
69
  }
69
70
  interface IconsOptions {
70
71
  defaultSet: IconSetName;
71
- sets?: FontIconSet[];
72
+ sets?: IconFontName | IconFontName[] | FontIconSet[];
72
73
  svg?: {
73
74
  mdi?: JSSVGIconSet;
74
75
  fa?: FontAwesomeSvgIconSet;
75
76
  };
76
77
  }
77
- interface VOptions extends Partial<Omit<VuetifyOptions, 'ssr' | 'directives' | 'locale' | 'date' | 'icons'>> {
78
+ type ComponentName = keyof typeof vuetify_components;
79
+ type Components = false | ComponentName | ComponentName[];
80
+ type DirectiveName = keyof typeof vuetify_directives;
81
+ type Directives = boolean | DirectiveName | DirectiveName[];
82
+ type LabComponentName = keyof typeof vuetify_labs_components;
83
+ type LabComponents = boolean | LabComponentName | LabComponentName[];
84
+ interface VOptions extends Partial<Omit<VuetifyOptions, 'ssr' | 'aliases' | 'components' | 'directives' | 'locale' | 'date' | 'icons'>> {
85
+ aliases?: Record<string, ComponentName>;
86
+ /**
87
+ * Do you need to configure some global components?.
88
+ *
89
+ * @default false
90
+ */
91
+ components?: Components;
92
+ /**
93
+ * Configure the locale messages, the locale, the fallback locale and RTL options.
94
+ *
95
+ * When `@nuxtjs/i18n` Nuxt module is present, the following options will be ignored:
96
+ * - `locale`
97
+ * - `fallback`
98
+ * - `rtl`
99
+ *
100
+ * The adapter will be `vuetify`, if you want to use another adapter, check `date` option.
101
+ */
102
+ locale?: Omit<LocaleOptions, 'adapter'> & RtlOptions;
78
103
  /**
79
104
  * Include the lab components?
80
105
  *
@@ -86,7 +111,7 @@ interface VOptions extends Partial<Omit<VuetifyOptions, 'ssr' | 'directives' | '
86
111
  *
87
112
  * @default false
88
113
  */
89
- labComponents?: BooleanOrArrayString;
114
+ labComponents?: LabComponents;
90
115
  /**
91
116
  * Include the directives?
92
117
  *
@@ -96,7 +121,7 @@ interface VOptions extends Partial<Omit<VuetifyOptions, 'ssr' | 'directives' | '
96
121
  *
97
122
  * @default false
98
123
  */
99
- directives?: BooleanOrArrayString;
124
+ directives?: Directives;
100
125
  /**
101
126
  * Date configuration.
102
127
  *
@@ -163,4 +188,4 @@ declare module '#app' {
163
188
 
164
189
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
165
190
 
166
- export { BooleanOrArrayString, DateAdapter, DateOptions, FontAwesomeSvgIconSet, FontIconSet, IconSet, IconSetName, IconsOptions, JSSVGIconSet, MOptions, ModuleOptions, VOptions, _default as default };
191
+ export { ComponentName, Components, DateAdapter, DateOptions, DirectiveName, Directives, FontAwesomeSvgIconSet, FontIconSet, IconFontName, IconSetName, IconsOptions, JSSVGIconSet, LabComponentName, LabComponents, MOptions, ModuleOptions, VOptions, _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.2.4"
7
+ "version": "0.4.0"
8
8
  }
package/dist/module.mjs CHANGED
@@ -6,7 +6,7 @@ import { resolveVuetifyBase, normalizePath, writeStyles, cacheDir } from '@vueti
6
6
  import { isAbsolute, join, relative } from 'pathe';
7
7
  import { normalizePath as normalizePath$1 } from 'vite';
8
8
 
9
- const version = "0.2.4";
9
+ const version = "0.4.0";
10
10
 
11
11
  function isSubdir(root, test) {
12
12
  const relative$1 = relative(root, test);
@@ -184,11 +184,13 @@ const RESOLVED_VIRTUAL_VUETIFY_DATE_CONFIGURATION = `/@nuxt-vuetify-configuratio
184
184
  const VIRTUAL_VUETIFY_ICONS_CONFIGURATION = "virtual:vuetify-icons-configuration";
185
185
  const RESOLVED_VIRTUAL_VUETIFY_ICONS_CONFIGURATION = `/@nuxt-vuetify-configuration/${VIRTUAL_VUETIFY_ICONS_CONFIGURATION.slice("virtual:".length)}`;
186
186
 
187
- function vuetifyConfigurationPlugin(isDev, directives, labComponents, vuetifyAppOptions) {
187
+ function vuetifyConfigurationPlugin(isDev, i18n, directives, labComponents, vuetifyAppOptions) {
188
188
  const {
189
189
  directives: _directives,
190
190
  date: _date,
191
191
  icons: _icons,
192
+ components,
193
+ aliases,
192
194
  ...newVuetifyOptions
193
195
  } = vuetifyAppOptions;
194
196
  return {
@@ -200,53 +202,98 @@ function vuetifyConfigurationPlugin(isDev, directives, labComponents, vuetifyApp
200
202
  },
201
203
  async load(id) {
202
204
  if (id === RESOLVED_VIRTUAL_VUETIFY_CONFIGURATION) {
203
- const directivesResult = buildDirectives();
204
- const labComponentsResult = buildLabComponents();
205
- return `${directivesResult.imports}
206
- ${labComponentsResult.imports}
205
+ if (i18n && newVuetifyOptions.locale) {
206
+ delete newVuetifyOptions.locale.rtl;
207
+ delete newVuetifyOptions.locale.locale;
208
+ delete newVuetifyOptions.locale.fallback;
209
+ }
210
+ const result = buildConfiguration();
211
+ return `${result.imports}
207
212
 
208
213
  export const isDev = ${isDev}
209
214
  export function vuetifyConfiguration() {
210
- const options = ${JSON.stringify(newVuetifyOptions)}
211
- ${directivesResult.expression}
212
- ${labComponentsResult.expression}
215
+ const options = JSON.parse('${JSON.stringify(newVuetifyOptions)}')
216
+ ${result.directives}
217
+ ${result.aliases}
218
+ ${result.components}
213
219
  return options
214
220
  }
215
221
  `;
216
222
  }
217
223
  }
218
224
  };
219
- function buildDirectives() {
220
- if (!directives)
221
- return { imports: "", expression: "" };
225
+ function buildConfiguration() {
226
+ const dateOptions = vuetifyAppOptions.date;
227
+ const config = {
228
+ directives: "",
229
+ imports: [],
230
+ aliasEntries: [],
231
+ aliases: aliases || {},
232
+ components: new Set(components ? Array.isArray(components) ? components : [components] : []),
233
+ labComponents: /* @__PURE__ */ new Set()
234
+ };
222
235
  if (typeof directives === "boolean") {
223
- return {
224
- imports: "import * as directives from 'vuetify/directives'",
225
- expression: "options.directives = directives"
226
- };
236
+ config.imports.push("import * as directives from 'vuetify/directives'");
237
+ config.directives = "options.directives = directives";
227
238
  } else {
228
- return {
229
- imports: `${directives.map((d) => `import { ${d} } from 'vuetify/directives/${d}'`).join("\n")}`,
230
- expression: `options.directives = {${directives.join(",")}}`
231
- };
239
+ const useDirectives = Array.isArray(directives) ? directives : [directives];
240
+ config.imports.push(useDirectives.map((d) => `import { ${d} } from 'vuetify/directives/${d}'`).join("\n"));
241
+ config.directives = `options.directives = {${useDirectives.join(",")}}`;
232
242
  }
233
- }
234
- function buildLabComponents() {
235
- const dateOptions = vuetifyAppOptions.date;
236
- if (!labComponents && !dateOptions)
237
- return { imports: "", expression: "" };
238
- if (typeof labComponents === "boolean") {
239
- return {
240
- imports: "import * as labsComponents from 'vuetify/labs/components'",
241
- expression: "options.components = labsComponents"
242
- };
243
- } else {
244
- const components = [...new Set(dateOptions ? ["VDatePicker", ...labComponents] : labComponents)];
245
- return {
246
- imports: `${components.map((d) => `import { ${d} } from 'vuetify/labs/${d}'`).join("\n")}`,
247
- expression: `options.components = {${components.join(",")}}`
248
- };
243
+ config.imports.push(...Array.from(config.components).map((c) => `import {${c}} from 'vuetify/components/${c}'`));
244
+ Object.entries(config.aliases).forEach(([key, component]) => {
245
+ if (!config.components.has(component)) {
246
+ config.components.add(component);
247
+ config.imports.push(`import {${component}} from 'vuetify/components/${component}'`);
248
+ }
249
+ config.aliasEntries.push(`'${key}': ${component}`);
250
+ });
251
+ let addDatePicker = true;
252
+ if (labComponents) {
253
+ if (typeof labComponents === "boolean") {
254
+ config.imports.push("import * as labsComponents from 'vuetify/labs/components'");
255
+ config.labComponents.add("*");
256
+ addDatePicker = false;
257
+ } else if (Array.isArray(labComponents)) {
258
+ labComponents.forEach((labComponent) => {
259
+ if (!config.labComponents.has(labComponent)) {
260
+ config.labComponents.add(labComponent);
261
+ config.imports.push(`import {${labComponent}} from 'vuetify/labs/${labComponent}'`);
262
+ }
263
+ });
264
+ addDatePicker = !config.labComponents.has("VDatePicker");
265
+ } else {
266
+ config.imports.push(`import {${labComponents}} from 'vuetify/labs/${labComponents}'`);
267
+ config.labComponents.add(labComponents);
268
+ addDatePicker = labComponents !== "VDatePicker";
269
+ }
249
270
  }
271
+ if (dateOptions && addDatePicker) {
272
+ config.imports.push("import {VDatePicker} from 'vuetify/labs/VDatePicker'");
273
+ config.labComponents.add("VDatePicker");
274
+ }
275
+ let componentsEntry = "";
276
+ if (config.components.size) {
277
+ if (config.labComponents.size) {
278
+ if (config.labComponents.has("*"))
279
+ componentsEntry = `options.components = {${Array.from(config.components).join(",")},...labsComponents}`;
280
+ else
281
+ componentsEntry = `options.components = {${Array.from(config.components).join(",")},${Array.from(config.labComponents).join(",")}}`;
282
+ } else {
283
+ componentsEntry = `options.components = {${Array.from(config.components).join(",")}}`;
284
+ }
285
+ } else if (config.labComponents.size) {
286
+ if (config.labComponents.has("*"))
287
+ componentsEntry = "options.components = {...labsComponents}";
288
+ else
289
+ componentsEntry = `options.components = {${Array.from(config.labComponents).join(",")}}`;
290
+ }
291
+ return {
292
+ imports: config.imports.length ? config.imports.join("\n") : "",
293
+ components: componentsEntry,
294
+ aliases: config.aliasEntries.length ? `options.aliases = {${config.aliasEntries.join(",")}}` : "",
295
+ directives: config.directives
296
+ };
250
297
  }
251
298
  }
252
299
 
@@ -267,7 +314,7 @@ export const isDev = ${isDev}
267
314
  export const i18n = ${i18n}
268
315
  export const adapter = '${dateAdapter}'
269
316
  export function dateConfiguration() {
270
- const options = ${JSON.stringify(newDateOptions)}
317
+ const options = JSON.parse('${JSON.stringify(newDateOptions)}')
271
318
  ${buildAdapter()}
272
319
  return options
273
320
  }
@@ -297,15 +344,25 @@ const iconsCDN = {
297
344
  fa: "https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@latest/css/all.min.css",
298
345
  fa4: "https://cdn.jsdelivr.net/npm/font-awesome@4.x/css/font-awesome.min.css"
299
346
  };
347
+ const disabledResolvedIcons = Object.freeze({
348
+ enabled: false,
349
+ imports: [],
350
+ aliases: [],
351
+ sets: [],
352
+ cdn: [],
353
+ local: [],
354
+ svg: {}
355
+ });
300
356
  function prepareIcons(logger, vuetifyOptions) {
301
357
  if (vuetifyOptions.icons === false)
302
- return { enabled: false };
303
- vuetifyOptions.icons = vuetifyOptions.icons ?? {};
304
- let { defaultSet = "mdi", sets } = vuetifyOptions.icons;
358
+ return disabledResolvedIcons;
359
+ const icons = vuetifyOptions.icons || {};
360
+ let { defaultSet = "mdi", sets } = icons;
305
361
  if (!defaultSet)
306
- defaultSet = vuetifyOptions.icons.defaultSet = "mdi";
307
- if (!sets)
362
+ defaultSet = icons.defaultSet = "mdi";
363
+ if (!sets && defaultSet !== "mdi-svg" && defaultSet !== "fa-svg" && defaultSet !== "custom")
308
364
  sets = [{ name: defaultSet || "mdi" }];
365
+ sets = sets ? convertFontSetsToObjectNotation(sets) : void 0;
309
366
  const resolvedIcons = {
310
367
  enabled: true,
311
368
  defaultSet,
@@ -318,30 +375,33 @@ function prepareIcons(logger, vuetifyOptions) {
318
375
  mdi: false
319
376
  }
320
377
  };
321
- sets.filter((s) => cssFonts.includes(s.name)).map((s) => s.name).forEach((name) => {
322
- resolvedIcons.imports.push(`import {${name === defaultSet ? "aliases," : ""}${name}} from 'vuetify/iconsets/${name}'`);
323
- resolvedIcons.sets.push(name);
324
- if (isPackageExists(iconsPackageNames[name].name))
325
- resolvedIcons.local.push(iconsPackageNames[name].css);
326
- else
327
- resolvedIcons.cdn.push(iconsCDN[name]);
328
- });
329
- let faSvg = vuetifyOptions.icons.svg?.fa;
378
+ if (sets) {
379
+ sets.filter((s) => cssFonts.includes(s.name)).map((s) => s.name).forEach((name) => {
380
+ resolvedIcons.imports.push(`import {${name === defaultSet ? "aliases," : ""}${name}} from 'vuetify/iconsets/${name}'`);
381
+ resolvedIcons.sets.push(name);
382
+ if (isPackageExists(iconsPackageNames[name].name))
383
+ resolvedIcons.local.push(iconsPackageNames[name].css);
384
+ else
385
+ resolvedIcons.cdn.push(iconsCDN[name]);
386
+ });
387
+ }
388
+ let faSvg = icons.svg?.fa;
330
389
  if (defaultSet === "fa-svg" || faSvg) {
390
+ if (!faSvg)
391
+ faSvg = {};
331
392
  let faSvgExists = isPackageExists("@fortawesome/fontawesome-svg-core");
332
393
  if (!faSvgExists)
333
394
  logger.warn("Missing @fortawesome/fontawesome-svg-core dependency, install it!");
334
395
  faSvgExists = isPackageExists("@fortawesome/vue-fontawesome");
335
396
  if (faSvgExists) {
336
- if (!faSvg?.libraries?.length) {
337
- faSvg = faSvg || {};
397
+ if (!faSvg.libraries?.length)
338
398
  faSvg.libraries = [[false, "fas", "@fortawesome/free-solid-svg-icons"]];
339
- }
340
399
  for (const p in faSvg.libraries) {
341
400
  const [_defaultExport, _name, library] = faSvg.libraries[p];
342
- faSvgExists = isPackageExists(library);
343
- if (!faSvgExists)
401
+ if (!isPackageExists(library)) {
402
+ faSvgExists = false;
344
403
  logger.warn(`Missing library ${library} dependency, install it!`);
404
+ }
345
405
  }
346
406
  } else {
347
407
  logger.warn("Missing @fortawesome/vue-fontawesome dependency, install it!");
@@ -361,8 +421,10 @@ function prepareIcons(logger, vuetifyOptions) {
361
421
  resolvedIcons.defaultSet = "fa";
362
422
  }
363
423
  }
364
- const mdiSvg = vuetifyOptions.icons.svg?.mdi;
424
+ let mdiSvg = icons.svg?.mdi;
365
425
  if (defaultSet === "mdi-svg" || mdiSvg) {
426
+ if (!mdiSvg)
427
+ mdiSvg = {};
366
428
  const mdiSvgExists = isPackageExists("@mdi/js");
367
429
  if (mdiSvgExists) {
368
430
  resolvedIcons.svg.mdi = true;
@@ -383,10 +445,24 @@ function prepareIcons(logger, vuetifyOptions) {
383
445
  }
384
446
  if (!resolvedIcons.local?.length && !resolvedIcons.cdn?.length && !resolvedIcons.svg?.mdi && !resolvedIcons.svg?.fa?.length) {
385
447
  logger.warn("No icons found, icons disabled!");
386
- return { enabled: false };
448
+ return disabledResolvedIcons;
387
449
  }
388
450
  return resolvedIcons;
389
451
  }
452
+ function convertFontSetsToObjectNotation(sets) {
453
+ const result = [];
454
+ if (typeof sets === "string") {
455
+ result.push({ name: sets });
456
+ } else {
457
+ for (const set of sets) {
458
+ if (typeof set === "string")
459
+ result.push({ name: set });
460
+ else
461
+ result.push(set);
462
+ }
463
+ }
464
+ return result;
465
+ }
390
466
 
391
467
  function vuetifyIconsPlugin(isDev, resolvedIcons) {
392
468
  const iconsOptionsPromise = prepareIcons();
@@ -505,6 +581,7 @@ const module = defineNuxtModule({
505
581
  const vuetifyAppOptions = defu(vOptions, {
506
582
  ssr: isSSR
507
583
  });
584
+ cleanupBlueprint(vuetifyAppOptions);
508
585
  const { styles } = moduleOptions;
509
586
  const i18n = hasNuxtModule("@nuxtjs/i18n", nuxt);
510
587
  let dateAdapter;
@@ -518,7 +595,7 @@ const module = defineNuxtModule({
518
595
  if (adapter === "vuetify" || adapter === "custom") {
519
596
  dateAdapter = adapter;
520
597
  } else {
521
- if (date.find((d) => d[0] === adapter) === void 0)
598
+ if (date.find((d) => d === adapter) === void 0)
522
599
  logger.warn(`Ignoring Vuetify Date configuration, date adapter "@date-io/${adapter}" not installed!`);
523
600
  else
524
601
  dateAdapter = adapter;
@@ -559,8 +636,8 @@ const module = defineNuxtModule({
559
636
  nuxt.hook("prepare:types", ({ references }) => {
560
637
  references.push({ types: "vuetify-nuxt-module/configuration" });
561
638
  });
562
- const vuetifyBase = resolveVuetifyBase();
563
639
  nuxt.hook("components:extend", async (c) => {
640
+ const vuetifyBase = resolveVuetifyBase();
564
641
  const { components } = JSON.parse(await readFile(resolver.resolve(vuetifyBase, "dist/json/importMap.json"), "utf-8"));
565
642
  Object.keys(components).forEach((component) => {
566
643
  const from = components[component].from;
@@ -568,7 +645,6 @@ const module = defineNuxtModule({
568
645
  pascalName: component,
569
646
  kebabName: toKebabCase(component),
570
647
  export: component,
571
- // pointing to the mjs file, links will not work: there is d.mts file for each component
572
648
  filePath: `${resolver.resolve(vuetifyBase, `lib/${from}`)}`,
573
649
  shortPath: `components/${from}`,
574
650
  chunkName: toKebabCase(component),
@@ -600,6 +676,7 @@ const module = defineNuxtModule({
600
676
  viteInlineConfig.plugins.push(vuetifyStylesPlugin({ styles }, logger));
601
677
  viteInlineConfig.plugins.push(vuetifyConfigurationPlugin(
602
678
  nuxt.options.dev,
679
+ i18n,
603
680
  directives,
604
681
  labComponents,
605
682
  vuetifyAppOptions
@@ -647,5 +724,17 @@ function detectDate() {
647
724
  const result = [];
648
725
  return result;
649
726
  }
727
+ function cleanupBlueprint(vuetifyOptions) {
728
+ const blueprint = vuetifyOptions.blueprint;
729
+ if (blueprint) {
730
+ delete blueprint.ssr;
731
+ delete blueprint.components;
732
+ delete blueprint.directives;
733
+ delete blueprint.locale;
734
+ delete blueprint.date;
735
+ delete blueprint.icons;
736
+ vuetifyOptions.blueprint = blueprint;
737
+ }
738
+ }
650
739
 
651
740
  export { module as default };
@@ -7,8 +7,7 @@ import {
7
7
  toRaw,
8
8
  watch
9
9
  } from "vue";
10
- import { toKebabCase } from "../../utils";
11
- import { useI18n } from "#imports";
10
+ import { useI18n } from "vue-i18n";
12
11
  import { useNuxtApp } from "#app";
13
12
  export function createAdapter(vuetifyOptions) {
14
13
  vuetifyOptions.locale = {};
@@ -60,6 +59,9 @@ function useToggleScope(source, fn) {
60
59
  scope?.stop();
61
60
  });
62
61
  }
62
+ function toKebabCase(str = "") {
63
+ return str.replace(/[^a-z]/gi, "-").replace(/\B([A-Z])/g, "-$1").toLowerCase();
64
+ }
63
65
  function useProxiedModel(props, prop, defaultValue, transformIn = (v) => v, transformOut = (v) => v) {
64
66
  const vm = getCurrentInstance("useProxiedModel");
65
67
  const internal = ref(props[prop] !== void 0 ? props[prop] : defaultValue);
package/dist/types.d.ts CHANGED
@@ -12,4 +12,4 @@ declare module 'nuxt/schema' {
12
12
  }
13
13
 
14
14
 
15
- export { BooleanOrArrayString, DateAdapter, DateOptions, FontAwesomeSvgIconSet, FontIconSet, IconSet, IconSetName, IconsOptions, JSSVGIconSet, 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, default } from './module'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vuetify-nuxt-module",
3
3
  "type": "module",
4
- "version": "0.2.4",
4
+ "version": "0.4.0",
5
5
  "packageManager": "pnpm@8.6.6",
6
6
  "description": "Zero-Config Nuxt Module for Vuetify ",
7
7
  "author": "userquin <userquin@gmail.com>",