vuetify-nuxt-module 0.2.4 → 0.3.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 +7 -7
- package/dist/module.d.ts +16 -12
- package/dist/module.json +1 -1
- package/dist/module.mjs +58 -28
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -175,7 +175,7 @@ vuetify: {
|
|
|
175
175
|
|
|
176
176
|
### fa-svg
|
|
177
177
|
|
|
178
|
-
You only need to add `@fortawesome/fontawesome-svg-core`, `@fortawesome/vue-fontawesome
|
|
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:
|
|
179
179
|
```ts
|
|
180
180
|
vuetify: {
|
|
181
181
|
vuetifyOptions: {
|
|
@@ -194,7 +194,7 @@ vuetify: {
|
|
|
194
194
|
defaultSet: 'fa-svg',
|
|
195
195
|
svg: {
|
|
196
196
|
fa: {
|
|
197
|
-
libraries: [/* default export? */ false, /* export name */ 'fas', /*
|
|
197
|
+
libraries: [/* default export? */ false, /* export name */ 'fas', /* library */ '@fortawesome/free-solid-svg-icons']
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
}
|
|
@@ -210,7 +210,7 @@ vuetify: {
|
|
|
210
210
|
vuetifyOptions: {
|
|
211
211
|
icons: {
|
|
212
212
|
defaultSet: 'mdi'
|
|
213
|
-
sets: [
|
|
213
|
+
sets: ['mdi', 'fa']
|
|
214
214
|
}
|
|
215
215
|
}
|
|
216
216
|
}
|
|
@@ -248,7 +248,7 @@ If you want to use a custom date adapter, you can configure it using `vuetifyOpt
|
|
|
248
248
|
import { adapter, dateConfiguration, i18n } from 'virtual:vuetify-date-configuration'
|
|
249
249
|
```
|
|
250
250
|
|
|
251
|
-
Check out [vuetify-date](
|
|
251
|
+
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
252
|
|
|
253
253
|
## ⚙️ Auto-Import Vuetify Composables
|
|
254
254
|
|
|
@@ -278,10 +278,10 @@ If you are using another composables that collide with the Vuetify ones, enable
|
|
|
278
278
|
|
|
279
279
|
## 👀 Full config
|
|
280
280
|
|
|
281
|
-
Check out the type declaration [src/types.ts](
|
|
281
|
+
Check out the type declaration [src/types.ts](https://github.com/userquin/vuetify-nuxt-module/blob/main/src/types.ts).
|
|
282
282
|
|
|
283
|
-
The virtual modules can be found in [configuration.d.ts](
|
|
283
|
+
The virtual modules can be found in [configuration.d.ts](https://github.com/userquin/vuetify-nuxt-module/blob/main/configuration.d.ts) file.
|
|
284
284
|
|
|
285
285
|
## 📄 License
|
|
286
286
|
|
|
287
|
-
[MIT](
|
|
287
|
+
[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,9 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
import * as vuetify from 'vuetify';
|
|
3
3
|
import { VuetifyOptions } from 'vuetify';
|
|
4
|
+
import * as vuetify_directives from 'vuetify/directives';
|
|
5
|
+
import * as vuetify_labs_components from 'vuetify/labs/components';
|
|
4
6
|
|
|
5
|
-
type BooleanOrArrayString = boolean | string[];
|
|
6
7
|
type DateAdapter = 'vuetify' | 'date-fns' | 'moment' | 'luxon' | 'dayjs' | 'js-joda' | 'date-fns-jalali' | 'jalaali' | 'hijri' | 'custom';
|
|
7
8
|
/**
|
|
8
9
|
* Date configuration.
|
|
@@ -30,16 +31,14 @@ interface DateOptions {
|
|
|
30
31
|
*
|
|
31
32
|
* When `@nuxtjs/i18n` Nuxt module is present, this option will be ignored, locales will be extracted from the available locales.
|
|
32
33
|
*/
|
|
33
|
-
locale
|
|
34
|
+
locale?: Record<string, any>;
|
|
34
35
|
}
|
|
35
36
|
type IconSetName = 'mdi' | 'fa' | 'fa4' | 'md' | 'mdi-svg' | 'fa-svg' | 'custom';
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
interface JSSVGIconSet extends IconSet {
|
|
37
|
+
type IconFontName = 'mdi' | 'fa' | 'fa4' | 'md';
|
|
38
|
+
interface JSSVGIconSet {
|
|
40
39
|
aliases?: Record<string, string>;
|
|
41
40
|
}
|
|
42
|
-
interface FontAwesomeSvgIconSet
|
|
41
|
+
interface FontAwesomeSvgIconSet {
|
|
43
42
|
/**
|
|
44
43
|
* The libraries to import and register with the corresponding name.
|
|
45
44
|
*
|
|
@@ -53,7 +52,8 @@ interface FontAwesomeSvgIconSet extends IconSet {
|
|
|
53
52
|
*/
|
|
54
53
|
libraries?: [defaultExport: boolean, name: string, library: string][];
|
|
55
54
|
}
|
|
56
|
-
interface FontIconSet
|
|
55
|
+
interface FontIconSet {
|
|
56
|
+
name: IconFontName;
|
|
57
57
|
/**
|
|
58
58
|
* Use CDN?
|
|
59
59
|
*
|
|
@@ -68,12 +68,16 @@ interface FontIconSet extends IconSet {
|
|
|
68
68
|
}
|
|
69
69
|
interface IconsOptions {
|
|
70
70
|
defaultSet: IconSetName;
|
|
71
|
-
sets?: FontIconSet[];
|
|
71
|
+
sets?: IconFontName | IconFontName[] | FontIconSet[];
|
|
72
72
|
svg?: {
|
|
73
73
|
mdi?: JSSVGIconSet;
|
|
74
74
|
fa?: FontAwesomeSvgIconSet;
|
|
75
75
|
};
|
|
76
76
|
}
|
|
77
|
+
type LabComponentName = keyof typeof vuetify_labs_components;
|
|
78
|
+
type LabComponents = boolean | LabComponentName | LabComponentName[];
|
|
79
|
+
type DirectiveName = keyof typeof vuetify_directives;
|
|
80
|
+
type Directives = boolean | DirectiveName | DirectiveName[];
|
|
77
81
|
interface VOptions extends Partial<Omit<VuetifyOptions, 'ssr' | 'directives' | 'locale' | 'date' | 'icons'>> {
|
|
78
82
|
/**
|
|
79
83
|
* Include the lab components?
|
|
@@ -86,7 +90,7 @@ interface VOptions extends Partial<Omit<VuetifyOptions, 'ssr' | 'directives' | '
|
|
|
86
90
|
*
|
|
87
91
|
* @default false
|
|
88
92
|
*/
|
|
89
|
-
labComponents?:
|
|
93
|
+
labComponents?: LabComponents;
|
|
90
94
|
/**
|
|
91
95
|
* Include the directives?
|
|
92
96
|
*
|
|
@@ -96,7 +100,7 @@ interface VOptions extends Partial<Omit<VuetifyOptions, 'ssr' | 'directives' | '
|
|
|
96
100
|
*
|
|
97
101
|
* @default false
|
|
98
102
|
*/
|
|
99
|
-
directives?:
|
|
103
|
+
directives?: Directives;
|
|
100
104
|
/**
|
|
101
105
|
* Date configuration.
|
|
102
106
|
*
|
|
@@ -163,4 +167,4 @@ declare module '#app' {
|
|
|
163
167
|
|
|
164
168
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
|
|
165
169
|
|
|
166
|
-
export {
|
|
170
|
+
export { DateAdapter, DateOptions, DirectiveName, Directives, FontAwesomeSvgIconSet, FontIconSet, IconFontName, IconSetName, IconsOptions, JSSVGIconSet, LabComponentName, LabComponents, MOptions, ModuleOptions, VOptions, _default as default };
|
package/dist/module.json
CHANGED
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.
|
|
9
|
+
const version = "0.3.0";
|
|
10
10
|
|
|
11
11
|
function isSubdir(root, test) {
|
|
12
12
|
const relative$1 = relative(root, test);
|
|
@@ -225,9 +225,10 @@ export function vuetifyConfiguration() {
|
|
|
225
225
|
expression: "options.directives = directives"
|
|
226
226
|
};
|
|
227
227
|
} else {
|
|
228
|
+
const useDirectives = Array.isArray(directives) ? directives : [directives];
|
|
228
229
|
return {
|
|
229
|
-
imports: `${
|
|
230
|
-
expression: `options.directives = {${
|
|
230
|
+
imports: `${useDirectives.map((d) => `import { ${d} } from 'vuetify/directives/${d}'`).join("\n")}`,
|
|
231
|
+
expression: `options.directives = {${useDirectives.join(",")}}`
|
|
231
232
|
};
|
|
232
233
|
}
|
|
233
234
|
}
|
|
@@ -241,7 +242,8 @@ export function vuetifyConfiguration() {
|
|
|
241
242
|
expression: "options.components = labsComponents"
|
|
242
243
|
};
|
|
243
244
|
} else {
|
|
244
|
-
const
|
|
245
|
+
const useComponents = Array.isArray(labComponents) ? labComponents : [labComponents];
|
|
246
|
+
const components = [...new Set(dateOptions ? ["VDatePicker", ...useComponents] : useComponents)];
|
|
245
247
|
return {
|
|
246
248
|
imports: `${components.map((d) => `import { ${d} } from 'vuetify/labs/${d}'`).join("\n")}`,
|
|
247
249
|
expression: `options.components = {${components.join(",")}}`
|
|
@@ -297,15 +299,25 @@ const iconsCDN = {
|
|
|
297
299
|
fa: "https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@latest/css/all.min.css",
|
|
298
300
|
fa4: "https://cdn.jsdelivr.net/npm/font-awesome@4.x/css/font-awesome.min.css"
|
|
299
301
|
};
|
|
302
|
+
const disabledResolvedIcons = Object.freeze({
|
|
303
|
+
enabled: false,
|
|
304
|
+
imports: [],
|
|
305
|
+
aliases: [],
|
|
306
|
+
sets: [],
|
|
307
|
+
cdn: [],
|
|
308
|
+
local: [],
|
|
309
|
+
svg: {}
|
|
310
|
+
});
|
|
300
311
|
function prepareIcons(logger, vuetifyOptions) {
|
|
301
312
|
if (vuetifyOptions.icons === false)
|
|
302
|
-
return
|
|
303
|
-
|
|
304
|
-
let { defaultSet = "mdi", sets } =
|
|
313
|
+
return disabledResolvedIcons;
|
|
314
|
+
const icons = vuetifyOptions.icons || {};
|
|
315
|
+
let { defaultSet = "mdi", sets } = icons;
|
|
305
316
|
if (!defaultSet)
|
|
306
|
-
defaultSet =
|
|
307
|
-
if (!sets)
|
|
317
|
+
defaultSet = icons.defaultSet = "mdi";
|
|
318
|
+
if (!sets && defaultSet !== "mdi-svg" && defaultSet !== "fa-svg" && defaultSet !== "custom")
|
|
308
319
|
sets = [{ name: defaultSet || "mdi" }];
|
|
320
|
+
sets = sets ? convertFontSetsToObjectNotation(sets) : void 0;
|
|
309
321
|
const resolvedIcons = {
|
|
310
322
|
enabled: true,
|
|
311
323
|
defaultSet,
|
|
@@ -318,30 +330,33 @@ function prepareIcons(logger, vuetifyOptions) {
|
|
|
318
330
|
mdi: false
|
|
319
331
|
}
|
|
320
332
|
};
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
333
|
+
if (sets) {
|
|
334
|
+
sets.filter((s) => cssFonts.includes(s.name)).map((s) => s.name).forEach((name) => {
|
|
335
|
+
resolvedIcons.imports.push(`import {${name === defaultSet ? "aliases," : ""}${name}} from 'vuetify/iconsets/${name}'`);
|
|
336
|
+
resolvedIcons.sets.push(name);
|
|
337
|
+
if (isPackageExists(iconsPackageNames[name].name))
|
|
338
|
+
resolvedIcons.local.push(iconsPackageNames[name].css);
|
|
339
|
+
else
|
|
340
|
+
resolvedIcons.cdn.push(iconsCDN[name]);
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
let faSvg = icons.svg?.fa;
|
|
330
344
|
if (defaultSet === "fa-svg" || faSvg) {
|
|
345
|
+
if (!faSvg)
|
|
346
|
+
faSvg = {};
|
|
331
347
|
let faSvgExists = isPackageExists("@fortawesome/fontawesome-svg-core");
|
|
332
348
|
if (!faSvgExists)
|
|
333
349
|
logger.warn("Missing @fortawesome/fontawesome-svg-core dependency, install it!");
|
|
334
350
|
faSvgExists = isPackageExists("@fortawesome/vue-fontawesome");
|
|
335
351
|
if (faSvgExists) {
|
|
336
|
-
if (!faSvg
|
|
337
|
-
faSvg = faSvg || {};
|
|
352
|
+
if (!faSvg.libraries?.length)
|
|
338
353
|
faSvg.libraries = [[false, "fas", "@fortawesome/free-solid-svg-icons"]];
|
|
339
|
-
}
|
|
340
354
|
for (const p in faSvg.libraries) {
|
|
341
355
|
const [_defaultExport, _name, library] = faSvg.libraries[p];
|
|
342
|
-
|
|
343
|
-
|
|
356
|
+
if (!isPackageExists(library)) {
|
|
357
|
+
faSvgExists = false;
|
|
344
358
|
logger.warn(`Missing library ${library} dependency, install it!`);
|
|
359
|
+
}
|
|
345
360
|
}
|
|
346
361
|
} else {
|
|
347
362
|
logger.warn("Missing @fortawesome/vue-fontawesome dependency, install it!");
|
|
@@ -361,8 +376,10 @@ function prepareIcons(logger, vuetifyOptions) {
|
|
|
361
376
|
resolvedIcons.defaultSet = "fa";
|
|
362
377
|
}
|
|
363
378
|
}
|
|
364
|
-
|
|
379
|
+
let mdiSvg = icons.svg?.mdi;
|
|
365
380
|
if (defaultSet === "mdi-svg" || mdiSvg) {
|
|
381
|
+
if (!mdiSvg)
|
|
382
|
+
mdiSvg = {};
|
|
366
383
|
const mdiSvgExists = isPackageExists("@mdi/js");
|
|
367
384
|
if (mdiSvgExists) {
|
|
368
385
|
resolvedIcons.svg.mdi = true;
|
|
@@ -383,10 +400,24 @@ function prepareIcons(logger, vuetifyOptions) {
|
|
|
383
400
|
}
|
|
384
401
|
if (!resolvedIcons.local?.length && !resolvedIcons.cdn?.length && !resolvedIcons.svg?.mdi && !resolvedIcons.svg?.fa?.length) {
|
|
385
402
|
logger.warn("No icons found, icons disabled!");
|
|
386
|
-
return
|
|
403
|
+
return disabledResolvedIcons;
|
|
387
404
|
}
|
|
388
405
|
return resolvedIcons;
|
|
389
406
|
}
|
|
407
|
+
function convertFontSetsToObjectNotation(sets) {
|
|
408
|
+
const result = [];
|
|
409
|
+
if (typeof sets === "string") {
|
|
410
|
+
result.push({ name: sets });
|
|
411
|
+
} else {
|
|
412
|
+
for (const set of sets) {
|
|
413
|
+
if (typeof set === "string")
|
|
414
|
+
result.push({ name: set });
|
|
415
|
+
else
|
|
416
|
+
result.push(set);
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
return result;
|
|
420
|
+
}
|
|
390
421
|
|
|
391
422
|
function vuetifyIconsPlugin(isDev, resolvedIcons) {
|
|
392
423
|
const iconsOptionsPromise = prepareIcons();
|
|
@@ -518,7 +549,7 @@ const module = defineNuxtModule({
|
|
|
518
549
|
if (adapter === "vuetify" || adapter === "custom") {
|
|
519
550
|
dateAdapter = adapter;
|
|
520
551
|
} else {
|
|
521
|
-
if (date.find((d) => d
|
|
552
|
+
if (date.find((d) => d === adapter) === void 0)
|
|
522
553
|
logger.warn(`Ignoring Vuetify Date configuration, date adapter "@date-io/${adapter}" not installed!`);
|
|
523
554
|
else
|
|
524
555
|
dateAdapter = adapter;
|
|
@@ -559,8 +590,8 @@ const module = defineNuxtModule({
|
|
|
559
590
|
nuxt.hook("prepare:types", ({ references }) => {
|
|
560
591
|
references.push({ types: "vuetify-nuxt-module/configuration" });
|
|
561
592
|
});
|
|
562
|
-
const vuetifyBase = resolveVuetifyBase();
|
|
563
593
|
nuxt.hook("components:extend", async (c) => {
|
|
594
|
+
const vuetifyBase = resolveVuetifyBase();
|
|
564
595
|
const { components } = JSON.parse(await readFile(resolver.resolve(vuetifyBase, "dist/json/importMap.json"), "utf-8"));
|
|
565
596
|
Object.keys(components).forEach((component) => {
|
|
566
597
|
const from = components[component].from;
|
|
@@ -568,7 +599,6 @@ const module = defineNuxtModule({
|
|
|
568
599
|
pascalName: component,
|
|
569
600
|
kebabName: toKebabCase(component),
|
|
570
601
|
export: component,
|
|
571
|
-
// pointing to the mjs file, links will not work: there is d.mts file for each component
|
|
572
602
|
filePath: `${resolver.resolve(vuetifyBase, `lib/${from}`)}`,
|
|
573
603
|
shortPath: `components/${from}`,
|
|
574
604
|
chunkName: toKebabCase(component),
|
package/dist/types.d.ts
CHANGED
|
@@ -12,4 +12,4 @@ declare module 'nuxt/schema' {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
|
|
15
|
-
export {
|
|
15
|
+
export { DateAdapter, DateOptions, DirectiveName, Directives, FontAwesomeSvgIconSet, FontIconSet, IconFontName, IconSetName, IconsOptions, JSSVGIconSet, LabComponentName, LabComponents, MOptions, ModuleOptions, VOptions, default } from './module'
|