vuetify-nuxt-module 0.1.0 → 0.2.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 CHANGED
@@ -1,134 +1,255 @@
1
- <p align='center'>
2
- <img src='https://github.com/userquin/vuetify-nuxt-module/raw/main/hero.svg' alt="vuetify-nuxt-module - Zero-config Nuxt module for Vuetify"><br>
3
- Zero-config Nuxt module for Vuetify
4
- </p>
5
-
6
- <p align='center'>
7
- <a href='https://www.npmjs.com/package/vuetify-nuxt-module' target="__blank">
8
- <img src='https://img.shields.io/npm/v/vuetify-nuxt-module?color=33A6B8&label=' alt="NPM version">
9
- </a>
10
- <a href="https://www.npmjs.com/package/vuetify-nuxt-module" target="__blank">
11
- <img alt="NPM Downloads" src="https://img.shields.io/npm/dm/vuetify-nuxt-module?color=476582&label=">
12
- </a>
13
- <!--
14
- <a href="https://vite-pwa-org.netlify.app/frameworks/nuxt" target="__blank">
15
- <img src="https://img.shields.io/static/v1?label=&message=docs%20%26%20guides&color=2e859c" alt="Docs & Guides">
16
- </a>
17
- -->
18
- <br>
19
- <a href="https://github.com/userquin/vuetify-nuxt-module" target="__blank">
20
- <img alt="GitHub stars" src="https://img.shields.io/github/stars/userquin/vuetify-nuxt-module?style=social">
21
- </a>
22
- </p>
23
-
24
- <br>
25
-
26
- ## 🚀 Features
27
-
28
- - 📖 [**Documentation & guides**](README.md#-features) (WIP)
29
- - 👌 **Zero-Config**: sensible built-in default [Vuetify](https://vuetifyjs.com/) configuration for common use cases
30
- - 🔩 **Extensible**: expose the ability to customize the Vuetify configuration via [Nuxt Plugin Hooks](https://nuxt.com/docs/guide/going-further/hooks#usage-with-plugins)
31
- - ⚡ **Fully Tree Shakable**: by default, only the needed Vuetify components are imported
32
- - 🛠️ **Versatile**: custom Vuetify [directives](https://vuetifyjs.com/en/getting-started/installation/#manual-steps) and [labs components](https://vuetifyjs.com/en/labs/introduction/) registration
33
- - ✨ **Configurable Styles**: configure your variables using [Vuetify SASS Variables](https://vuetifyjs.com/en/features/sass-variables/)
34
- - 💥 **SSR**: automatic SSR detection and configuration
35
- - 🌍 **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
36
- - 📆 **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
37
- - 🦾 **Type Strong**: written in [TypeScript](https://www.typescriptlang.org/)
38
-
39
- ## 📦 Install
40
-
41
- > Requires Vite, will not work with Webpack
42
-
43
- ```bash
44
- npm i vuetify-nuxt-module -D
45
-
46
- # yarn
47
- yarn add vuetify-nuxt-module -D
48
-
49
- # pnpm
50
- pnpm add vuetify-nuxt-module -D
51
- ```
52
-
53
- ## 🦄 Usage
54
-
55
- > `vuetify-nuxt-module` is strongly opinionated and has a built-in default configuration out of the box. You can use it without any configuration, and it will work for most use cases.
56
-
57
- Add `vuetify-nuxt-module` module to `nuxt.config.ts` and configure it:
58
-
59
- ```ts
60
- // nuxt.config.ts
61
- import { defineNuxtConfig } from 'nuxt/config'
62
-
63
- export default defineNuxtConfig({
64
- modules: [
65
- 'vuetify-nuxt-module'
66
- ],
67
- vuetify: {
68
- moduleOptions: {
69
- /* module specific options */
70
- },
71
- vuetifyOptions: {
72
- /* vuetify options */
73
- }
74
- }
75
- })
76
- ```
77
-
78
- <!--
79
- Read the [📖 documentation](https://vite-pwa-org.netlify.app/frameworks/nuxt) for a complete guide on how to configure and use
80
- this plugin.
81
- -->
82
-
83
-
84
- ## 🌍 I18n support
85
-
86
- > Requires latest [@nuxtjs/i18n](https://v8.i18n.nuxtjs.org/) Nuxt module: `8.0.0.beta.12`.
87
-
88
- There is a [bug](https://github.com/nuxt-modules/i18n/pull/2193) in the current version that prevents `@nuxtjs/i18n` module to work properly when using `lazy` i18n files.
89
-
90
- If you're using `lazy` i18n files per locale, apply [this patch](./patches/@nuxtjs__i18n@8.0.0-beta.12.patch) to your project: check how to apply it when using `pnpm` in the root `package.json` file in this repo: [package.json](./package.json#L97-L101).
91
-
92
- You can check the playground folder, you can run it using single or multiple json files per locale:
93
- - for single file per locale: run from root folder `pnpm install && nr dev:prepare && nr dev`
94
- - for multiple files per locale: run from root folder `pnpm install && nr dev:prepare:multiple-json && nr dev:multiple-json`
95
-
96
- ## 📆 Date components support
97
-
98
- 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.
99
-
100
- To use Vuetify components [that require date functionality](https://vuetifyjs.com/en/features/dates/):
101
- - (optional): install one of the [@date-io](https://github.com/dmtrKovalenko/date-io#projects) adapters
102
- - configure the date entry in your Vuetify configuration:
103
- ```ts
104
- vuetifyOptions: {
105
- date: {
106
- adapter: 'vuetify' // 'vuetify' | 'date-fns' | 'moment' | 'luxon' | 'dayjs' | 'js-joda' | 'date-fns-jalali' | 'jalaali' | 'hijri' | 'custom'
107
- }
108
- }
109
- ```
110
-
111
- If you also have `@nuxtjs/i18n` module installed, `vuetifyOptions.date.locale` will be automatically configured, beware, the configured `locale` entry will be ignored.
112
-
113
- If you want to use a custom date adapter, you can configure it using `vuetifyOptions.date.adapter = 'custom'`, and then:
114
- - add a Nuxt Plugin and add the `vuetify:configuration` hook to configure your Vuetify options
115
- - you can import the `virtual:vuetify-date-configuration` module, you will have access to the configuration:
116
- ```ts
117
- import { adapter, dateConfiguration, i18n } from 'virtual:vuetify-date-configuration'
118
- ```
119
-
120
- 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.
121
-
122
- ## 👀 Full config
123
-
124
- **WIP**
125
- <!--
126
- Check out the type declaration [src/types.ts](./src/types.ts) and the following links for more details.
127
-
128
- - [Web app manifests](https://developer.mozilla.org/en-US/docs/Web/Manifest)
129
- - [Workbox](https://developers.google.com/web/tools/workbox)
130
- -->
131
-
132
- ## 📄 License
133
-
134
- [MIT](./LICENSE) License &copy; 2023-PRESENT [Joaquín Sánchez](https://github.com/userquin)
1
+ <p align='center'>
2
+ <img src='https://github.com/userquin/vuetify-nuxt-module/raw/main/hero.svg' alt="vuetify-nuxt-module - Zero-config Nuxt module for Vuetify"><br>
3
+ Zero-config Nuxt module for Vuetify
4
+ </p>
5
+
6
+ <p align='center'>
7
+ <a href='https://www.npmjs.com/package/vuetify-nuxt-module' target="__blank">
8
+ <img src='https://img.shields.io/npm/v/vuetify-nuxt-module?color=33A6B8&label=' alt="NPM version">
9
+ </a>
10
+ <a href="https://www.npmjs.com/package/vuetify-nuxt-module" target="__blank">
11
+ <img alt="NPM Downloads" src="https://img.shields.io/npm/dm/vuetify-nuxt-module?color=476582&label=">
12
+ </a>
13
+ <!--
14
+ <a href="https://vite-pwa-org.netlify.app/frameworks/nuxt" target="__blank">
15
+ <img src="https://img.shields.io/static/v1?label=&message=docs%20%26%20guides&color=2e859c" alt="Docs & Guides">
16
+ </a>
17
+ -->
18
+ <br>
19
+ <a href="https://github.com/userquin/vuetify-nuxt-module" target="__blank">
20
+ <img alt="GitHub stars" src="https://img.shields.io/github/stars/userquin/vuetify-nuxt-module?style=social">
21
+ </a>
22
+ </p>
23
+
24
+ <br>
25
+
26
+ ## 🚀 Features
27
+
28
+ - 📖 [**Documentation & guides**](README.md#-features) (WIP)
29
+ - 👌 **Zero-Config**: sensible built-in default [Vuetify](https://vuetifyjs.com/) configuration for common use cases
30
+ - 🔩 **Extensible**: expose the ability to customize the Vuetify configuration via [Nuxt Plugin Hooks](https://nuxt.com/docs/guide/going-further/hooks#usage-with-plugins)
31
+ - ⚡ **Fully Tree Shakable**: by default, only the needed Vuetify components are imported
32
+ - 🛠️ **Versatile**: custom Vuetify [directives](https://vuetifyjs.com/en/getting-started/installation/#manual-steps) and [labs components](https://vuetifyjs.com/en/labs/introduction/) registration
33
+ - ✨ **Configurable Styles**: configure your variables using [Vuetify SASS Variables](https://vuetifyjs.com/en/features/sass-variables/)
34
+ - 💥 **SSR**: automatic SSR detection and configuration
35
+ - 😃 **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
36
+ - 🎨 **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
37
+ - 📦 **Multiple Icon Sets**: register [multiple icon sets](https://vuetifyjs.com/en/features/icon-fonts/#multiple-icon-sets)
38
+ - 🌍 **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
39
+ - 📆 **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
40
+ - 🦾 **Type Strong**: written in [TypeScript](https://www.typescriptlang.org/)
41
+
42
+ ## 📦 Install
43
+
44
+ > Requires Vite, will not work with Webpack
45
+
46
+ ```bash
47
+ npm i vuetify-nuxt-module -D
48
+
49
+ # yarn
50
+ yarn add vuetify-nuxt-module -D
51
+
52
+ # pnpm
53
+ pnpm add vuetify-nuxt-module -D
54
+ ```
55
+
56
+ [![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/userquin/vuetify-nuxt-module)
57
+
58
+ ## 🦄 Usage
59
+
60
+ > `vuetify-nuxt-module` is strongly opinionated and has a built-in default configuration out of the box. You can use it without any configuration, and it will work for most use cases.
61
+
62
+ Add `vuetify-nuxt-module` module to `nuxt.config.ts` and configure it:
63
+
64
+ ```ts
65
+ // nuxt.config.ts
66
+ import { defineNuxtConfig } from 'nuxt/config'
67
+
68
+ export default defineNuxtConfig({
69
+ modules: [
70
+ 'vuetify-nuxt-module'
71
+ ],
72
+ vuetify: {
73
+ moduleOptions: {
74
+ /* module specific options */
75
+ },
76
+ vuetifyOptions: {
77
+ /* vuetify options */
78
+ }
79
+ }
80
+ })
81
+ ```
82
+
83
+ ## 😃 Font Icons
84
+
85
+ This module supports the following font icons libraries:
86
+ - [Material Design Icons](https://materialdesignicons.com/)
87
+ - [Material Icons](https://fonts.google.com/icons)
88
+ - [Font Awesome 4](https://fontawesome.com/v4.7.0/)
89
+ - [Font Awesome 5](https://fontawesome.com/)
90
+
91
+ By default, the module will use the `mdi` font icon library. You can change it by setting the `defaultSet` option to:
92
+ - `mdi` for [Material Design Icons](https://materialdesignicons.com/)
93
+ - `md` for [Material Icons](https://fonts.google.com/icons)
94
+ - `fa4` for [Font Awesome 4](https://fontawesome.com/v4.7.0/)
95
+ - `fa` for [Font Awesome 5](https://fontawesome.com)
96
+
97
+ To configure a font icon you only need to specify the default set:
98
+ ```ts
99
+ vuetify: {
100
+ vuetifyOptions: {
101
+ icons: {
102
+ defaultSet: 'mdi'
103
+ }
104
+ }
105
+ }
106
+ ```
107
+
108
+ 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.
109
+
110
+ The CDN used for each font icon library, you can use the `cdn` option to change it:
111
+ - [CDN for Material Design Icons (mdi)](https://cdn.jsdelivr.net/npm/@mdi/font@5.x/css/materialdesignicons.min.css)
112
+ - [CDN for Material Icons (md)](https://fonts.googleapis.com/css?family=Material+Icons)
113
+ - [CDN for Font Awesome 4 (fa4)](https://cdn.jsdelivr.net/npm/font-awesome@4.x/css/font-awesome.min.css)
114
+ - [CDN for Font Awesome 5 (fa)](https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@latest/css/all.min.css)
115
+
116
+ To change the CDN for a font icon library you only need to specify the `cdn` option:
117
+ ```ts
118
+ vuetify: {
119
+ vuetifyOptions: {
120
+ icons: {
121
+ defaultSet: 'mdi'
122
+ sets: [{
123
+ name: 'mdi',
124
+ cdn: 'https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons'
125
+ }]
126
+ }
127
+ }
128
+ }
129
+ ```
130
+
131
+ ## 🎨 SVG Icons
132
+
133
+ This module supports the following SVG icon libraries:
134
+ - [@mdi/js](https://www.npmjs.com/package/@mdi/js)
135
+ - [@fortawesome/fontawesome-svg-core](https://www.npmjs.com/package/@fortawesome/fontawesome-svg-core)
136
+
137
+ ### mdi-svg
138
+
139
+ You only need to add `@mdi/js` dependency to your project and configure the default set:
140
+ ```ts
141
+ vuetify: {
142
+ vuetifyOptions: {
143
+ icons: {
144
+ defaultSet: 'mdi-svg'
145
+ }
146
+ }
147
+ }
148
+ ```
149
+
150
+ You can also add icon aliases:
151
+ ```ts
152
+ vuetify: {
153
+ vuetifyOptions: {
154
+ icons: {
155
+ defaultSet: 'mdi-svg',
156
+ svg: {
157
+ mdi: {
158
+ account: 'mdiAccount'
159
+ }
160
+ }
161
+ }
162
+ }
163
+ }
164
+ ```
165
+
166
+ ### fa-svg
167
+
168
+ 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:
169
+ ```ts
170
+ vuetify: {
171
+ vuetifyOptions: {
172
+ icons: {
173
+ defaultSet: 'fa-svg'
174
+ }
175
+ }
176
+ }
177
+ ```
178
+
179
+ 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):
180
+ ```ts
181
+ vuetify: {
182
+ vuetifyOptions: {
183
+ icons: {
184
+ defaultSet: 'fa-svg',
185
+ svg: {
186
+ fa: {
187
+ libraries: [/* default export? */ false, /* export name */ 'fas', /* import */ '@fortawesome/free-solid-svg-icons']
188
+ }
189
+ }
190
+ }
191
+ }
192
+ }
193
+ ```
194
+
195
+ ## 📦 Multiple Icon Sets
196
+
197
+ 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:
198
+ ```ts
199
+ vuetify: {
200
+ vuetifyOptions: {
201
+ icons: {
202
+ defaultSet: 'mdi'
203
+ sets: [{ name: 'mdi' }, { name: 'fa' }]
204
+ }
205
+ }
206
+ }
207
+ ```
208
+
209
+ ## 🌍 I18n support
210
+
211
+ > Requires latest [@nuxtjs/i18n](https://v8.i18n.nuxtjs.org/) Nuxt module: `8.0.0.beta.13`.
212
+
213
+ You can check the playground folder, you can run it using single or multiple json files per locale:
214
+ - for single file per locale: run from root folder `pnpm install && nr dev:prepare && nr dev`
215
+ - for multiple files per locale: run from root folder `pnpm install && nr dev:prepare:multiple-json && nr dev:multiple-json`
216
+
217
+ ## 📆 Date components support
218
+
219
+ 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.
220
+
221
+ To use Vuetify components [that require date functionality](https://vuetifyjs.com/en/features/dates/):
222
+ - install one of the [@date-io](https://github.com/dmtrKovalenko/date-io#projects) adapters (optional)
223
+ - configure the date entry in your Vuetify configuration:
224
+ ```ts
225
+ vuetifyOptions: {
226
+ date: {
227
+ adapter: 'vuetify' // 'vuetify' | 'date-fns' | 'moment' | 'luxon' | 'dayjs' | 'js-joda' | 'date-fns-jalali' | 'jalaali' | 'hijri' | 'custom'
228
+ }
229
+ }
230
+ ```
231
+
232
+ If you also have `@nuxtjs/i18n` module installed, `vuetifyOptions.date.locale` will be automatically configured, beware, the configured `locale` entry will be ignored.
233
+
234
+ If you want to use a custom date adapter, you can configure it using `vuetifyOptions.date.adapter = 'custom'`, and then:
235
+ - add a Nuxt Plugin and add the `vuetify:configuration` hook to configure your Vuetify options
236
+ - you can import the `virtual:vuetify-date-configuration` module, you will have access to the configuration:
237
+ ```ts
238
+ import { adapter, dateConfiguration, i18n } from 'virtual:vuetify-date-configuration'
239
+ ```
240
+
241
+ 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.
242
+
243
+ ## 👀 Full config
244
+
245
+ **WIP**
246
+ <!--
247
+ Check out the type declaration [src/types.ts](./src/types.ts) and the following links for more details.
248
+
249
+ - [Web app manifests](https://developer.mozilla.org/en-US/docs/Web/Manifest)
250
+ - [Workbox](https://developers.google.com/web/tools/workbox)
251
+ -->
252
+
253
+ ## 📄 License
254
+
255
+ [MIT](./LICENSE) License &copy; 2023-PRESENT [Joaquín Sánchez](https://github.com/userquin)
@@ -13,3 +13,10 @@ declare module 'virtual:vuetify-date-configuration' {
13
13
  export const adapter: 'vuetify' | 'date-fns' | 'moment' | 'luxon' | 'dayjs' | 'js-joda' | 'date-fns-jalali' | 'jalaali' | 'hijri' | 'custom'
14
14
  export function dateConfiguration(): DateOptions
15
15
  }
16
+
17
+ declare module 'virtual:vuetify-icons-configuration' {
18
+ import type { IconOptions } from 'vuetify'
19
+
20
+ export const isDev: boolean
21
+ export function iconsConfiguration(): IconOptions
22
+ }
package/dist/module.d.ts CHANGED
@@ -31,7 +31,46 @@ interface DateOptions {
31
31
  */
32
32
  locale: Record<string, any>;
33
33
  }
34
- interface VOptions extends Partial<Omit<VuetifyOptions, 'ssr' | 'directives' | 'locale' | 'date'>> {
34
+ type IconSetName = 'mdi' | 'fa' | 'fa4' | 'md' | 'mdi-svg' | 'fa-svg' | 'custom';
35
+ interface IconSet {
36
+ name: IconSetName;
37
+ }
38
+ interface JSSVGIconSet extends IconSet {
39
+ aliases?: Record<string, string>;
40
+ }
41
+ interface FontAwesomeSvgIconSet extends IconSet {
42
+ /**
43
+ * The libraries to import and the corresponding name.
44
+ *
45
+ * For example, to import free svg icons, `libraries` should be (the default):
46
+ * `libraries: [[false, 'fas', 'import { fas } from \'@fortawesome/free-solid-svg-icons\'']]
47
+ *
48
+ * @default [[false, 'fas', 'import { fas } from \'@fortawesome/free-solid-svg-icons\'']]
49
+ */
50
+ libraries?: [defaultExport: boolean, name: string, statement: string][];
51
+ }
52
+ interface FontIconSet extends IconSet {
53
+ /**
54
+ * Use CDN?
55
+ *
56
+ * - mdi: https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons
57
+ * - md: https://fonts.googleapis.com/css?family=Material+Icons
58
+ * - fa: https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@latest/css/all.min.css
59
+ * - fa4: https://cdn.jsdelivr.net/npm/font-awesome@4.x/css/font-awesome.min.css
60
+ *
61
+ * @default the corresponding CDN for the icon set
62
+ */
63
+ cdn?: string;
64
+ }
65
+ interface IconsOptions {
66
+ defaultSet: IconSetName;
67
+ sets?: FontIconSet[];
68
+ svg?: {
69
+ mdi?: JSSVGIconSet;
70
+ fa?: FontAwesomeSvgIconSet;
71
+ };
72
+ }
73
+ interface VOptions extends Partial<Omit<VuetifyOptions, 'ssr' | 'directives' | 'locale' | 'date' | 'icons'>> {
35
74
  /**
36
75
  * Include the lab components?
37
76
  *
@@ -63,6 +102,14 @@ interface VOptions extends Partial<Omit<VuetifyOptions, 'ssr' | 'directives' | '
63
102
  * @see https://vuetifyjs.com/components/date-pickers/
64
103
  */
65
104
  date?: DateOptions;
105
+ /**
106
+ * Include the icons?
107
+ *
108
+ * By default, `mdi` icons will be used via cdn: https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css.
109
+ *
110
+ * @see https://vuetifyjs.com/en/features/icon-fonts/
111
+ */
112
+ icons?: false | IconsOptions;
66
113
  }
67
114
  interface ModuleOptions {
68
115
  moduleOptions?: {
@@ -91,4 +138,4 @@ declare module '#app' {
91
138
 
92
139
  declare const _default: _nuxt_schema.NuxtModule<ModuleOptions>;
93
140
 
94
- export { BooleanOrArrayString, DateAdapter, DateOptions, ModuleOptions, VOptions, _default as default };
141
+ export { BooleanOrArrayString, DateAdapter, DateOptions, FontAwesomeSvgIconSet, FontIconSet, IconSet, IconSetName, IconsOptions, JSSVGIconSet, 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.1.0"
7
+ "version": "0.2.1"
8
8
  }
package/dist/module.mjs CHANGED
@@ -1,20 +1,19 @@
1
+ import { utimes, readFile } from 'node:fs/promises';
1
2
  import { useLogger, defineNuxtModule, createResolver, hasNuxtModule, extendWebpackConfig, addPlugin } from '@nuxt/kit';
2
3
  import defu from 'defu';
3
- import vuetify from 'vite-plugin-vuetify';
4
- import 'local-pkg';
5
- import { utimes } from 'node:fs/promises';
4
+ import { isPackageExists } from 'local-pkg';
6
5
  import { resolveVuetifyBase, normalizePath, writeStyles, cacheDir } from '@vuetify/loader-shared';
7
6
  import { isAbsolute, join, relative } from 'pathe';
8
7
  import { normalizePath as normalizePath$1 } from 'vite';
9
8
 
10
- const version = "0.1.0";
9
+ const version = "0.2.1";
11
10
 
12
11
  function isSubdir(root, test) {
13
12
  const relative$1 = relative(root, test);
14
13
  return relative$1 && !relative$1.startsWith("..") && !isAbsolute(relative$1);
15
14
  }
16
15
  const styleImportRegexp = /(@use |meta\.load-css\()['"](vuetify(?:\/lib)?(?:\/styles(?:\/main(?:\.sass)?)?)?)['"]/;
17
- function stylesPlugin(options, logger) {
16
+ function vuetifyStylesPlugin(options, logger) {
18
17
  const vuetifyBase = resolveVuetifyBase();
19
18
  const files = /* @__PURE__ */ new Set();
20
19
  let server;
@@ -182,12 +181,14 @@ const VIRTUAL_VUETIFY_CONFIGURATION = "virtual:vuetify-configuration";
182
181
  const RESOLVED_VIRTUAL_VUETIFY_CONFIGURATION = `/@nuxt-vuetify-configuration/${VIRTUAL_VUETIFY_CONFIGURATION.slice("virtual:".length)}`;
183
182
  const VIRTUAL_VUETIFY_DATE_CONFIGURATION = "virtual:vuetify-date-configuration";
184
183
  const RESOLVED_VIRTUAL_VUETIFY_DATE_CONFIGURATION = `/@nuxt-vuetify-configuration/${VIRTUAL_VUETIFY_DATE_CONFIGURATION.slice("virtual:".length)}`;
184
+ const VIRTUAL_VUETIFY_ICONS_CONFIGURATION = "virtual:vuetify-icons-configuration";
185
+ const RESOLVED_VIRTUAL_VUETIFY_ICONS_CONFIGURATION = `/@nuxt-vuetify-configuration/${VIRTUAL_VUETIFY_ICONS_CONFIGURATION.slice("virtual:".length)}`;
185
186
 
186
187
  function vuetifyConfigurationPlugin(isDev, directives, labComponents, vuetifyAppOptions) {
187
188
  const {
188
189
  directives: _directives,
189
190
  date: _date,
190
- locale: _locale,
191
+ icons: _icons,
191
192
  ...newVuetifyOptions
192
193
  } = vuetifyAppOptions;
193
194
  return {
@@ -267,22 +268,205 @@ export const i18n = ${i18n}
267
268
  export const adapter = '${dateAdapter}'
268
269
  export function dateConfiguration() {
269
270
  const options = ${JSON.stringify(newDateOptions)}
270
- ${buildAdapter(dateAdapter)}
271
+ ${buildAdapter()}
271
272
  return options
272
273
  }
273
274
  `;
274
275
  }
275
276
  }
276
277
  };
278
+ function buildAdapter() {
279
+ if (dateAdapter === "custom")
280
+ return "";
281
+ if (dateAdapter === "vuetify")
282
+ return "options.adapter = VuetifyDateAdapter";
283
+ return "options.adapter = Adapter";
284
+ }
285
+ }
286
+
287
+ const cssFonts = ["mdi", "md", "fa", "fa4"];
288
+ const iconsPackageNames = {
289
+ mdi: { name: "@mdi/font", css: "@mdi/font/css/materialdesignicons.css" },
290
+ md: { name: "material-design-icons-iconfont", css: "@mdi/font/css/materialdesignicons.css" },
291
+ fa: { name: "@fortawesome/fontawesome-free", css: "@fortawesome/fontawesome-free/css/all.css" },
292
+ fa4: { name: "font-awesome@4.7.0", css: "font-awesome/css/font-awesome.min.css" }
293
+ };
294
+ const iconsCDN = {
295
+ mdi: "https://cdn.jsdelivr.net/npm/@mdi/font@5.x/css/materialdesignicons.min.css",
296
+ md: "https://fonts.googleapis.com/css?family=Material+Icons",
297
+ fa: "https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@latest/css/all.min.css",
298
+ fa4: "https://cdn.jsdelivr.net/npm/font-awesome@4.x/css/font-awesome.min.css"
299
+ };
300
+ function prepareIcons(logger, vuetifyOptions) {
301
+ if (vuetifyOptions.icons === false)
302
+ return { enabled: false };
303
+ vuetifyOptions.icons = vuetifyOptions.icons ?? {};
304
+ let { defaultSet = "mdi", sets } = vuetifyOptions.icons;
305
+ if (!defaultSet)
306
+ defaultSet = vuetifyOptions.icons.defaultSet = "mdi";
307
+ if (!sets)
308
+ sets = [{ name: defaultSet || "mdi" }];
309
+ const resolvedIcons = {
310
+ enabled: true,
311
+ defaultSet,
312
+ sets: [],
313
+ aliases: [],
314
+ imports: [],
315
+ cdn: [],
316
+ local: [],
317
+ svg: {
318
+ mdi: false
319
+ }
320
+ };
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;
330
+ if (defaultSet === "fa-svg" || faSvg) {
331
+ let faSvgExists = isPackageExists("@fortawesome/fontawesome-svg-core");
332
+ if (!faSvgExists)
333
+ logger.warn("Missing @fortawesome/fontawesome-svg-core dependency, install it!");
334
+ faSvgExists = isPackageExists("@fortawesome/vue-fontawesome");
335
+ if (faSvgExists) {
336
+ if (!faSvg?.libraries?.length) {
337
+ faSvg = faSvg || {};
338
+ faSvg.libraries = [[false, "fas", "@fortawesome/free-solid-svg-icons"]];
339
+ }
340
+ for (const p in faSvg.libraries) {
341
+ const [_defaultExport, _name, library] = faSvg.libraries[p];
342
+ faSvgExists = isPackageExists(library);
343
+ if (!faSvgExists)
344
+ logger.warn(`Missing library ${library} dependency, install it!`);
345
+ }
346
+ } else {
347
+ logger.warn("Missing @fortawesome/vue-fontawesome dependency, install it!");
348
+ }
349
+ if (faSvgExists) {
350
+ resolvedIcons.imports.push(`import {${defaultSet === "fa-svg" ? "aliases," : ""}fa} from 'vuetify/iconsets/fa-svg'`);
351
+ resolvedIcons.imports.push("import { library } from '@fortawesome/fontawesome-svg-core'");
352
+ resolvedIcons.imports.push("import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'");
353
+ resolvedIcons.imports.push("import { useNuxtApp } from '#app'");
354
+ resolvedIcons.svg.fa = ["useNuxtApp().vueApp.component('font-awesome-icon', FontAwesomeIcon)"];
355
+ faSvg.libraries.forEach(([defaultExport, name, library]) => {
356
+ resolvedIcons.imports.push(`import ${defaultExport ? name : `{${name}}`} from '${library}'`);
357
+ resolvedIcons.svg.fa.push(`library.add(${name})`);
358
+ });
359
+ resolvedIcons.sets.push("fa");
360
+ if (defaultSet === "fa-svg")
361
+ resolvedIcons.defaultSet = "fa";
362
+ }
363
+ }
364
+ const mdiSvg = vuetifyOptions.icons.svg?.mdi;
365
+ if (defaultSet === "mdi-svg" || mdiSvg) {
366
+ const mdiSvgExists = isPackageExists("@mdi/js");
367
+ if (mdiSvgExists) {
368
+ resolvedIcons.svg.mdi = true;
369
+ resolvedIcons.imports.push(`import {${defaultSet === "mdi-svg" ? "aliases," : ""}mdi} from 'vuetify/iconsets/mdi-svg'`);
370
+ if (mdiSvg && mdiSvg.aliases) {
371
+ resolvedIcons.imports.push(`import {${Object.values(mdiSvg.aliases).join(",")}} from '@mdi/js'`);
372
+ Object.entries(mdiSvg.aliases).forEach(([alias, icon]) => {
373
+ resolvedIcons.aliases.push(`${alias}: ${icon}`);
374
+ });
375
+ }
376
+ resolvedIcons.sets.push("mdi");
377
+ if (defaultSet === "mdi-svg")
378
+ resolvedIcons.defaultSet = "mdi";
379
+ } else {
380
+ resolvedIcons.svg.mdi = false;
381
+ logger.warn("Missing @mdi/js dependency, install it!");
382
+ }
383
+ }
384
+ if (!resolvedIcons.local?.length && !resolvedIcons.cdn?.length && !resolvedIcons.svg?.mdi && !resolvedIcons.svg?.fa?.length) {
385
+ logger.warn("No icons found, icons disabled!");
386
+ return { enabled: false };
387
+ }
388
+ return resolvedIcons;
389
+ }
390
+
391
+ function vuetifyIconsPlugin(isDev, resolvedIcons) {
392
+ const iconsOptionsPromise = prepareIcons();
393
+ return {
394
+ name: "vuetify:icons-configuration:nuxt",
395
+ enforce: "pre",
396
+ resolveId(id) {
397
+ if (id === VIRTUAL_VUETIFY_ICONS_CONFIGURATION)
398
+ return RESOLVED_VIRTUAL_VUETIFY_ICONS_CONFIGURATION;
399
+ },
400
+ async load(id) {
401
+ if (id === RESOLVED_VIRTUAL_VUETIFY_ICONS_CONFIGURATION) {
402
+ if (!resolvedIcons.enabled) {
403
+ return `export const isDev = ${isDev}
404
+ export function iconsConfiguration() {
405
+ return { defaultSet: undefined }
406
+ }
407
+ `;
408
+ }
409
+ const { aliases, fa, defaultSet, imports, sets } = await iconsOptionsPromise;
410
+ if (!defaultSet) {
411
+ return `export const isDev = ${isDev}
412
+ export function iconsConfiguration() {
413
+ return { defaultSet: undefined }
414
+ }
415
+ `;
416
+ }
417
+ return `${imports}
418
+
419
+ export const isDev = ${isDev}
420
+ export function iconsConfiguration() {
421
+ ${fa.map((f) => ` ${f}`).join("\n")}
422
+ return {
423
+ defaultSet: '${defaultSet}',
424
+ ${aliases}
425
+ sets: { ${sets} }
426
+ }
277
427
  }
278
- function buildAdapter(dateAdapter) {
279
- if (dateAdapter === "custom")
280
- return "";
281
- if (dateAdapter === "vuetify")
282
- return "options.adapter = VuetifyDateAdapter";
283
- return "options.adapter = Adapter";
428
+ `;
429
+ }
430
+ }
431
+ };
432
+ async function prepareIcons() {
433
+ if (!resolvedIcons.enabled) {
434
+ return {
435
+ defaultSet: void 0,
436
+ imports: "",
437
+ sets: "",
438
+ aliases: "",
439
+ fa: []
440
+ };
441
+ }
442
+ let aliases = "aliases,";
443
+ const alias = resolvedIcons.aliases;
444
+ if (alias.length) {
445
+ aliases = `aliases: {
446
+ ...aliases,
447
+ ${alias.join(",\n")}
448
+ },
449
+ `;
450
+ }
451
+ return {
452
+ fa: resolvedIcons.svg?.fa ?? [],
453
+ defaultSet: resolvedIcons.defaultSet,
454
+ imports: Object.values(resolvedIcons.imports).join("\n"),
455
+ sets: resolvedIcons.sets.join(","),
456
+ aliases
457
+ };
458
+ }
284
459
  }
285
460
 
461
+ function toKebabCase(str = "") {
462
+ if (toKebabCase.cache.has(str))
463
+ return toKebabCase.cache.get(str);
464
+ const kebab = str.replace(/[^a-z]/gi, "-").replace(/\B([A-Z])/g, "-$1").toLowerCase();
465
+ toKebabCase.cache.set(str, kebab);
466
+ return kebab;
467
+ }
468
+ toKebabCase.cache = /* @__PURE__ */ new Map();
469
+
286
470
  const CONFIG_KEY = "vuetify";
287
471
  const logger = useLogger(`nuxt:${CONFIG_KEY}`);
288
472
  const module = defineNuxtModule({
@@ -303,22 +487,22 @@ const module = defineNuxtModule({
303
487
  }
304
488
  }),
305
489
  setup(options, nuxt) {
306
- var _a;
490
+ var _a, _b;
307
491
  const resolver = createResolver(import.meta.url);
308
- const { moduleOptions, vuetifyOptions } = options;
492
+ const { moduleOptions = {}, vuetifyOptions = {} } = options;
309
493
  const {
310
494
  directives = false,
311
495
  labComponents = false,
312
496
  ...vOptions
313
- } = vuetifyOptions ?? {};
497
+ } = vuetifyOptions;
314
498
  const isSSR = nuxt.options.ssr;
315
499
  const vuetifyAppOptions = defu(vOptions, {
316
500
  ssr: isSSR
317
501
  });
318
- const { styles = true } = moduleOptions ?? {};
502
+ const { styles = true } = moduleOptions;
319
503
  const i18n = hasNuxtModule("@nuxtjs/i18n", nuxt);
320
504
  let dateAdapter;
321
- const dateOptions = vuetifyOptions?.date;
505
+ const dateOptions = vuetifyOptions.date;
322
506
  if (dateOptions) {
323
507
  const adapter = dateOptions.adapter;
324
508
  const date = detectDate();
@@ -342,6 +526,7 @@ const module = defineNuxtModule({
342
526
  const runtimeDir = resolver.resolve("./runtime");
343
527
  nuxt.options.build.transpile.push(runtimeDir);
344
528
  nuxt.options.build.transpile.push(CONFIG_KEY);
529
+ const icons = prepareIcons(logger, vuetifyOptions);
345
530
  (_a = nuxt.options).css ?? (_a.css = []);
346
531
  if (typeof styles === "string" && ["sass", "expose"].includes(styles))
347
532
  nuxt.options.css.unshift("vuetify/styles/main.sass");
@@ -349,6 +534,18 @@ const module = defineNuxtModule({
349
534
  nuxt.options.css.unshift("vuetify/styles");
350
535
  else if (typeof styles === "object" && styles?.configFile && typeof styles.configFile === "string")
351
536
  nuxt.options.css.unshift(styles.configFile);
537
+ if (icons.enabled) {
538
+ icons.local?.forEach((css) => nuxt.options.css.push(css));
539
+ if (icons.cdn?.length) {
540
+ (_b = nuxt.options.app.head).link ?? (_b.link = []);
541
+ icons.cdn.forEach((href) => nuxt.options.app.head.link.push({
542
+ rel: "stylesheet",
543
+ href,
544
+ type: "text/css",
545
+ crossorigin: "anonymous"
546
+ }));
547
+ }
548
+ }
352
549
  extendWebpackConfig(() => {
353
550
  throw new Error("Webpack is not supported: vuetify-nuxt-module module can only be used with Vite!");
354
551
  });
@@ -357,6 +554,25 @@ const module = defineNuxtModule({
357
554
  references.push({ types: "vuetify-nuxt-module/configuration" });
358
555
  references.push({ types: "vuetify" });
359
556
  });
557
+ const vuetifyBase = resolveVuetifyBase();
558
+ nuxt.hook("components:extend", async (c) => {
559
+ const { components } = JSON.parse(await readFile(resolver.resolve(vuetifyBase, "dist/json/importMap.json"), "utf-8"));
560
+ Object.keys(components).forEach((component) => {
561
+ const from = components[component].from;
562
+ c.push({
563
+ pascalName: component,
564
+ kebabName: toKebabCase(component),
565
+ export: component,
566
+ filePath: `${resolver.resolve(vuetifyBase, `lib/${from}`)}`,
567
+ shortPath: `components/${from}`,
568
+ chunkName: toKebabCase(component),
569
+ prefetch: false,
570
+ preload: false,
571
+ global: false,
572
+ mode: "all"
573
+ });
574
+ });
575
+ });
360
576
  nuxt.hook("vite:extendConfig", (viteInlineConfig) => {
361
577
  viteInlineConfig.plugins = viteInlineConfig.plugins || [];
362
578
  checkVuetifyPlugins(viteInlineConfig);
@@ -366,15 +582,17 @@ const module = defineNuxtModule({
366
582
  ...Array.isArray(viteInlineConfig.ssr.noExternal) ? viteInlineConfig.ssr.noExternal : [],
367
583
  CONFIG_KEY
368
584
  ];
369
- const autoImportPlugin = vuetify({ styles: true, autoImport: true }).find((p) => p && typeof p === "object" && "name" in p && p.name === "vuetify:import");
370
- viteInlineConfig.plugins.push(autoImportPlugin);
371
- viteInlineConfig.plugins.push(stylesPlugin({ styles }, logger));
585
+ viteInlineConfig.plugins.push(vuetifyStylesPlugin({ styles }, logger));
372
586
  viteInlineConfig.plugins.push(vuetifyConfigurationPlugin(
373
587
  nuxt.options.dev,
374
588
  directives,
375
589
  labComponents,
376
590
  vuetifyAppOptions
377
591
  ));
592
+ viteInlineConfig.plugins.push(vuetifyIconsPlugin(
593
+ nuxt.options.dev,
594
+ icons
595
+ ));
378
596
  if (dateAdapter) {
379
597
  viteInlineConfig.plugins.push(vuetifyDateConfigurationPlugin(
380
598
  nuxt.options.dev,
@@ -387,6 +605,9 @@ const module = defineNuxtModule({
387
605
  addPlugin({
388
606
  src: resolver.resolve(runtimeDir, "plugins/vuetify.mts")
389
607
  });
608
+ addPlugin({
609
+ src: resolver.resolve(runtimeDir, "plugins/vuetify-icons.mts")
610
+ });
390
611
  if (i18n) {
391
612
  addPlugin({
392
613
  src: resolver.resolve(runtimeDir, "plugins/vuetify-i18n.mts")
@@ -0,0 +1,22 @@
1
+ export declare function configureVuetify(): Promise<{
2
+ install: (app: import("vue").App<any>) => void;
3
+ defaults: import("vue").Ref<import("vuetify/lib/framework.mjs").DefaultsInstance>;
4
+ display: import("vuetify/lib/framework.mjs").DisplayInstance;
5
+ theme: import("vuetify/lib/framework.mjs").ThemeInstance & {
6
+ install: (app: import("vue").App<any>) => void;
7
+ };
8
+ icons: Record<string, any>;
9
+ locale: {
10
+ isRtl: import("vue").Ref<boolean>;
11
+ rtl: import("vue").Ref<Record<string, boolean>>;
12
+ rtlClasses: import("vue").Ref<string>;
13
+ name: string;
14
+ messages: import("vue").Ref<import("vuetify/lib/framework.mjs").LocaleMessages>;
15
+ current: import("vue").Ref<string>;
16
+ fallback: import("vue").Ref<string>;
17
+ t: (key: string, ...params: unknown[]) => string;
18
+ n: (value: number) => string;
19
+ provide: (props: import("vuetify/lib/framework.mjs").LocaleOptions) => import("vuetify/lib/framework.mjs").LocaleInstance;
20
+ };
21
+ date: Record<string, any>;
22
+ }>;
@@ -0,0 +1,14 @@
1
+ import { createVuetify } from "vuetify";
2
+ import { isDev, vuetifyConfiguration } from "virtual:vuetify-configuration";
3
+ import { useNuxtApp } from "#app";
4
+ export async function configureVuetify() {
5
+ const nuxtApp = useNuxtApp();
6
+ const vuetifyOptions = vuetifyConfiguration();
7
+ await nuxtApp.hooks.callHook("vuetify:configuration", { isDev, vuetifyOptions });
8
+ const vuetify = createVuetify(vuetifyOptions);
9
+ nuxtApp.vueApp.use(vuetify);
10
+ if (process.client) {
11
+ isDev && console.log("Vuetify 3 initialized", vuetify);
12
+ }
13
+ return vuetify;
14
+ }
@@ -1,3 +1,2 @@
1
- import type { DateOptions } from '../../types';
2
- import type { NuxtApp } from '#app';
3
- export declare function configureLocales(nuxtApp: NuxtApp, options: DateOptions): DateOptions;
1
+ import type { VuetifyOptions } from 'vuetify';
2
+ export declare function configureDate(vuetifyOptions: VuetifyOptions): void;
@@ -1,11 +1,17 @@
1
- import { camelize } from "../../utils";
2
- export function configureLocales(nuxtApp, options) {
3
- const locales = nuxtApp.$i18n?.locales.value;
4
- if (locales) {
5
- options.locale = locales.reduce((acc, locale) => {
6
- acc[camelize(locale.code)] = locale.code;
7
- return acc;
8
- }, {});
1
+ import { adapter, dateConfiguration, i18n } from "virtual:vuetify-date-configuration";
2
+ import { useNuxtApp } from "#app";
3
+ export function configureDate(vuetifyOptions) {
4
+ if (adapter === "custom")
5
+ return;
6
+ const dateOptions = dateConfiguration();
7
+ if (i18n) {
8
+ const locales = useNuxtApp().$i18n.locales.value;
9
+ if (locales) {
10
+ dateOptions.locale = locales.reduce((acc, locale) => {
11
+ acc[locale.code] = locale.code;
12
+ return acc;
13
+ }, {});
14
+ }
9
15
  }
10
- return options;
16
+ vuetifyOptions.date = dateOptions;
11
17
  }
@@ -1,20 +1,2 @@
1
- import type { Ref } from 'vue';
2
- import type { LocaleMessages, LocaleOptions } from 'vuetify';
3
- import type { NuxtApp } from '#app';
4
- export declare function createAdapter(nuxtApp: NuxtApp): {
5
- name: string;
6
- current: any;
7
- fallback: any;
8
- messages: any;
9
- t: (key: string, ...params: unknown[]) => any;
10
- n: any;
11
- provide: (props: LocaleOptions) => {
12
- name: string;
13
- current: Ref<string>;
14
- fallback: Ref<string>;
15
- messages: Ref<LocaleMessages>;
16
- t: (key: string, ...params: unknown[]) => any;
17
- n: any;
18
- provide: any;
19
- };
20
- };
1
+ import type { VuetifyOptions } from 'vuetify';
2
+ export declare function createAdapter(vuetifyOptions: VuetifyOptions): void;
@@ -9,14 +9,19 @@ import {
9
9
  } from "vue";
10
10
  import { toKebabCase } from "../../utils";
11
11
  import { useI18n } from "#imports";
12
- export function createAdapter(nuxtApp) {
12
+ import { useNuxtApp } from "#app";
13
+ export function createAdapter(vuetifyOptions) {
14
+ vuetifyOptions.locale = {};
15
+ const nuxtApp = useNuxtApp();
13
16
  const i18n = nuxtApp.$i18n;
14
17
  const current = i18n.locale;
15
18
  const fallback = i18n.fallbackLocale;
16
19
  const messages = i18n.messages;
17
- watch(() => current, (l) => nuxtApp.$vuetify.locale.current.value = l);
18
- watch(() => nuxtApp.$vuetify?.locale?.current.value, (l) => i18n.setLocale(l));
19
- return {
20
+ vuetifyOptions.locale.rtl = i18n.locales.value.reduce((acc, locale) => {
21
+ acc[locale.code] = locale.dir === "rtl";
22
+ return acc;
23
+ }, {});
24
+ vuetifyOptions.locale.adapter = {
20
25
  name: "nuxt-vue-i18n",
21
26
  current,
22
27
  fallback,
@@ -113,7 +118,6 @@ function createProvideFunction(data) {
113
118
  legacy: false,
114
119
  inheritLocale: false
115
120
  });
116
- watch(current, (l) => i18n.locale.value = l);
117
121
  return {
118
122
  name: "nuxt-vue-i18n",
119
123
  current,
@@ -0,0 +1,2 @@
1
+ import type { VuetifyOptions } from 'vuetify';
2
+ export declare function configureIcons(vuetifyOptions: VuetifyOptions): void;
@@ -0,0 +1,4 @@
1
+ import { iconsConfiguration } from "virtual:vuetify-icons-configuration";
2
+ export function configureIcons(vuetifyOptions) {
3
+ vuetifyOptions.icons = iconsConfiguration();
4
+ }
@@ -1,16 +1,8 @@
1
- import { adapter, dateConfiguration, i18n } from 'virtual:vuetify-date-configuration'
2
- import { configureLocales } from './date'
3
- import { defineNuxtPlugin } from '#app'
1
+ import { configureDate } from './date'
2
+ import { defineNuxtPlugin } from '#imports'
4
3
 
5
4
  export default defineNuxtPlugin((nuxtApp) => {
6
- nuxtApp.hook('vuetify:configuration', async ({ vuetifyOptions }) => {
7
- if (adapter === 'custom')
8
- return
9
-
10
- const options = dateConfiguration()
11
- if (i18n)
12
- configureLocales(nuxtApp, options)
13
-
14
- vuetifyOptions.date = options
5
+ nuxtApp.hook('vuetify:configuration', ({ vuetifyOptions }) => {
6
+ configureDate(vuetifyOptions)
15
7
  })
16
8
  })
@@ -1,9 +1,8 @@
1
1
  import { createAdapter } from './i18n'
2
- import { defineNuxtPlugin } from '#app'
2
+ import { defineNuxtPlugin } from '#imports'
3
3
 
4
4
  export default defineNuxtPlugin((nuxtApp) => {
5
5
  nuxtApp.hook('vuetify:configuration', ({ vuetifyOptions }) => {
6
- vuetifyOptions.locale = vuetifyOptions.locale ?? {}
7
- vuetifyOptions.locale.adapter = createAdapter(nuxtApp)
6
+ createAdapter(vuetifyOptions)
8
7
  })
9
8
  })
@@ -0,0 +1,8 @@
1
+ import { configureIcons } from './icons'
2
+ import { defineNuxtPlugin } from '#imports'
3
+
4
+ export default defineNuxtPlugin((nuxtApp) => {
5
+ nuxtApp.hook('vuetify:configuration', ({ vuetifyOptions }) => {
6
+ configureIcons(vuetifyOptions)
7
+ })
8
+ })
@@ -1,30 +1,11 @@
1
- import { createVuetify } from 'vuetify'
2
- import { isDev, vuetifyConfiguration } from 'virtual:vuetify-configuration'
3
- import { defineNuxtPlugin, useNuxtApp } from '#app'
4
-
5
- export default defineNuxtPlugin({
6
- name: 'vuetify:configuration:plugin',
7
- enforce: 'post',
8
- parallel: false,
9
- async setup() {
10
- const nuxtApp = useNuxtApp()
11
- const vuetifyOptions = vuetifyConfiguration()
12
-
13
- await nuxtApp.hooks.callHook('vuetify:configuration', { isDev, vuetifyOptions })
14
-
15
- const vuetify = createVuetify(vuetifyOptions)
16
-
17
- nuxtApp.vueApp.use(vuetify)
18
-
19
- if (process.client && isDev) {
20
- // eslint-disable-next-line no-console
21
- console.log('Vuetify 3 initialized', vuetify)
22
- }
23
-
24
- return {
25
- provide: {
26
- vuetify,
27
- },
28
- }
29
- },
30
- })
1
+ import { configureVuetify } from './config'
2
+ import { defineNuxtPlugin } from '#imports'
3
+ import { useNuxtApp } from '#app'
4
+
5
+ export default defineNuxtPlugin({
6
+ name: 'vuetify:configuration:plugin',
7
+ enforce: 'pre',
8
+ setup() {
9
+ useNuxtApp().hook('app:created', configureVuetify)
10
+ },
11
+ })
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, ModuleOptions, VOptions, default } from './module'
15
+ export { BooleanOrArrayString, DateAdapter, DateOptions, FontAwesomeSvgIconSet, FontIconSet, IconSet, IconSetName, IconsOptions, JSSVGIconSet, 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.1.0",
4
+ "version": "0.2.1",
5
5
  "packageManager": "pnpm@8.6.6",
6
6
  "description": "Zero-Config Nuxt Module for Vuetify ",
7
7
  "author": "userquin <userquin@gmail.com>",
@@ -42,7 +42,10 @@
42
42
  "dev:prepare": "nuxt-module-build --stub && nuxi prepare playground",
43
43
  "dev:prepare:multiple-json": "nuxt-module-build --stub && MULTIPLE_LANG_FILES=true nuxi prepare playground",
44
44
  "dev:build": "nuxi build playground",
45
+ "dev:generate": "nuxi generate playground",
45
46
  "dev:build:multiple-json": "MULTIPLE_LANG_FILES=true nuxi build playground",
47
+ "dev:generate:multiple-json": "MULTIPLE_LANG_FILES=true nuxi generate playground",
48
+ "dev:preview": "nuxi preview playground",
46
49
  "lint": "eslint .",
47
50
  "lint:fix": "nr lint --fix",
48
51
  "test": "vitest run",
@@ -51,12 +54,12 @@
51
54
  "release": "bumpp && npm publish"
52
55
  },
53
56
  "peerDependencies": {
54
- "@nuxt/kit": "^3.5.3",
57
+ "@nuxt/kit": "^3.6.2",
55
58
  "vite-plugin-vuetify": "^1.0.2",
56
59
  "vuetify": "^3.3.6"
57
60
  },
58
61
  "dependencies": {
59
- "@nuxt/kit": "^3.6.1",
62
+ "@nuxt/kit": "^3.6.2",
60
63
  "defu": "^6.1.2",
61
64
  "vite-plugin-vuetify": "^1.0.2",
62
65
  "vuetify": "^3.3.6"
@@ -65,17 +68,21 @@
65
68
  "@antfu/eslint-config": "^0.39.6",
66
69
  "@antfu/ni": "^0.21.4",
67
70
  "@date-io/luxon": "^2.16.1",
68
- "@nuxt/devtools": "^0.6.6",
71
+ "@fortawesome/fontawesome-svg-core": "^6.4.0",
72
+ "@fortawesome/free-solid-svg-icons": "^6.4.0",
73
+ "@fortawesome/vue-fontawesome": "^3.0.3",
74
+ "@mdi/js": "^7.2.96",
75
+ "@nuxt/devtools": "^0.6.7",
69
76
  "@nuxt/module-builder": "^0.4.0",
70
- "@nuxt/schema": "^3.6.1",
71
- "@nuxt/test-utils": "^3.6.1",
72
- "@nuxtjs/i18n": "^8.0.0-beta.12",
77
+ "@nuxt/schema": "^3.6.2",
78
+ "@nuxt/test-utils": "^3.6.2",
79
+ "@nuxtjs/i18n": "^8.0.0-beta.13",
73
80
  "@parcel/watcher": "^2.1.0",
74
81
  "@types/node": "^18",
75
82
  "bumpp": "^9.1.1",
76
83
  "eslint": "^8.43.0",
77
84
  "luxon": "^3.3.0",
78
- "nuxt": "^3.6.1",
85
+ "nuxt": "^3.6.2",
79
86
  "sass": "^1.63.6",
80
87
  "typescript": "^5.1.6",
81
88
  "vite": "^4.3.9",
@@ -100,7 +107,11 @@
100
107
  },
101
108
  "pnpm": {
102
109
  "patchedDependencies": {
103
- "@nuxtjs/i18n@8.0.0-beta.12": "patches/@nuxtjs__i18n@8.0.0-beta.12.patch"
110
+ "@nuxtjs/i18n@8.0.0-beta.13": "patches/@nuxtjs__i18n@8.0.0-beta.13.patch"
104
111
  }
112
+ },
113
+ "stackblitz": {
114
+ "installDependencies": false,
115
+ "startCommand": "node .stackblitz.js && pnpm install && pnpm run dev"
105
116
  }
106
- }
117
+ }