vuetify-nuxt-module 0.3.0 → 0.4.1
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 +37 -3
- package/dist/module.d.ts +27 -6
- package/dist/module.json +1 -1
- package/dist/module.mjs +102 -41
- package/dist/runtime/plugins/i18n.mjs +4 -2
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
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
|
|
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:
|
|
@@ -194,7 +222,7 @@ vuetify: {
|
|
|
194
222
|
defaultSet: 'fa-svg',
|
|
195
223
|
svg: {
|
|
196
224
|
fa: {
|
|
197
|
-
libraries: [/* default export? */ false, /* export name */ 'fas', /* library */ '@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
|
}
|
|
@@ -274,7 +302,13 @@ If you are using another composables that collide with the Vuetify ones, enable
|
|
|
274
302
|
|
|
275
303
|
## 🎨 Vuetify Blueprints
|
|
276
304
|
|
|
277
|
-
|
|
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
|
|
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
|
-
import { VuetifyOptions } from 'vuetify';
|
|
4
|
-
import * as vuetify_directives from 'vuetify/directives';
|
|
3
|
+
import { VuetifyOptions, LocaleOptions, RtlOptions } from 'vuetify';
|
|
5
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';
|
|
6
7
|
|
|
7
8
|
type DateAdapter = 'vuetify' | 'date-fns' | 'moment' | 'luxon' | 'dayjs' | 'js-joda' | 'date-fns-jalali' | 'jalaali' | 'hijri' | 'custom';
|
|
8
9
|
/**
|
|
@@ -74,11 +75,31 @@ interface IconsOptions {
|
|
|
74
75
|
fa?: FontAwesomeSvgIconSet;
|
|
75
76
|
};
|
|
76
77
|
}
|
|
77
|
-
type
|
|
78
|
-
type
|
|
78
|
+
type ComponentName = keyof typeof vuetify_components;
|
|
79
|
+
type Components = false | ComponentName | ComponentName[];
|
|
79
80
|
type DirectiveName = keyof typeof vuetify_directives;
|
|
80
81
|
type Directives = boolean | DirectiveName | DirectiveName[];
|
|
81
|
-
|
|
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;
|
|
82
103
|
/**
|
|
83
104
|
* Include the lab components?
|
|
84
105
|
*
|
|
@@ -167,4 +188,4 @@ declare module '#app' {
|
|
|
167
188
|
|
|
168
189
|
declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
|
|
169
190
|
|
|
170
|
-
export { DateAdapter, DateOptions, DirectiveName, Directives, FontAwesomeSvgIconSet, FontIconSet, IconFontName, IconSetName, IconsOptions, JSSVGIconSet, LabComponentName, LabComponents, 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
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.4.1";
|
|
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,55 +202,100 @@ function vuetifyConfigurationPlugin(isDev, directives, labComponents, vuetifyApp
|
|
|
200
202
|
},
|
|
201
203
|
async load(id) {
|
|
202
204
|
if (id === RESOLVED_VIRTUAL_VUETIFY_CONFIGURATION) {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
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
|
-
${
|
|
212
|
-
${
|
|
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
|
|
220
|
-
if (!directives)
|
|
221
|
-
return { imports: "", expression: "" };
|
|
222
|
-
if (typeof directives === "boolean") {
|
|
223
|
-
return {
|
|
224
|
-
imports: "import * as directives from 'vuetify/directives'",
|
|
225
|
-
expression: "options.directives = directives"
|
|
226
|
-
};
|
|
227
|
-
} else {
|
|
228
|
-
const useDirectives = Array.isArray(directives) ? directives : [directives];
|
|
229
|
-
return {
|
|
230
|
-
imports: `${useDirectives.map((d) => `import { ${d} } from 'vuetify/directives/${d}'`).join("\n")}`,
|
|
231
|
-
expression: `options.directives = {${useDirectives.join(",")}}`
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
function buildLabComponents() {
|
|
225
|
+
function buildConfiguration() {
|
|
236
226
|
const dateOptions = vuetifyAppOptions.date;
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
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
|
+
};
|
|
235
|
+
if (directives) {
|
|
236
|
+
if (typeof directives === "boolean") {
|
|
237
|
+
config.imports.push("import * as directives from 'vuetify/directives'");
|
|
238
|
+
config.directives = "options.directives = directives";
|
|
239
|
+
} else {
|
|
240
|
+
const useDirectives = Array.isArray(directives) ? directives : [directives];
|
|
241
|
+
config.imports.push(useDirectives.map((d) => `import { ${d} } from 'vuetify/directives/${d}'`).join("\n"));
|
|
242
|
+
config.directives = `options.directives = {${useDirectives.join(",")}}`;
|
|
243
|
+
}
|
|
251
244
|
}
|
|
245
|
+
config.imports.push(...Array.from(config.components).map((c) => `import {${c}} from 'vuetify/components/${c}'`));
|
|
246
|
+
Object.entries(config.aliases).forEach(([key, component]) => {
|
|
247
|
+
if (!config.components.has(component)) {
|
|
248
|
+
config.components.add(component);
|
|
249
|
+
config.imports.push(`import {${component}} from 'vuetify/components/${component}'`);
|
|
250
|
+
}
|
|
251
|
+
config.aliasEntries.push(`'${key}': ${component}`);
|
|
252
|
+
});
|
|
253
|
+
let addDatePicker = true;
|
|
254
|
+
if (labComponents) {
|
|
255
|
+
if (typeof labComponents === "boolean") {
|
|
256
|
+
config.imports.push("import * as labsComponents from 'vuetify/labs/components'");
|
|
257
|
+
config.labComponents.add("*");
|
|
258
|
+
addDatePicker = false;
|
|
259
|
+
} else if (Array.isArray(labComponents)) {
|
|
260
|
+
labComponents.forEach((labComponent) => {
|
|
261
|
+
if (!config.labComponents.has(labComponent)) {
|
|
262
|
+
config.labComponents.add(labComponent);
|
|
263
|
+
config.imports.push(`import {${labComponent}} from 'vuetify/labs/${labComponent}'`);
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
addDatePicker = !config.labComponents.has("VDatePicker");
|
|
267
|
+
} else {
|
|
268
|
+
config.imports.push(`import {${labComponents}} from 'vuetify/labs/${labComponents}'`);
|
|
269
|
+
config.labComponents.add(labComponents);
|
|
270
|
+
addDatePicker = labComponents !== "VDatePicker";
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
if (dateOptions && addDatePicker) {
|
|
274
|
+
config.imports.push("import {VDatePicker} from 'vuetify/labs/VDatePicker'");
|
|
275
|
+
config.labComponents.add("VDatePicker");
|
|
276
|
+
}
|
|
277
|
+
let componentsEntry = "";
|
|
278
|
+
if (config.components.size) {
|
|
279
|
+
if (config.labComponents.size) {
|
|
280
|
+
if (config.labComponents.has("*"))
|
|
281
|
+
componentsEntry = `options.components = {${Array.from(config.components).join(",")},...labsComponents}`;
|
|
282
|
+
else
|
|
283
|
+
componentsEntry = `options.components = {${Array.from(config.components).join(",")},${Array.from(config.labComponents).join(",")}}`;
|
|
284
|
+
} else {
|
|
285
|
+
componentsEntry = `options.components = {${Array.from(config.components).join(",")}}`;
|
|
286
|
+
}
|
|
287
|
+
} else if (config.labComponents.size) {
|
|
288
|
+
if (config.labComponents.has("*"))
|
|
289
|
+
componentsEntry = "options.components = {...labsComponents}";
|
|
290
|
+
else
|
|
291
|
+
componentsEntry = `options.components = {${Array.from(config.labComponents).join(",")}}`;
|
|
292
|
+
}
|
|
293
|
+
return {
|
|
294
|
+
imports: config.imports.length ? config.imports.join("\n") : "",
|
|
295
|
+
components: componentsEntry,
|
|
296
|
+
aliases: config.aliasEntries.length ? `options.aliases = {${config.aliasEntries.join(",")}}` : "",
|
|
297
|
+
directives: config.directives
|
|
298
|
+
};
|
|
252
299
|
}
|
|
253
300
|
}
|
|
254
301
|
|
|
@@ -269,7 +316,7 @@ export const isDev = ${isDev}
|
|
|
269
316
|
export const i18n = ${i18n}
|
|
270
317
|
export const adapter = '${dateAdapter}'
|
|
271
318
|
export function dateConfiguration() {
|
|
272
|
-
const options = ${JSON.stringify(newDateOptions)}
|
|
319
|
+
const options = JSON.parse('${JSON.stringify(newDateOptions)}')
|
|
273
320
|
${buildAdapter()}
|
|
274
321
|
return options
|
|
275
322
|
}
|
|
@@ -536,6 +583,7 @@ const module = defineNuxtModule({
|
|
|
536
583
|
const vuetifyAppOptions = defu(vOptions, {
|
|
537
584
|
ssr: isSSR
|
|
538
585
|
});
|
|
586
|
+
cleanupBlueprint(vuetifyAppOptions);
|
|
539
587
|
const { styles } = moduleOptions;
|
|
540
588
|
const i18n = hasNuxtModule("@nuxtjs/i18n", nuxt);
|
|
541
589
|
let dateAdapter;
|
|
@@ -630,6 +678,7 @@ const module = defineNuxtModule({
|
|
|
630
678
|
viteInlineConfig.plugins.push(vuetifyStylesPlugin({ styles }, logger));
|
|
631
679
|
viteInlineConfig.plugins.push(vuetifyConfigurationPlugin(
|
|
632
680
|
nuxt.options.dev,
|
|
681
|
+
i18n,
|
|
633
682
|
directives,
|
|
634
683
|
labComponents,
|
|
635
684
|
vuetifyAppOptions
|
|
@@ -677,5 +726,17 @@ function detectDate() {
|
|
|
677
726
|
const result = [];
|
|
678
727
|
return result;
|
|
679
728
|
}
|
|
729
|
+
function cleanupBlueprint(vuetifyOptions) {
|
|
730
|
+
const blueprint = vuetifyOptions.blueprint;
|
|
731
|
+
if (blueprint) {
|
|
732
|
+
delete blueprint.ssr;
|
|
733
|
+
delete blueprint.components;
|
|
734
|
+
delete blueprint.directives;
|
|
735
|
+
delete blueprint.locale;
|
|
736
|
+
delete blueprint.date;
|
|
737
|
+
delete blueprint.icons;
|
|
738
|
+
vuetifyOptions.blueprint = blueprint;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
680
741
|
|
|
681
742
|
export { module as default };
|
|
@@ -7,8 +7,7 @@ import {
|
|
|
7
7
|
toRaw,
|
|
8
8
|
watch
|
|
9
9
|
} from "vue";
|
|
10
|
-
import {
|
|
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 { 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, default } from './module'
|