vuetify-nuxt-module 0.4.4 → 0.4.6
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 +5 -319
- package/dist/module.d.ts +15 -2
- package/dist/module.json +1 -1
- package/dist/module.mjs +86 -16
- package/dist/runtime/plugins/config.mjs +1 -0
- package/package.json +13 -2
package/README.md
CHANGED
|
@@ -13,11 +13,9 @@
|
|
|
13
13
|
<a href="https://www.npmjs.com/package/vuetify-nuxt-module" target="__blank">
|
|
14
14
|
<img alt="NPM Downloads" src="https://img.shields.io/npm/dm/vuetify-nuxt-module?color=476582&label=">
|
|
15
15
|
</a>
|
|
16
|
-
|
|
17
|
-
<a href="https://vite-pwa-org.netlify.app/frameworks/nuxt" target="__blank">
|
|
16
|
+
<a href="https://vuetify-nuxt-module.netlify.app/" target="__blank">
|
|
18
17
|
<img src="https://img.shields.io/static/v1?label=&message=docs%20%26%20guides&color=2e859c" alt="Docs & Guides">
|
|
19
18
|
</a>
|
|
20
|
-
-->
|
|
21
19
|
<br>
|
|
22
20
|
<a href="https://github.com/userquin/vuetify-nuxt-module" target="__blank">
|
|
23
21
|
<img alt="GitHub stars" src="https://img.shields.io/github/stars/userquin/vuetify-nuxt-module?style=social">
|
|
@@ -28,12 +26,14 @@
|
|
|
28
26
|
|
|
29
27
|
## 🚀 Features
|
|
30
28
|
|
|
29
|
+
- 📖 [**Documentation & guides**](https://vuetify-nuxt-module.netlify.app/)
|
|
31
30
|
- 👌 **Zero-Config**: sensible built-in default [Vuetify](https://vuetifyjs.com/) configuration for common use cases
|
|
32
31
|
- 🔌 **Extensible**: expose the ability to customize the Vuetify configuration via [Nuxt Plugin Hooks](https://nuxt.com/docs/guide/going-further/hooks#usage-with-plugins)
|
|
33
32
|
- ⚡ **Fully Tree Shakable**: by default, only the needed Vuetify components are imported
|
|
34
33
|
- 🛠️ **Versatile**: custom Vuetify [directives](https://vuetifyjs.com/en/getting-started/installation/#manual-steps) and [labs components](https://vuetifyjs.com/en/labs/introduction/) registration
|
|
35
34
|
- ✨ **Configurable Styles**: configure your variables using [Vuetify SASS Variables](https://vuetifyjs.com/en/features/sass-variables/)
|
|
36
35
|
- 💥 **SSR**: automatic SSR detection and configuration
|
|
36
|
+
- 🔥 **Pure CSS Icons**: no more font/js icons, use the new `unocsss-mdi` icon set or build your own with UnoCSS Preset Icons
|
|
37
37
|
- 😃 **Icon Fonts**: configure the [icon font](https://vuetifyjs.com/en/features/icon-fonts/) you want to use, the module will automatically import it for you using CDN or local dependencies
|
|
38
38
|
- 🎭 **SVG Icons**: ready to use [@mdi/js](https://www.npmjs.com/package/@mdi/js) and [@fortawesome/vue-fontawesome](https://www.npmjs.com/package/@fortawesome/vue-fontawesome) SVG icons packs
|
|
39
39
|
- 📦 **Multiple Icon Sets**: register [multiple icon sets](https://vuetifyjs.com/en/features/icon-fonts/#multiple-icon-sets)
|
|
@@ -86,325 +86,11 @@ export default defineNuxtConfig({
|
|
|
86
86
|
})
|
|
87
87
|
```
|
|
88
88
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
The module will enable automatic tree shaking for Vuetify components.
|
|
92
|
-
|
|
93
|
-
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):
|
|
94
|
-
- the module will provide auto-import support via `vuetify/dist/json/importMap.json` json file and Nuxt `components:extend` hook.
|
|
95
|
-
- 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.
|
|
96
|
-
|
|
97
|
-
### Global Components
|
|
98
|
-
|
|
99
|
-
If you need to add some global component, use `vuetifyOptions.components` module option, it has been declared properly to have better DX.
|
|
100
|
-
|
|
101
|
-
Check the [components definition](https://github.com/userquin/vuetify-nuxt-module/blob/main/src/types.ts#L80-L81).
|
|
102
|
-
|
|
103
|
-
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.
|
|
104
|
-
|
|
105
|
-
### Directives
|
|
106
|
-
|
|
107
|
-
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.
|
|
108
|
-
|
|
109
|
-
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).
|
|
110
|
-
|
|
111
|
-
### Labs Components
|
|
112
|
-
|
|
113
|
-
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.
|
|
114
|
-
|
|
115
|
-
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).
|
|
116
|
-
|
|
117
|
-
## 🔩 Nuxt Layers and Hooks
|
|
118
|
-
|
|
119
|
-
You can load your Vuetify configuration using [Nuxt Layers](https://nuxt.com/docs/getting-started/layers#layers) or using a custom module via `vuetify:registerModule` [Nuxt Hook](https://nuxt.com/docs/guide/going-further/hooks#nuxt-hooks-build-time).
|
|
120
|
-
|
|
121
|
-
### Nuxt Layers
|
|
122
|
-
|
|
123
|
-
Add your Vuetify configuration to a layer and then configure the module to use it:
|
|
124
|
-
```ts
|
|
125
|
-
// Nuxt config file
|
|
126
|
-
import { defineNuxtConfig } from 'nuxt/config'
|
|
127
|
-
|
|
128
|
-
export default defineNuxtConfig({
|
|
129
|
-
extends: ['my-awesome-vuetify-layer'],
|
|
130
|
-
modules: ['vuetify-nuxt-module']
|
|
131
|
-
})
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
### Nuxt Hook
|
|
135
|
-
|
|
136
|
-
You can use a custom module to load your Vuetify configuration:
|
|
137
|
-
```ts
|
|
138
|
-
// Nuxt config file
|
|
139
|
-
import MyVuetifyModule from './modules/my-vuetify-module'
|
|
140
|
-
|
|
141
|
-
export default defineNuxtConfig({
|
|
142
|
-
modules: [MyVuetifyModule, 'vuetify-nuxt-module']
|
|
143
|
-
})
|
|
144
|
-
```
|
|
145
|
-
|
|
146
|
-
and your module will load your configuration via `vuetify:registerModule` Nuxt hook:
|
|
147
|
-
```ts
|
|
148
|
-
// modules/my-vuetify-module
|
|
149
|
-
export default defineNuxtModule({
|
|
150
|
-
setup(_options, nuxt) {
|
|
151
|
-
nuxt.hook('vuetify:registerModule', register => register({
|
|
152
|
-
moduleOptions: {
|
|
153
|
-
/* module specific options */
|
|
154
|
-
},
|
|
155
|
-
vuetifyOptions: {
|
|
156
|
-
/* vuetify options */
|
|
157
|
-
},
|
|
158
|
-
}))
|
|
159
|
-
},
|
|
160
|
-
})
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
## 😃 Font Icons
|
|
164
|
-
|
|
165
|
-
This module supports the following font icons libraries:
|
|
166
|
-
- [Material Design Icons](https://materialdesignicons.com/)
|
|
167
|
-
- [Material Icons](https://fonts.google.com/icons)
|
|
168
|
-
- [Font Awesome 4](https://fontawesome.com/v4.7.0/)
|
|
169
|
-
- [Font Awesome 5](https://fontawesome.com/)
|
|
170
|
-
|
|
171
|
-
By default, the module will use the `mdi` font icon library. You can change it by setting the `defaultSet` option to:
|
|
172
|
-
- `mdi` for [Material Design Icons](https://materialdesignicons.com/)
|
|
173
|
-
- `md` for [Material Icons](https://fonts.google.com/icons)
|
|
174
|
-
- `fa4` for [Font Awesome 4](https://fontawesome.com/v4.7.0/)
|
|
175
|
-
- `fa` for [Font Awesome 5](https://fontawesome.com)
|
|
176
|
-
|
|
177
|
-
To configure a font icon you only need to specify the default set:
|
|
178
|
-
```ts
|
|
179
|
-
// Nuxt config file
|
|
180
|
-
import { defineNuxtConfig } from 'nuxt/config'
|
|
181
|
-
|
|
182
|
-
export default defineNuxtConfig({
|
|
183
|
-
modules: ['vuetify-nuxt-module'],
|
|
184
|
-
vuetify: {
|
|
185
|
-
vuetifyOptions: {
|
|
186
|
-
icons: {
|
|
187
|
-
defaultSet: 'mdi'
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
})
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
The module will use the CDN version of the font icon. If you want to use the local version, you only need to install the corresponding dependency, the module will auto-detect it and will switch to register the font to use the local version.
|
|
195
|
-
|
|
196
|
-
The CDN used for each font icon library, you can use the `cdn` option to change it:
|
|
197
|
-
- [CDN for Material Design Icons (mdi)](https://cdn.jsdelivr.net/npm/@mdi/font@5.x/css/materialdesignicons.min.css)
|
|
198
|
-
- [CDN for Material Icons (md)](https://fonts.googleapis.com/css?family=Material+Icons)
|
|
199
|
-
- [CDN for Font Awesome 4 (fa4)](https://cdn.jsdelivr.net/npm/font-awesome@4.x/css/font-awesome.min.css)
|
|
200
|
-
- [CDN for Font Awesome 5 (fa)](https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@latest/css/all.min.css)
|
|
201
|
-
|
|
202
|
-
To change the CDN for a font icon library you only need to specify the `cdn` option:
|
|
203
|
-
```ts
|
|
204
|
-
// Nuxt config file
|
|
205
|
-
import { defineNuxtConfig } from 'nuxt/config'
|
|
206
|
-
|
|
207
|
-
export default defineNuxtConfig({
|
|
208
|
-
modules: ['vuetify-nuxt-module'],
|
|
209
|
-
vuetify: {
|
|
210
|
-
vuetifyOptions: {
|
|
211
|
-
icons: {
|
|
212
|
-
defaultSet: 'mdi',
|
|
213
|
-
sets: [{
|
|
214
|
-
name: 'mdi',
|
|
215
|
-
cdn: 'https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons'
|
|
216
|
-
}]
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
})
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
## 🎭 SVG Icons
|
|
224
|
-
|
|
225
|
-
This module supports the following SVG icon libraries:
|
|
226
|
-
- [@mdi/js](https://www.npmjs.com/package/@mdi/js)
|
|
227
|
-
- [@fortawesome/fontawesome-svg-core](https://www.npmjs.com/package/@fortawesome/fontawesome-svg-core)
|
|
228
|
-
|
|
229
|
-
We're trying to figure out how to include the following SVG icon libraries:
|
|
230
|
-
- [Nuxt Icon](https://github.com/nuxt-modules/icon)
|
|
231
|
-
- [unplugin-icons](https://github.com/antfu/unplugin-icons)
|
|
232
|
-
|
|
233
|
-
### mdi-svg
|
|
234
|
-
|
|
235
|
-
You only need to add `@mdi/js` dependency to your project and configure the default set:
|
|
236
|
-
```ts
|
|
237
|
-
// Nuxt config file
|
|
238
|
-
import { defineNuxtConfig } from 'nuxt/config'
|
|
239
|
-
|
|
240
|
-
export default defineNuxtConfig({
|
|
241
|
-
modules: ['vuetify-nuxt-module'],
|
|
242
|
-
vuetify: {
|
|
243
|
-
vuetifyOptions: {
|
|
244
|
-
icons: {
|
|
245
|
-
defaultSet: 'mdi-svg'
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
})
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
You can also add icon aliases:
|
|
253
|
-
```ts
|
|
254
|
-
// Nuxt config file
|
|
255
|
-
import { defineNuxtConfig } from 'nuxt/config'
|
|
256
|
-
|
|
257
|
-
export default defineNuxtConfig({
|
|
258
|
-
modules: ['vuetify-nuxt-module'],
|
|
259
|
-
vuetify: {
|
|
260
|
-
vuetifyOptions: {
|
|
261
|
-
icons: {
|
|
262
|
-
defaultSet: 'mdi-svg',
|
|
263
|
-
svg: {
|
|
264
|
-
mdi: {
|
|
265
|
-
aliases: {
|
|
266
|
-
account: 'mdiAccount'
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
})
|
|
274
|
-
```
|
|
275
|
-
|
|
276
|
-
### fa-svg
|
|
277
|
-
|
|
278
|
-
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:
|
|
279
|
-
```ts
|
|
280
|
-
// Nuxt config file
|
|
281
|
-
import { defineNuxtConfig } from 'nuxt/config'
|
|
282
|
-
|
|
283
|
-
export default defineNuxtConfig({
|
|
284
|
-
modules: ['vuetify-nuxt-module'],
|
|
285
|
-
vuetify: {
|
|
286
|
-
vuetifyOptions: {
|
|
287
|
-
icons: {
|
|
288
|
-
defaultSet: 'fa-svg'
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
})
|
|
293
|
-
```
|
|
294
|
-
|
|
295
|
-
You can also add more libraries and install them in your project, the module will register them for you (this is the default configuration using the above configuration):
|
|
296
|
-
```ts
|
|
297
|
-
// Nuxt config file
|
|
298
|
-
import { defineNuxtConfig } from 'nuxt/config'
|
|
299
|
-
|
|
300
|
-
export default defineNuxtConfig({
|
|
301
|
-
modules: ['vuetify-nuxt-module'],
|
|
302
|
-
vuetify: {
|
|
303
|
-
vuetifyOptions: {
|
|
304
|
-
icons: {
|
|
305
|
-
defaultSet: 'fa-svg',
|
|
306
|
-
svg: {
|
|
307
|
-
fa: {
|
|
308
|
-
libraries: [
|
|
309
|
-
[/* default export? */ false, /* export name */ 'fas', /* library */ '@fortawesome/free-solid-svg-icons']
|
|
310
|
-
]
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
})
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
## 📦 Multiple Icon Sets
|
|
320
|
-
|
|
321
|
-
You can register multiple icons sets adding them to the sets array, don't forget to add the default set, otherwise 'mdi' will be used:
|
|
322
|
-
```ts
|
|
323
|
-
// Nuxt config file
|
|
324
|
-
import { defineNuxtConfig } from 'nuxt/config'
|
|
325
|
-
|
|
326
|
-
export default defineNuxtConfig({
|
|
327
|
-
modules: ['vuetify-nuxt-module'],
|
|
328
|
-
vuetify: {
|
|
329
|
-
vuetifyOptions: {
|
|
330
|
-
icons: {
|
|
331
|
-
defaultSet: 'mdi',
|
|
332
|
-
sets: ['mdi', 'fa']
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
})
|
|
337
|
-
```
|
|
338
|
-
|
|
339
|
-
## 🌍 I18n support
|
|
340
|
-
|
|
341
|
-
> Requires latest [@nuxtjs/i18n](https://v8.i18n.nuxtjs.org/) Nuxt module: `8.0.0.beta.13`.
|
|
342
|
-
|
|
343
|
-
You can check the playground folder, you can run it using single or multiple json files per locale:
|
|
344
|
-
- for single file per locale: run from root folder `pnpm install && nr dev:prepare && nr dev`
|
|
345
|
-
- for multiple files per locale: run from root folder `pnpm install && nr dev:prepare:multiple-json && nr dev:multiple-json`
|
|
346
|
-
|
|
347
|
-
## 📆 Date components support
|
|
348
|
-
|
|
349
|
-
Right now you can only use Vuetify adapter, there is a bug and will not work, I'm working on it: https://github.com/userquin/vuetify-nuxt-module/pull/9#issuecomment-1620023814.
|
|
350
|
-
|
|
351
|
-
To use Vuetify components [that require date functionality](https://vuetifyjs.com/en/features/dates/):
|
|
352
|
-
- install one of the [@date-io](https://github.com/dmtrKovalenko/date-io#projects) adapters (optional)
|
|
353
|
-
- configure the date entry in your Vuetify configuration:
|
|
354
|
-
```ts
|
|
355
|
-
vuetifyOptions: {
|
|
356
|
-
date: {
|
|
357
|
-
adapter: 'vuetify' // 'vuetify' | 'date-fns' | 'moment' | 'luxon' | 'dayjs' | 'js-joda' | 'date-fns-jalali' | 'jalaali' | 'hijri' | 'custom'
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
```
|
|
361
|
-
|
|
362
|
-
If you also have `@nuxtjs/i18n` module installed, `vuetifyOptions.date.locale` will be automatically configured, beware, the configured `locale` entry will be ignored.
|
|
363
|
-
|
|
364
|
-
If you want to use a custom date adapter, you can configure it using `vuetifyOptions.date.adapter = 'custom'`, and then:
|
|
365
|
-
- add a Nuxt Plugin and add the `vuetify:configuration` hook to configure your Vuetify options
|
|
366
|
-
- you can import the `virtual:vuetify-date-configuration` module, you will have access to the configuration:
|
|
367
|
-
```ts
|
|
368
|
-
import { adapter, dateConfiguration, i18n } from 'virtual:vuetify-date-configuration'
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
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.
|
|
372
|
-
|
|
373
|
-
## ⚙️ Auto-Import Vuetify Composables
|
|
374
|
-
|
|
375
|
-
No more Vuetify composables manual imports, auto import is enabled by default:
|
|
376
|
-
- [useDate](https://vuetifyjs.com/en/api/use-date/)
|
|
377
|
-
- [useDefaults](https://vuetifyjs.com/en/api/use-defaults/)
|
|
378
|
-
- [useDisplay](https://vuetifyjs.com/en/api/use-display/)
|
|
379
|
-
- [useLayout](https://vuetifyjs.com/en/api/use-layout/)
|
|
380
|
-
- [useLocale](https://vuetifyjs.com/en/api/use-locale/)
|
|
381
|
-
- [useRtl](https://vuetifyjs.com/en/api/use-rtl/)
|
|
382
|
-
- [useTheme](https://vuetifyjs.com/en/api/use-theme/)
|
|
383
|
-
|
|
384
|
-
You can disable auto-import using `moduleOptions.importComposables: false`.
|
|
385
|
-
|
|
386
|
-
If you are using another composables that collide with the Vuetify ones, enable `moduleOptions.prefixComposables: true` to prefix them with `V`:
|
|
387
|
-
- `useLocale` => `useVLocale`
|
|
388
|
-
- `useDefaults` => `useVDefaults`
|
|
389
|
-
- `useDisplay` => `useVDisplay`
|
|
390
|
-
- `useLayout` => `useVLayout`
|
|
391
|
-
- `useRtl` => `useVRtl`
|
|
392
|
-
- `useTheme` => `useVTheme`
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
## 🎨 Vuetify Blueprints
|
|
396
|
-
|
|
397
|
-
The module supports Vuetify Blueprints, just add it to the `vuetifyOptions.blueprint` module option, but with some limitations:
|
|
398
|
-
- `ssr` will be ignored, this flag can be only configured internally by the module via the Nuxt ssr option
|
|
399
|
-
- `components` will be ignored, configure them using the `vuetifyOptions.components` module option
|
|
400
|
-
- `directives` will be ignored, configure them using the `vuetifyOptions.directives` module option
|
|
401
|
-
- `locale` will be ignored, configure it using the `vuetifyOptions.locale` module option
|
|
402
|
-
- `date` will be ignored, configure it using the `vuetifyOptions.date` module option
|
|
403
|
-
- `icons` will be ignored, configure it using the `vuetifyOptions.icons` module option
|
|
89
|
+
Read the [📖 documentation](https://vuetify-nuxt-module.netlify.app/) for a complete guide on how to configure and use this module.
|
|
404
90
|
|
|
405
91
|
## 👀 Full config
|
|
406
92
|
|
|
407
|
-
Check out the
|
|
93
|
+
Check out the [types](https://github.com/userquin/vuetify-nuxt-module/blob/main/src/types.ts).
|
|
408
94
|
|
|
409
95
|
The virtual modules can be found in [configuration.d.ts](https://github.com/userquin/vuetify-nuxt-module/blob/main/configuration.d.ts) file.
|
|
410
96
|
|
package/dist/module.d.ts
CHANGED
|
@@ -34,8 +34,8 @@ interface DateOptions {
|
|
|
34
34
|
*/
|
|
35
35
|
locale?: Record<string, any>;
|
|
36
36
|
}
|
|
37
|
-
type IconSetName = 'mdi' | 'fa' | 'fa4' | 'md' | 'mdi-svg' | 'fa-svg' | 'custom';
|
|
38
|
-
type IconFontName = 'mdi' | 'fa' | 'fa4' | 'md';
|
|
37
|
+
type IconSetName = 'mdi' | 'fa' | 'fa4' | 'md' | 'mdi-svg' | 'fa-svg' | 'unocss-mdi' | 'custom';
|
|
38
|
+
type IconFontName = 'unocss-mdi' | 'mdi' | 'fa' | 'fa4' | 'md';
|
|
39
39
|
interface JSSVGIconSet {
|
|
40
40
|
aliases?: Record<string, string>;
|
|
41
41
|
}
|
|
@@ -68,7 +68,16 @@ interface FontIconSet {
|
|
|
68
68
|
cdn?: string;
|
|
69
69
|
}
|
|
70
70
|
interface IconsOptions {
|
|
71
|
+
/**
|
|
72
|
+
* @default 'mdi'
|
|
73
|
+
*/
|
|
71
74
|
defaultSet: IconSetName;
|
|
75
|
+
/**
|
|
76
|
+
* The prefix for UnoCSS Preset Icons.
|
|
77
|
+
*
|
|
78
|
+
* @default 'i-'
|
|
79
|
+
*/
|
|
80
|
+
unocssIconPrefix?: string;
|
|
72
81
|
sets?: IconFontName | IconFontName[] | FontIconSet[];
|
|
73
82
|
svg?: {
|
|
74
83
|
mdi?: JSSVGIconSet;
|
|
@@ -191,6 +200,10 @@ declare module '#app' {
|
|
|
191
200
|
isDev: boolean;
|
|
192
201
|
vuetifyOptions: VuetifyOptions;
|
|
193
202
|
}) => Promise<void> | void;
|
|
203
|
+
'vuetify:before-create': (options: {
|
|
204
|
+
isDev: boolean;
|
|
205
|
+
vuetifyOptions: VuetifyOptions;
|
|
206
|
+
}) => Promise<void> | void;
|
|
194
207
|
}
|
|
195
208
|
}
|
|
196
209
|
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -6,7 +6,7 @@ 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.
|
|
9
|
+
const version = "0.4.6";
|
|
10
10
|
|
|
11
11
|
function isSubdir(root, test) {
|
|
12
12
|
const relative$1 = relative(root, test);
|
|
@@ -333,21 +333,26 @@ export function dateConfiguration() {
|
|
|
333
333
|
}
|
|
334
334
|
}
|
|
335
335
|
|
|
336
|
-
const cssFonts = ["mdi", "md", "fa", "fa4"];
|
|
336
|
+
const cssFonts = ["unocss-mdi", "mdi", "md", "fa", "fa4"];
|
|
337
337
|
const iconsPackageNames = {
|
|
338
|
-
mdi: { name: "@mdi/font", css: "
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
338
|
+
"unocss-mdi": { name: "@mdi/font", css: "" },
|
|
339
|
+
"mdi": { name: "@mdi/font", css: "@mdi/font/css/materialdesignicons.css" },
|
|
340
|
+
"md": { name: "material-design-icons-iconfont", css: "@mdi/font/css/materialdesignicons.css" },
|
|
341
|
+
"fa": { name: "@fortawesome/fontawesome-free", css: "@fortawesome/fontawesome-free/css/all.css" },
|
|
342
|
+
"fa4": { name: "font-awesome@4.7.0", css: "font-awesome/css/font-awesome.min.css" }
|
|
342
343
|
};
|
|
343
344
|
const iconsCDN = {
|
|
344
|
-
mdi: "
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
345
|
+
"unocss-mdi": "",
|
|
346
|
+
"mdi": "https://cdn.jsdelivr.net/npm/@mdi/font@5.x/css/materialdesignicons.min.css",
|
|
347
|
+
"md": "https://fonts.googleapis.com/css?family=Material+Icons",
|
|
348
|
+
"fa": "https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@latest/css/all.min.css",
|
|
349
|
+
"fa4": "https://cdn.jsdelivr.net/npm/font-awesome@4.x/css/font-awesome.min.css"
|
|
348
350
|
};
|
|
349
351
|
const disabledResolvedIcons = Object.freeze({
|
|
350
352
|
enabled: false,
|
|
353
|
+
unocss: false,
|
|
354
|
+
unocssAliases: false,
|
|
355
|
+
unocssIconPrefix: "i-",
|
|
351
356
|
imports: [],
|
|
352
357
|
aliases: [],
|
|
353
358
|
sets: [],
|
|
@@ -355,7 +360,7 @@ const disabledResolvedIcons = Object.freeze({
|
|
|
355
360
|
local: [],
|
|
356
361
|
svg: {}
|
|
357
362
|
});
|
|
358
|
-
function prepareIcons(logger, vuetifyOptions) {
|
|
363
|
+
function prepareIcons(unocssPresent, logger, vuetifyOptions) {
|
|
359
364
|
if (vuetifyOptions.icons === false)
|
|
360
365
|
return disabledResolvedIcons;
|
|
361
366
|
const icons = vuetifyOptions.icons || {};
|
|
@@ -364,9 +369,12 @@ function prepareIcons(logger, vuetifyOptions) {
|
|
|
364
369
|
defaultSet = icons.defaultSet = "mdi";
|
|
365
370
|
if (!sets && defaultSet !== "mdi-svg" && defaultSet !== "fa-svg" && defaultSet !== "custom")
|
|
366
371
|
sets = [{ name: defaultSet || "mdi" }];
|
|
367
|
-
sets = sets ? convertFontSetsToObjectNotation(sets) :
|
|
372
|
+
sets = sets ? convertFontSetsToObjectNotation(sets) : [];
|
|
368
373
|
const resolvedIcons = {
|
|
369
374
|
enabled: true,
|
|
375
|
+
unocss: unocssPresent && (defaultSet === "unocss-mdi" || sets.some((s) => s.name === "unocss-mdi")),
|
|
376
|
+
unocssAliases: defaultSet === "unocss-mdi",
|
|
377
|
+
unocssIconPrefix: icons.unocssIconPrefix ?? "i-",
|
|
370
378
|
defaultSet,
|
|
371
379
|
sets: [],
|
|
372
380
|
aliases: [],
|
|
@@ -378,7 +386,14 @@ function prepareIcons(logger, vuetifyOptions) {
|
|
|
378
386
|
}
|
|
379
387
|
};
|
|
380
388
|
if (sets) {
|
|
389
|
+
if (!unocssPresent && defaultSet === "unocss-mdi") {
|
|
390
|
+
logger.warn("Configured unocss-mdi as default icon set and @unocss/nuxt is not installed, reverting configuration to use mdi icon set: install @unocss/nuxt module or change the default icon set!");
|
|
391
|
+
defaultSet = "mdi";
|
|
392
|
+
sets = sets.filter((s) => s.name !== "unocss-mdi");
|
|
393
|
+
}
|
|
381
394
|
sets.filter((s) => cssFonts.includes(s.name)).map((s) => s.name).forEach((name) => {
|
|
395
|
+
if (name === "unocss-mdi")
|
|
396
|
+
return;
|
|
382
397
|
resolvedIcons.imports.push(`import {${name === defaultSet ? "aliases," : ""}${name}} from 'vuetify/iconsets/${name}'`);
|
|
383
398
|
resolvedIcons.sets.push(name);
|
|
384
399
|
if (isPackageExists(iconsPackageNames[name].name))
|
|
@@ -386,6 +401,13 @@ function prepareIcons(logger, vuetifyOptions) {
|
|
|
386
401
|
else
|
|
387
402
|
resolvedIcons.cdn.push(iconsCDN[name]);
|
|
388
403
|
});
|
|
404
|
+
if (resolvedIcons.unocss && defaultSet === "unocss-mdi") {
|
|
405
|
+
if (!resolvedIcons.sets.includes("mdi")) {
|
|
406
|
+
resolvedIcons.sets.push("mdi");
|
|
407
|
+
resolvedIcons.imports.push("import {mdi} from 'vuetify/iconsets/mdi'");
|
|
408
|
+
}
|
|
409
|
+
resolvedIcons.defaultSet = "mdi";
|
|
410
|
+
}
|
|
389
411
|
}
|
|
390
412
|
let faSvg = icons.svg?.fa;
|
|
391
413
|
if (defaultSet === "fa-svg" || faSvg) {
|
|
@@ -445,7 +467,7 @@ function prepareIcons(logger, vuetifyOptions) {
|
|
|
445
467
|
logger.warn("Missing @mdi/js dependency, install it!");
|
|
446
468
|
}
|
|
447
469
|
}
|
|
448
|
-
if (!resolvedIcons.local?.length && !resolvedIcons.cdn?.length && !resolvedIcons.svg?.mdi && !resolvedIcons.svg?.fa?.length) {
|
|
470
|
+
if (defaultSet !== "custom" && !resolvedIcons.unocss && !resolvedIcons.local?.length && !resolvedIcons.cdn?.length && !resolvedIcons.svg?.mdi && !resolvedIcons.svg?.fa?.length) {
|
|
449
471
|
logger.warn("No icons found, icons disabled!");
|
|
450
472
|
return disabledResolvedIcons;
|
|
451
473
|
}
|
|
@@ -484,7 +506,7 @@ export function iconsConfiguration() {
|
|
|
484
506
|
}
|
|
485
507
|
`;
|
|
486
508
|
}
|
|
487
|
-
const { aliases, fa, defaultSet, imports, sets } = await iconsOptionsPromise;
|
|
509
|
+
const { unocss, aliases, fa, defaultSet, imports, sets } = await iconsOptionsPromise;
|
|
488
510
|
if (!defaultSet) {
|
|
489
511
|
return `export const isDev = ${isDev}
|
|
490
512
|
export function iconsConfiguration() {
|
|
@@ -493,7 +515,6 @@ export function iconsConfiguration() {
|
|
|
493
515
|
`;
|
|
494
516
|
}
|
|
495
517
|
return `${imports}
|
|
496
|
-
|
|
497
518
|
export const isDev = ${isDev}
|
|
498
519
|
export function iconsConfiguration() {
|
|
499
520
|
${fa.map((f) => ` ${f}`).join("\n")}
|
|
@@ -503,6 +524,7 @@ ${fa.map((f) => ` ${f}`).join("\n")}
|
|
|
503
524
|
sets: { ${sets} }
|
|
504
525
|
}
|
|
505
526
|
}
|
|
527
|
+
${unocss}
|
|
506
528
|
`;
|
|
507
529
|
}
|
|
508
530
|
}
|
|
@@ -510,6 +532,7 @@ ${fa.map((f) => ` ${f}`).join("\n")}
|
|
|
510
532
|
async function prepareIcons() {
|
|
511
533
|
if (!resolvedIcons.enabled) {
|
|
512
534
|
return {
|
|
535
|
+
unocss: "",
|
|
513
536
|
defaultSet: void 0,
|
|
514
537
|
imports: "",
|
|
515
538
|
sets: "",
|
|
@@ -524,9 +547,56 @@ ${fa.map((f) => ` ${f}`).join("\n")}
|
|
|
524
547
|
...aliases,
|
|
525
548
|
${alias.join(",\n")}
|
|
526
549
|
},
|
|
550
|
+
`;
|
|
551
|
+
}
|
|
552
|
+
let unocss = "";
|
|
553
|
+
if (resolvedIcons.unocss && resolvedIcons.unocssAliases) {
|
|
554
|
+
resolvedIcons.imports.unshift("// @unocss-include");
|
|
555
|
+
const prefix = `${resolvedIcons.unocssIconPrefix}mdi:`;
|
|
556
|
+
unocss = `const aliases = ${JSON.stringify({
|
|
557
|
+
collapse: `${prefix}chevron-up`,
|
|
558
|
+
complete: `${prefix}check`,
|
|
559
|
+
cancel: `${prefix}close-circle`,
|
|
560
|
+
close: `${prefix}close`,
|
|
561
|
+
delete: `${prefix}close-circle`,
|
|
562
|
+
// delete (e.g. v-chip close)
|
|
563
|
+
clear: `${prefix}close-circle`,
|
|
564
|
+
success: `${prefix}check-circle`,
|
|
565
|
+
info: `${prefix}information`,
|
|
566
|
+
warning: `${prefix}alert-circle`,
|
|
567
|
+
error: `${prefix}close-circle`,
|
|
568
|
+
prev: `${prefix}chevron-left`,
|
|
569
|
+
next: `${prefix}chevron-right`,
|
|
570
|
+
checkboxOn: `${prefix}checkbox-marked`,
|
|
571
|
+
checkboxOff: `${prefix}checkbox-blank-outline`,
|
|
572
|
+
checkboxIndeterminate: `${prefix}minus-box`,
|
|
573
|
+
delimiter: `${prefix}circle`,
|
|
574
|
+
// for carousel
|
|
575
|
+
sortAsc: `${prefix}arrow-up`,
|
|
576
|
+
sortDesc: `${prefix}arrow-down`,
|
|
577
|
+
expand: `${prefix}chevron-down`,
|
|
578
|
+
menu: `${prefix}menu`,
|
|
579
|
+
subgroup: `${prefix}menu-down`,
|
|
580
|
+
dropdown: `${prefix}menu-down`,
|
|
581
|
+
radioOn: `${prefix}radiobox-marked`,
|
|
582
|
+
radioOff: `${prefix}radiobox-blank`,
|
|
583
|
+
edit: `${prefix}pencil`,
|
|
584
|
+
ratingEmpty: `${prefix}star-outline`,
|
|
585
|
+
ratingFull: `${prefix}star`,
|
|
586
|
+
ratingHalf: `${prefix}star-half-full`,
|
|
587
|
+
loading: `${prefix}cached`,
|
|
588
|
+
first: `${prefix}page-first`,
|
|
589
|
+
last: `${prefix}page-last`,
|
|
590
|
+
unfold: `${prefix}unfold-more-horizontal`,
|
|
591
|
+
file: `${prefix}paperclip`,
|
|
592
|
+
plus: `${prefix}plus`,
|
|
593
|
+
minus: `${prefix}minus`,
|
|
594
|
+
calendar: `${prefix}calendar`
|
|
595
|
+
})}
|
|
527
596
|
`;
|
|
528
597
|
}
|
|
529
598
|
return {
|
|
599
|
+
unocss,
|
|
530
600
|
fa: resolvedIcons.svg?.fa ?? [],
|
|
531
601
|
defaultSet: resolvedIcons.defaultSet,
|
|
532
602
|
imports: Object.values(resolvedIcons.imports).join("\n"),
|
|
@@ -647,7 +717,7 @@ const module = defineNuxtModule({
|
|
|
647
717
|
}
|
|
648
718
|
}
|
|
649
719
|
nuxt.options.build.transpile.push(CONFIG_KEY);
|
|
650
|
-
const icons = prepareIcons(logger, vuetifyOptions);
|
|
720
|
+
const icons = prepareIcons(hasNuxtModule("@unocss/nuxt"), logger, vuetifyOptions);
|
|
651
721
|
(_a = nuxt.options).css ?? (_a.css = []);
|
|
652
722
|
if (typeof styles === "string" && ["sass", "expose"].includes(styles))
|
|
653
723
|
nuxt.options.css.unshift("vuetify/styles/main.sass");
|
|
@@ -5,6 +5,7 @@ export async function configureVuetify() {
|
|
|
5
5
|
const nuxtApp = useNuxtApp();
|
|
6
6
|
const vuetifyOptions = vuetifyConfiguration();
|
|
7
7
|
await nuxtApp.hooks.callHook("vuetify:configuration", { isDev, vuetifyOptions });
|
|
8
|
+
await nuxtApp.hooks.callHook("vuetify:before-create", { isDev, vuetifyOptions });
|
|
8
9
|
const vuetify = createVuetify(vuetifyOptions);
|
|
9
10
|
nuxtApp.vueApp.use(vuetify);
|
|
10
11
|
nuxtApp.provide("vuetify", vuetify);
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vuetify-nuxt-module",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.4.
|
|
5
|
-
"packageManager": "pnpm@8.6.
|
|
4
|
+
"version": "0.4.6",
|
|
5
|
+
"packageManager": "pnpm@8.6.8",
|
|
6
6
|
"description": "Zero-Config Nuxt Module for Vuetify",
|
|
7
7
|
"author": "userquin <userquin@gmail.com>",
|
|
8
8
|
"license": "MIT",
|
|
@@ -46,6 +46,9 @@
|
|
|
46
46
|
"dev:build:multiple-json": "MULTIPLE_LANG_FILES=true nuxi build playground",
|
|
47
47
|
"dev:generate:multiple-json": "MULTIPLE_LANG_FILES=true nuxi generate playground",
|
|
48
48
|
"dev:preview": "nuxi preview playground",
|
|
49
|
+
"docs:dev": "pnpm -C docs run dev",
|
|
50
|
+
"docs:build": "pnpm dev:prepare && pnpm -C docs run build",
|
|
51
|
+
"docs:serve": "pnpm -C docs run serve",
|
|
49
52
|
"lint": "eslint .",
|
|
50
53
|
"lint:fix": "nr lint --fix",
|
|
51
54
|
"test": "vitest run",
|
|
@@ -71,6 +74,8 @@
|
|
|
71
74
|
"@fortawesome/fontawesome-svg-core": "^6.4.0",
|
|
72
75
|
"@fortawesome/free-solid-svg-icons": "^6.4.0",
|
|
73
76
|
"@fortawesome/vue-fontawesome": "^3.0.3",
|
|
77
|
+
"@iconify-json/carbon": "^1.1.18",
|
|
78
|
+
"@iconify-json/mdi": "^1.1.53",
|
|
74
79
|
"@mdi/js": "^7.2.96",
|
|
75
80
|
"@nuxt/devtools": "^0.6.7",
|
|
76
81
|
"@nuxt/module-builder": "^0.4.0",
|
|
@@ -79,6 +84,7 @@
|
|
|
79
84
|
"@nuxtjs/i18n": "^8.0.0-beta.13",
|
|
80
85
|
"@parcel/watcher": "^2.1.0",
|
|
81
86
|
"@types/node": "^18",
|
|
87
|
+
"@unocss/nuxt": "^0.53.5",
|
|
82
88
|
"bumpp": "^9.1.1",
|
|
83
89
|
"eslint": "^8.43.0",
|
|
84
90
|
"luxon": "^3.3.0",
|
|
@@ -108,6 +114,11 @@
|
|
|
108
114
|
"pnpm": {
|
|
109
115
|
"patchedDependencies": {
|
|
110
116
|
"@nuxtjs/i18n@8.0.0-beta.13": "patches/@nuxtjs__i18n@8.0.0-beta.13.patch"
|
|
117
|
+
},
|
|
118
|
+
"peerDependencyRules": {
|
|
119
|
+
"ignoreMissing": [
|
|
120
|
+
"@algolia/client-search"
|
|
121
|
+
]
|
|
111
122
|
}
|
|
112
123
|
},
|
|
113
124
|
"stackblitz": {
|