@mframework/ui 0.0.6-beta2 → 0.0.6-beta3
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/module.ts +27 -24
- package/package.json +1 -1
- package/runtime/plugins/icon-switcher.ts +22 -12
package/module.ts
CHANGED
|
@@ -8,17 +8,18 @@ import {
|
|
|
8
8
|
} from '@nuxt/kit'
|
|
9
9
|
|
|
10
10
|
export interface MFrameworkUiOptions {
|
|
11
|
-
image
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
image ? : Record < string, any >
|
|
12
|
+
fonts ? : Record < string, any >
|
|
13
|
+
vuetify ? : {
|
|
14
|
+
vuetifyOptions ? : Record < string,
|
|
15
|
+
any >
|
|
16
|
+
}
|
|
17
|
+
tailwind ? : {
|
|
18
|
+
enable ? : boolean
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
21
|
|
|
21
|
-
export default defineNuxtModule<MFrameworkUiOptions>({
|
|
22
|
+
export default defineNuxtModule < MFrameworkUiOptions > ({
|
|
22
23
|
meta: {
|
|
23
24
|
name: '@mframework/ui',
|
|
24
25
|
configKey: 'mframeworkUi'
|
|
@@ -38,7 +39,9 @@ export default defineNuxtModule<MFrameworkUiOptions>({
|
|
|
38
39
|
}
|
|
39
40
|
},
|
|
40
41
|
async setup(options, nuxt) {
|
|
41
|
-
const {
|
|
42
|
+
const {
|
|
43
|
+
resolve
|
|
44
|
+
} = createResolver(import.meta.url)
|
|
42
45
|
|
|
43
46
|
//
|
|
44
47
|
// 1. Expose options to runtime
|
|
@@ -65,7 +68,9 @@ export default defineNuxtModule<MFrameworkUiOptions>({
|
|
|
65
68
|
// Use Node resolution from this project's root to detect installed package
|
|
66
69
|
// without triggering Nuxt's module loader.
|
|
67
70
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
68
|
-
const {
|
|
71
|
+
const {
|
|
72
|
+
createRequire
|
|
73
|
+
} = await import('module')
|
|
69
74
|
const req = createRequire(import.meta.url)
|
|
70
75
|
try {
|
|
71
76
|
req.resolve('vuetify')
|
|
@@ -92,7 +97,10 @@ export default defineNuxtModule<MFrameworkUiOptions>({
|
|
|
92
97
|
nuxt.options.css = nuxt.options.css || []
|
|
93
98
|
nuxt.options.css.push(resolve('./runtime/assets/css/tailwind.css'))
|
|
94
99
|
|
|
95
|
-
nuxt.options.postcss = nuxt.options.postcss || {
|
|
100
|
+
nuxt.options.postcss = nuxt.options.postcss || {
|
|
101
|
+
plugins: {},
|
|
102
|
+
order: []
|
|
103
|
+
}
|
|
96
104
|
nuxt.options.postcss.plugins = nuxt.options.postcss.plugins || {}
|
|
97
105
|
// Use the new PostCSS adapter package name so Nuxt doesn't try to
|
|
98
106
|
// use the old `tailwindcss` package as a PostCSS plugin.
|
|
@@ -108,19 +116,14 @@ export default defineNuxtModule<MFrameworkUiOptions>({
|
|
|
108
116
|
// 6. Register plugins (icons, theme, icon switching, search).
|
|
109
117
|
// Only register plugins that require Vuetify when Vuetify is available.
|
|
110
118
|
//
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
addPlugin(resolve('./runtime/search/plugin'))
|
|
120
|
-
} catch (e) {
|
|
121
|
-
// ignore — plugin not critical
|
|
122
|
-
}
|
|
123
|
-
}
|
|
119
|
+
// Install Vuetify first
|
|
120
|
+
await installModule(resolveModule('vuetify-nuxt-module'), {
|
|
121
|
+
vuetifyOptions: options.vuetify?.vuetifyOptions || {}
|
|
122
|
+
})
|
|
123
|
+
|
|
124
|
+
// THEN load plugins that depend on Vuetify
|
|
125
|
+
addPlugin(resolve('./runtime/plugins/theme'))
|
|
126
|
+
addPlugin(resolve('./runtime/plugins/icon-switcher'))
|
|
124
127
|
|
|
125
128
|
//
|
|
126
129
|
// 7. Auto-import components from this module
|
package/package.json
CHANGED
|
@@ -1,22 +1,32 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { defineNuxtPlugin } from '#app'
|
|
2
|
+
import { useVuetify } from 'vuetify-nuxt-module/runtime'
|
|
3
|
+
|
|
4
|
+
export default defineNuxtPlugin((nuxtApp) => {
|
|
5
|
+
const vuetify = useVuetify()
|
|
6
|
+
|
|
7
|
+
// If Vuetify isn't ready yet, skip plugin initialization
|
|
8
|
+
if (!vuetify || !vuetify.framework) {
|
|
9
|
+
console.warn('[mframework-ui] Vuetify not ready for icon-switcher plugin')
|
|
10
|
+
return
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const stored =
|
|
14
|
+
typeof localStorage !== 'undefined'
|
|
15
|
+
? localStorage.getItem('mframework-icon-set')
|
|
16
|
+
: null
|
|
2
17
|
|
|
3
|
-
export default (nuxtApp: any) => {
|
|
4
|
-
const stored = typeof localStorage !== 'undefined' ? localStorage.getItem('mframework-icon-set') : null
|
|
5
18
|
const initial = stored || 'mdi'
|
|
6
|
-
const framework = vuetify as any
|
|
7
19
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
;(vuetify as any).framework.icons = (vuetify as any).framework.icons || {}
|
|
11
|
-
;(vuetify as any).framework.icons.defaultSet = initial
|
|
20
|
+
vuetify.framework.icons = vuetify.framework.icons || {}
|
|
21
|
+
vuetify.framework.icons.defaultSet = initial
|
|
12
22
|
|
|
13
23
|
const setIconSet = (name: string) => {
|
|
14
|
-
|
|
15
|
-
|
|
24
|
+
vuetify.framework.icons.defaultSet = name
|
|
25
|
+
localStorage.setItem('mframework-icon-set', name)
|
|
16
26
|
}
|
|
17
27
|
|
|
18
28
|
nuxtApp.provide('mIcons', {
|
|
19
29
|
setIconSet,
|
|
20
|
-
current: () =>
|
|
30
|
+
current: () => vuetify.framework.icons.defaultSet
|
|
21
31
|
})
|
|
22
|
-
}
|
|
32
|
+
})
|