@maz-ui/nuxt 5.0.0-canary.ef64a02.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -1
- package/dist/module.d.mts +40 -0
- package/dist/module.json +4 -4
- package/dist/module.mjs +45 -3
- package/dist/runtime/plugins/aos.d.ts +2 -2
- package/dist/runtime/plugins/defaults.d.ts +2 -0
- package/dist/runtime/plugins/defaults.js +8 -0
- package/dist/runtime/plugins/dialog.d.ts +2 -2
- package/dist/runtime/plugins/local-flags.d.ts +2 -0
- package/dist/runtime/plugins/local-flags.js +13 -0
- package/dist/runtime/plugins/maz-icon-path.d.ts +2 -2
- package/dist/runtime/plugins/maz-link-component.d.ts +1 -1
- package/dist/runtime/plugins/prevent-ios-input-zoom.client.d.ts +5 -0
- package/dist/runtime/plugins/prevent-ios-input-zoom.client.js +13 -0
- package/dist/runtime/plugins/theme.d.ts +1 -1
- package/dist/runtime/plugins/theme.js +49 -30
- package/dist/runtime/plugins/toast.d.ts +2 -2
- package/dist/runtime/plugins/translations.d.ts +1 -1
- package/dist/runtime/plugins/v-click-outside.d.ts +1 -1
- package/dist/runtime/plugins/v-fullscreen-img.d.ts +1 -1
- package/dist/runtime/plugins/v-lazy-img.d.ts +1 -1
- package/dist/runtime/plugins/v-tooltip.d.ts +1 -1
- package/dist/runtime/plugins/v-zoom-img.d.ts +1 -1
- package/dist/runtime/plugins/wait.d.ts +2 -2
- package/package.json +21 -17
package/README.md
CHANGED
|
@@ -182,6 +182,13 @@ export default defineNuxtConfig({
|
|
|
182
182
|
autoImport: true, // Auto-import all components globally
|
|
183
183
|
},
|
|
184
184
|
|
|
185
|
+
// Global component defaults (instance prop > defaults[Component] > defaults.global > library default)
|
|
186
|
+
defaults: {
|
|
187
|
+
global: { roundedSize: 'lg' }, // cross-cutting (roundedSize, size)
|
|
188
|
+
MazBtn: { roundedSize: 'full' }, // per-component, wins over global
|
|
189
|
+
MazCard: { bordered: false, elevation: true },
|
|
190
|
+
},
|
|
191
|
+
|
|
185
192
|
// Composables (customize what you need)
|
|
186
193
|
composables: {
|
|
187
194
|
useTheme: true,
|
|
@@ -264,7 +271,7 @@ This module is built specifically for Nuxt with perfect SSR and SSG support:
|
|
|
264
271
|
|
|
265
272
|
## Learn More
|
|
266
273
|
|
|
267
|
-
- **[Full Documentation](https://maz-ui.com/
|
|
274
|
+
- **[Full Documentation](https://maz-ui.com/ecosystem/nuxt)**
|
|
268
275
|
- **[Report Issues](https://github.com/LouisMazel/maz-ui/issues)**
|
|
269
276
|
- **[Discussions](https://github.com/LouisMazel/maz-ui/discussions)**
|
|
270
277
|
|
package/dist/module.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as _nuxt_schema from '@nuxt/schema';
|
|
2
2
|
import { MazUiThemeOptions, ThemePreset, ThemePresetName } from '@maz-ui/themes';
|
|
3
3
|
import { MazUiTranslationsOptions } from '@maz-ui/translations';
|
|
4
|
+
import { MazUiDefaultsOptions } from 'maz-ui/composables/useGlobalConfig';
|
|
4
5
|
import { VLazyImgOptions, VFullscreenImgOptions, VTooltipOptions } from 'maz-ui/directives';
|
|
5
6
|
import { AosOptions, DialogOptions, ToastOptions } from 'maz-ui/plugins';
|
|
6
7
|
|
|
@@ -29,6 +30,14 @@ interface MazUiNuxtOptions {
|
|
|
29
30
|
* @default true
|
|
30
31
|
*/
|
|
31
32
|
devtools?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* Stop iOS from zooming the page when a form field gets the focus
|
|
35
|
+
* @description iOS zooms on fields with a font size below 16px. Adds `maximum-scale=1` to the viewport
|
|
36
|
+
* on iOS only: iOS still lets the user pinch to zoom, Android (which does not zoom on focus) is left untouched.
|
|
37
|
+
* The design of the fields is not changed.
|
|
38
|
+
* @default false
|
|
39
|
+
*/
|
|
40
|
+
preventIosInputZoom?: boolean;
|
|
32
41
|
};
|
|
33
42
|
/**
|
|
34
43
|
* Theme system configuration
|
|
@@ -55,6 +64,31 @@ interface MazUiNuxtOptions {
|
|
|
55
64
|
* }
|
|
56
65
|
*/
|
|
57
66
|
translations?: MazUiTranslationsOptions;
|
|
67
|
+
/**
|
|
68
|
+
* Global default prop values for components
|
|
69
|
+
* @description Set default prop values once for every component, with the priority:
|
|
70
|
+
* instance prop > `defaults[Component]` > `defaults.global` > library default.
|
|
71
|
+
* A global default never wins over a prop set on the component instance.
|
|
72
|
+
* @default {}
|
|
73
|
+
* @example {
|
|
74
|
+
* global: { roundedSize: 'lg' },
|
|
75
|
+
* MazBtn: { roundedSize: 'full' },
|
|
76
|
+
* MazCard: { bordered: false, elevation: true },
|
|
77
|
+
* }
|
|
78
|
+
*/
|
|
79
|
+
defaults?: MazUiDefaultsOptions;
|
|
80
|
+
/**
|
|
81
|
+
* Source of the country flags of `MazSelectCountry` and `MazInputPhoneNumber`
|
|
82
|
+
* @description
|
|
83
|
+
* - `'cdn'`: images of the flagcdn.com CDN
|
|
84
|
+
* - `'local'`: square flags of `@maz-ui/icons`, one chunk per flag, loaded only when visible, without any request to a third party (works offline)
|
|
85
|
+
* - a URL template of your own files, with `{code}` (lowercase) or `{CODE}` (uppercase): `'/flags/{code}.svg'`
|
|
86
|
+
*
|
|
87
|
+
* Sets the default of the `flag-src` prop (`defaults.global.flagSrc`): a `flag-src` set on a component wins.
|
|
88
|
+
* Nothing is added to the build of the app unless this option is `'local'`.
|
|
89
|
+
* @default 'cdn'
|
|
90
|
+
*/
|
|
91
|
+
flags?: 'cdn' | 'local' | (string & {});
|
|
58
92
|
/**
|
|
59
93
|
* CSS and styles configuration
|
|
60
94
|
*/
|
|
@@ -223,6 +257,12 @@ interface MazUiNuxtOptions {
|
|
|
223
257
|
* @default true
|
|
224
258
|
*/
|
|
225
259
|
useSwipe?: boolean;
|
|
260
|
+
/**
|
|
261
|
+
* Enable auto-import of usePullToRefresh composable
|
|
262
|
+
* @description Headless pull to refresh gesture on a scroll container
|
|
263
|
+
* @default true
|
|
264
|
+
*/
|
|
265
|
+
usePullToRefresh?: boolean;
|
|
226
266
|
};
|
|
227
267
|
/**
|
|
228
268
|
* Vue directives configuration
|
package/dist/module.json
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
"name": "maz-ui",
|
|
3
3
|
"configKey": "mazUi",
|
|
4
4
|
"compatibility": {
|
|
5
|
-
"nuxt": ">=3.0.0"
|
|
5
|
+
"nuxt": ">=3.4.0 <5.0.0"
|
|
6
6
|
},
|
|
7
|
-
"version": "5.0.0
|
|
7
|
+
"version": "5.0.0",
|
|
8
8
|
"builder": {
|
|
9
|
-
"@nuxt/module-builder": "1.0.
|
|
10
|
-
"unbuild": "
|
|
9
|
+
"@nuxt/module-builder": "1.0.3",
|
|
10
|
+
"unbuild": "unknown"
|
|
11
11
|
}
|
|
12
12
|
}
|
package/dist/module.mjs
CHANGED
|
@@ -25,6 +25,7 @@ const COMPONENT_NAMES = {
|
|
|
25
25
|
MazChecklist: true,
|
|
26
26
|
MazContainer: true,
|
|
27
27
|
MazCircularProgressBar: true,
|
|
28
|
+
MazCodeHighlight: true,
|
|
28
29
|
MazDialog: true,
|
|
29
30
|
MazDialogConfirm: true,
|
|
30
31
|
MazDrawer: true,
|
|
@@ -43,6 +44,7 @@ const COMPONENT_NAMES = {
|
|
|
43
44
|
MazLazyImg: true,
|
|
44
45
|
MazLink: true,
|
|
45
46
|
MazLoadingBar: true,
|
|
47
|
+
MazMarkdownEditor: true,
|
|
46
48
|
MazPagination: true,
|
|
47
49
|
MazDatePicker: true,
|
|
48
50
|
MazPullToRefresh: true,
|
|
@@ -57,6 +59,17 @@ const COMPONENT_NAMES = {
|
|
|
57
59
|
MazSpinner: true,
|
|
58
60
|
MazStepper: true,
|
|
59
61
|
MazSwitch: true,
|
|
62
|
+
MazSidebar: true,
|
|
63
|
+
MazSidebarMenu: true,
|
|
64
|
+
MazSidebarMenuItem: true,
|
|
65
|
+
MazSidebarMenuSub: true,
|
|
66
|
+
MazSidebarFooter: true,
|
|
67
|
+
MazSidebarHeader: true,
|
|
68
|
+
MazSidebarContent: true,
|
|
69
|
+
MazSidebarGroup: true,
|
|
70
|
+
MazSidebarMenuButton: true,
|
|
71
|
+
MazSidebarSeparator: true,
|
|
72
|
+
MazSidebarTrigger: true,
|
|
60
73
|
MazTable: true,
|
|
61
74
|
MazTableCell: true,
|
|
62
75
|
MazTableRow: true,
|
|
@@ -69,6 +82,7 @@ const COMPONENT_NAMES = {
|
|
|
69
82
|
MazTimeline: true,
|
|
70
83
|
MazTextarea: true,
|
|
71
84
|
MazUiProvider: true,
|
|
85
|
+
MazWindowMockup: true,
|
|
72
86
|
MazPopover: true
|
|
73
87
|
};
|
|
74
88
|
const _dirname = dirname(fileURLToPath(import.meta.url));
|
|
@@ -78,6 +92,7 @@ const pluginComposables = {
|
|
|
78
92
|
};
|
|
79
93
|
const mazUiComposables = {
|
|
80
94
|
useIdleTimeout: true,
|
|
95
|
+
useDrag: true,
|
|
81
96
|
useReadingTime: true,
|
|
82
97
|
useFormField: true,
|
|
83
98
|
useWindowSize: true,
|
|
@@ -93,13 +108,16 @@ const mazUiComposables = {
|
|
|
93
108
|
useInstanceUniqId: true,
|
|
94
109
|
useMountComponent: true,
|
|
95
110
|
useSwipe: true,
|
|
96
|
-
|
|
111
|
+
usePullToRefresh: true,
|
|
112
|
+
useMutationObserver: true,
|
|
113
|
+
useSidebar: true
|
|
97
114
|
};
|
|
98
115
|
const defaults = {
|
|
99
116
|
general: {
|
|
100
117
|
autoImportPrefix: "",
|
|
101
118
|
defaultMazIconPath: "",
|
|
102
|
-
devtools: true
|
|
119
|
+
devtools: true,
|
|
120
|
+
preventIosInputZoom: false
|
|
103
121
|
},
|
|
104
122
|
css: {
|
|
105
123
|
injectCss: true
|
|
@@ -116,6 +134,8 @@ const defaults = {
|
|
|
116
134
|
fallbackLocale: "en",
|
|
117
135
|
preloadFallback: true
|
|
118
136
|
},
|
|
137
|
+
defaults: {},
|
|
138
|
+
flags: "cdn",
|
|
119
139
|
components: {
|
|
120
140
|
autoImport: true
|
|
121
141
|
},
|
|
@@ -153,7 +173,7 @@ const module$1 = defineNuxtModule({
|
|
|
153
173
|
name: "maz-ui",
|
|
154
174
|
configKey: "mazUi",
|
|
155
175
|
compatibility: {
|
|
156
|
-
nuxt: ">=3.0.0"
|
|
176
|
+
nuxt: ">=3.4.0 <5.0.0"
|
|
157
177
|
}
|
|
158
178
|
},
|
|
159
179
|
defaults,
|
|
@@ -170,9 +190,28 @@ const module$1 = defineNuxtModule({
|
|
|
170
190
|
if (moduleOptions.css.injectCss) {
|
|
171
191
|
nuxt.options.css.unshift("maz-ui/style.css");
|
|
172
192
|
}
|
|
193
|
+
nuxt.options.postcss ??= { plugins: {}, order: [] };
|
|
194
|
+
nuxt.options.postcss.plugins ??= {};
|
|
195
|
+
const postcssPlugins = nuxt.options.postcss.plugins;
|
|
196
|
+
if (postcssPlugins.cssnano !== false) {
|
|
197
|
+
const current = typeof postcssPlugins.cssnano === "object" && postcssPlugins.cssnano !== null ? postcssPlugins.cssnano : {};
|
|
198
|
+
postcssPlugins.cssnano = { ...current, preset: ["default", { calc: false }] };
|
|
199
|
+
}
|
|
173
200
|
addPlugin(resolve(_dirname, "./runtime/plugins/theme"));
|
|
174
201
|
addPlugin(resolve(_dirname, "./runtime/plugins/translations"));
|
|
175
202
|
addPlugin(resolve(_dirname, "./runtime/plugins/maz-link-component"));
|
|
203
|
+
const flags = moduleOptions.flags;
|
|
204
|
+
if (flags && flags !== "cdn" && flags !== "local") {
|
|
205
|
+
moduleOptions.defaults = {
|
|
206
|
+
...moduleOptions.defaults,
|
|
207
|
+
global: { flagSrc: flags, ...moduleOptions.defaults.global }
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
if (flags === "local") {
|
|
211
|
+
addPlugin(resolve(_dirname, "./runtime/plugins/local-flags"));
|
|
212
|
+
} else if (Object.keys(moduleOptions.defaults).length > 0) {
|
|
213
|
+
addPlugin(resolve(_dirname, "./runtime/plugins/defaults"));
|
|
214
|
+
}
|
|
176
215
|
if (moduleOptions.components.autoImport) {
|
|
177
216
|
for (const name of Object.keys(COMPONENT_NAMES)) {
|
|
178
217
|
addComponent({
|
|
@@ -258,6 +297,9 @@ const module$1 = defineNuxtModule({
|
|
|
258
297
|
if (moduleOptions.general.defaultMazIconPath) {
|
|
259
298
|
addPlugin(resolve(_dirname, "./runtime/plugins/maz-icon-path"));
|
|
260
299
|
}
|
|
300
|
+
if (moduleOptions.general.preventIosInputZoom) {
|
|
301
|
+
addPlugin(resolve(_dirname, "./runtime/plugins/prevent-ios-input-zoom.client"));
|
|
302
|
+
}
|
|
261
303
|
if (moduleOptions.general.devtools) {
|
|
262
304
|
addCustomTab({
|
|
263
305
|
name: "maz-ui",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AosHandler } from 'maz-ui/plugins/aos';
|
|
2
|
-
declare const _default: import("nuxt
|
|
2
|
+
declare const _default: import("#app/nuxt").Plugin<{
|
|
3
3
|
mazAos: AosHandler;
|
|
4
|
-
}> & import("nuxt
|
|
4
|
+
}> & import("#app/nuxt").ObjectPlugin<{
|
|
5
5
|
mazAos: AosHandler;
|
|
6
6
|
}>;
|
|
7
7
|
export default _default;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { GLOBAL_CONFIG_INJECTION_KEY } from "maz-ui/composables/useGlobalConfig";
|
|
2
|
+
import { defineNuxtPlugin } from "nuxt/app";
|
|
3
|
+
export default defineNuxtPlugin(({ vueApp, $config }) => {
|
|
4
|
+
const defaults = $config.public.mazUi?.defaults;
|
|
5
|
+
if (defaults && Object.keys(defaults).length > 0) {
|
|
6
|
+
vueApp.provide(GLOBAL_CONFIG_INJECTION_KEY, defaults);
|
|
7
|
+
}
|
|
8
|
+
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { DialogHandler } from 'maz-ui/plugins/dialog';
|
|
2
|
-
declare const _default: import("nuxt
|
|
2
|
+
declare const _default: import("#app/nuxt").Plugin<{
|
|
3
3
|
mazDialog: DialogHandler;
|
|
4
|
-
}> & import("nuxt
|
|
4
|
+
}> & import("#app/nuxt").ObjectPlugin<{
|
|
5
5
|
mazDialog: DialogHandler;
|
|
6
6
|
}>;
|
|
7
7
|
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GLOBAL_CONFIG_INJECTION_KEY } from "maz-ui/composables/useGlobalConfig";
|
|
2
|
+
import { defineNuxtPlugin } from "nuxt/app";
|
|
3
|
+
async function loadCountryFlag(code) {
|
|
4
|
+
const { loadCountryFlag: loadCountryFlag2 } = await import("maz-ui/country-flags");
|
|
5
|
+
return loadCountryFlag2(code);
|
|
6
|
+
}
|
|
7
|
+
export default defineNuxtPlugin(({ vueApp, $config }) => {
|
|
8
|
+
const defaults = $config.public.mazUi?.defaults ?? {};
|
|
9
|
+
vueApp.provide(GLOBAL_CONFIG_INJECTION_KEY, {
|
|
10
|
+
...defaults,
|
|
11
|
+
global: { flagSrc: loadCountryFlag, ...defaults.global }
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: import("nuxt
|
|
1
|
+
declare const _default: import("#app/nuxt").Plugin<Record<string, unknown>> & import("#app/nuxt").ObjectPlugin<Record<string, unknown>>;
|
|
2
2
|
export default _default;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The viewport goes through `useHead`: unhead owns the meta and would overwrite a direct DOM change.
|
|
3
|
+
*/
|
|
4
|
+
declare const _default: import("#app/nuxt").Plugin<Record<string, unknown>> & import("#app/nuxt").ObjectPlugin<Record<string, unknown>>;
|
|
5
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { isIos } from "@maz-ui/utils/helpers/isIos";
|
|
2
|
+
import { addViewportMaximumScale } from "@maz-ui/utils/helpers/preventIosInputZoom";
|
|
3
|
+
import { defineNuxtPlugin, useHead } from "nuxt/app";
|
|
4
|
+
export default defineNuxtPlugin(() => {
|
|
5
|
+
if (!isIos())
|
|
6
|
+
return;
|
|
7
|
+
const content = document.querySelector('meta[name="viewport"]')?.getAttribute("content");
|
|
8
|
+
if (content == null)
|
|
9
|
+
return;
|
|
10
|
+
useHead({
|
|
11
|
+
meta: [{ name: "viewport", content: addViewportMaximumScale(content) }]
|
|
12
|
+
});
|
|
13
|
+
});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ThemeState } from '@maz-ui/themes';
|
|
2
2
|
import type { Ref } from 'vue';
|
|
3
|
-
declare const _default: import("nuxt
|
|
3
|
+
declare const _default: import("#app/nuxt").Plugin<Record<string, unknown>> & import("#app/nuxt").ObjectPlugin<Record<string, unknown>>;
|
|
4
4
|
export default _default;
|
|
5
5
|
declare module 'nuxt/app' {
|
|
6
6
|
interface NuxtApp {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MazUiTheme } from "@maz-ui/themes/plugin";
|
|
2
|
-
import { CSS_ID, generateCSS, getPreset, mergePresets } from "@maz-ui/themes/utils";
|
|
2
|
+
import { CSS_ID, generateCSS, getPreset, mergePresets, resolveColorSchemeContent } from "@maz-ui/themes/utils";
|
|
3
3
|
import { getSystemColorMode } from "@maz-ui/themes/utils/get-color-mode";
|
|
4
4
|
import { defineNuxtPlugin, useCookie, useHead, useRequestHeaders } from "nuxt/app";
|
|
5
5
|
function getSavedColorMode() {
|
|
@@ -17,11 +17,11 @@ function getSavedResolvedColorMode() {
|
|
|
17
17
|
return void 0;
|
|
18
18
|
}
|
|
19
19
|
function getInitialColorMode() {
|
|
20
|
-
const resolvedColorMode = getSavedResolvedColorMode();
|
|
21
|
-
if (resolvedColorMode) {
|
|
22
|
-
return resolvedColorMode;
|
|
23
|
-
}
|
|
24
20
|
if (import.meta.server) {
|
|
21
|
+
const resolvedColorMode = getSavedResolvedColorMode();
|
|
22
|
+
if (resolvedColorMode) {
|
|
23
|
+
return resolvedColorMode;
|
|
24
|
+
}
|
|
25
25
|
const headers = useRequestHeaders();
|
|
26
26
|
if (headers["sec-ch-prefers-color-scheme"] === "dark") {
|
|
27
27
|
return "dark";
|
|
@@ -30,13 +30,9 @@ function getInitialColorMode() {
|
|
|
30
30
|
if (userAgent?.includes("dark")) {
|
|
31
31
|
return "dark";
|
|
32
32
|
}
|
|
33
|
-
|
|
34
|
-
const systemColorMode = getSystemColorMode();
|
|
35
|
-
if (systemColorMode === "dark") {
|
|
36
|
-
return "dark";
|
|
37
|
-
}
|
|
33
|
+
return "auto";
|
|
38
34
|
}
|
|
39
|
-
return
|
|
35
|
+
return getSystemColorMode();
|
|
40
36
|
}
|
|
41
37
|
function getColorModeBlockingScript(config) {
|
|
42
38
|
const darkClass = config.darkClass;
|
|
@@ -50,7 +46,8 @@ function injectThemeCSS(config) {
|
|
|
50
46
|
mode: config.mode,
|
|
51
47
|
darkSelectorStrategy: config.darkModeStrategy,
|
|
52
48
|
prefix: "maz",
|
|
53
|
-
darkClass: config.darkClass
|
|
49
|
+
darkClass: config.darkClass,
|
|
50
|
+
lightClass: config.lightClass
|
|
54
51
|
});
|
|
55
52
|
useHead({
|
|
56
53
|
style: [{
|
|
@@ -59,26 +56,39 @@ function injectThemeCSS(config) {
|
|
|
59
56
|
}]
|
|
60
57
|
});
|
|
61
58
|
}
|
|
59
|
+
function parseSavedPreset(raw) {
|
|
60
|
+
if (!raw) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
const separatorIndex = raw.indexOf(":");
|
|
64
|
+
if (separatorIndex === -1) {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
const base = raw.slice(0, separatorIndex);
|
|
68
|
+
const active = raw.slice(separatorIndex + 1);
|
|
69
|
+
return base && active ? { base, active } : null;
|
|
70
|
+
}
|
|
62
71
|
async function resolvePreset(options, persistPreset) {
|
|
63
|
-
const presetCookie = useCookie("maz-preset");
|
|
64
|
-
const savedName = persistPreset ? presetCookie.value : void 0;
|
|
65
72
|
const presetObject = options?.preset && typeof options.preset !== "string" ? options.preset : void 0;
|
|
66
|
-
|
|
67
|
-
|
|
73
|
+
const saved = persistPreset ? parseSavedPreset(useCookie("maz-preset").value) : null;
|
|
74
|
+
const basePreset = presetObject ?? await getPreset(options?.preset);
|
|
75
|
+
const baseName = basePreset.name;
|
|
76
|
+
if (!persistPreset) {
|
|
77
|
+
return { preset: basePreset, baseName };
|
|
68
78
|
}
|
|
69
|
-
if (
|
|
79
|
+
if (saved && saved.base === baseName && saved.active !== baseName) {
|
|
70
80
|
try {
|
|
71
|
-
return await getPreset(
|
|
81
|
+
return { preset: await getPreset(saved.active), baseName };
|
|
72
82
|
} catch {
|
|
73
|
-
presetCookie.value = null;
|
|
74
83
|
}
|
|
75
84
|
}
|
|
76
|
-
return
|
|
85
|
+
return { preset: basePreset, baseName };
|
|
77
86
|
}
|
|
78
87
|
export default defineNuxtPlugin(async ({ vueApp, $config }) => {
|
|
79
88
|
const options = $config.public.mazUi.theme;
|
|
80
89
|
const persistPreset = options?.persistPreset !== false;
|
|
81
|
-
|
|
90
|
+
const resolved = await resolvePreset(options, persistPreset);
|
|
91
|
+
let preset = resolved.preset;
|
|
82
92
|
if (options?.overrides) {
|
|
83
93
|
preset = mergePresets(preset, options.overrides);
|
|
84
94
|
}
|
|
@@ -88,13 +98,15 @@ export default defineNuxtPlugin(async ({ vueApp, $config }) => {
|
|
|
88
98
|
sameSite: "lax",
|
|
89
99
|
path: "/"
|
|
90
100
|
});
|
|
91
|
-
|
|
92
|
-
|
|
101
|
+
const value = `${resolved.baseName}:${preset.name}`;
|
|
102
|
+
if (presetCookie.value !== value) {
|
|
103
|
+
presetCookie.value = value;
|
|
93
104
|
}
|
|
94
105
|
}
|
|
95
106
|
const config = {
|
|
96
107
|
strategy: "runtime",
|
|
97
108
|
darkClass: "dark",
|
|
109
|
+
lightClass: "light",
|
|
98
110
|
darkModeStrategy: "class",
|
|
99
111
|
mode: "both",
|
|
100
112
|
overrides: {},
|
|
@@ -104,15 +116,22 @@ export default defineNuxtPlugin(async ({ vueApp, $config }) => {
|
|
|
104
116
|
preset
|
|
105
117
|
};
|
|
106
118
|
const isDark = config.colorMode === "auto" && config.mode === "both" ? getInitialColorMode() === "dark" : config.colorMode === "dark" || config.mode === "dark";
|
|
107
|
-
if (isDark && config.darkModeStrategy === "class") {
|
|
108
|
-
useHead({
|
|
109
|
-
htmlAttrs: {
|
|
110
|
-
class: config.darkClass
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
119
|
if (import.meta.server) {
|
|
120
|
+
if (isDark && config.darkModeStrategy === "class") {
|
|
121
|
+
useHead({
|
|
122
|
+
htmlAttrs: {
|
|
123
|
+
class: config.darkClass
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
115
127
|
injectThemeCSS(config);
|
|
128
|
+
useHead({
|
|
129
|
+
meta: [{
|
|
130
|
+
name: "color-scheme",
|
|
131
|
+
content: resolveColorSchemeContent(config.mode, config.colorMode),
|
|
132
|
+
id: "maz-color-scheme"
|
|
133
|
+
}]
|
|
134
|
+
});
|
|
116
135
|
if (config.colorMode === "auto" && config.mode === "both" && config.darkModeStrategy === "class") {
|
|
117
136
|
useHead({
|
|
118
137
|
script: [{ innerHTML: getColorModeBlockingScript(config), tagPosition: "head", id: "maz-color-mode-blocking" }],
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ToastHandler } from 'maz-ui/plugins/toast';
|
|
2
|
-
declare const _default: import("nuxt
|
|
2
|
+
declare const _default: import("#app/nuxt").Plugin<{
|
|
3
3
|
mazToast: ToastHandler;
|
|
4
|
-
}> & import("nuxt
|
|
4
|
+
}> & import("#app/nuxt").ObjectPlugin<{
|
|
5
5
|
mazToast: ToastHandler;
|
|
6
6
|
}>;
|
|
7
7
|
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MazUiTranslationsInstance } from '@maz-ui/translations';
|
|
2
|
-
declare const _default: import("nuxt
|
|
2
|
+
declare const _default: import("#app/nuxt").Plugin<Record<string, unknown>> & import("#app/nuxt").ObjectPlugin<Record<string, unknown>>;
|
|
3
3
|
export default _default;
|
|
4
4
|
declare module 'nuxt/app' {
|
|
5
5
|
interface NuxtApp {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { VClickOutsideDirective } from 'maz-ui/directives/vClickOutside';
|
|
2
|
-
declare const _default: import("nuxt
|
|
2
|
+
declare const _default: import("#app/nuxt").Plugin<Record<string, unknown>> & import("#app/nuxt").ObjectPlugin<Record<string, unknown>>;
|
|
3
3
|
export default _default;
|
|
4
4
|
declare module 'vue' {
|
|
5
5
|
interface GlobalDirectives {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { VFullscreenImgDirective } from 'maz-ui/directives/vFullscreenImg';
|
|
2
|
-
declare const _default: import("nuxt
|
|
2
|
+
declare const _default: import("#app/nuxt").Plugin<Record<string, unknown>> & import("#app/nuxt").ObjectPlugin<Record<string, unknown>>;
|
|
3
3
|
export default _default;
|
|
4
4
|
declare module 'vue' {
|
|
5
5
|
interface GlobalDirectives {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { VLazyImgDirective } from 'maz-ui/directives/vLazyImg';
|
|
2
|
-
declare const _default: import("nuxt
|
|
2
|
+
declare const _default: import("#app/nuxt").Plugin<Record<string, unknown>> & import("#app/nuxt").ObjectPlugin<Record<string, unknown>>;
|
|
3
3
|
export default _default;
|
|
4
4
|
declare module 'vue' {
|
|
5
5
|
interface GlobalDirectives {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { VTooltipDirective } from 'maz-ui/directives/vTooltip';
|
|
2
|
-
declare const _default: import("nuxt
|
|
2
|
+
declare const _default: import("#app/nuxt").Plugin<Record<string, unknown>> & import("#app/nuxt").ObjectPlugin<Record<string, unknown>>;
|
|
3
3
|
export default _default;
|
|
4
4
|
declare module 'vue' {
|
|
5
5
|
interface GlobalDirectives {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { VZoomImgDirective } from 'maz-ui/directives/vZoomImg';
|
|
2
|
-
declare const _default: import("nuxt
|
|
2
|
+
declare const _default: import("#app/nuxt").Plugin<Record<string, unknown>> & import("#app/nuxt").ObjectPlugin<Record<string, unknown>>;
|
|
3
3
|
export default _default;
|
|
4
4
|
declare module 'vue' {
|
|
5
5
|
interface GlobalDirectives {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { WaitHandler } from 'maz-ui/plugins/wait';
|
|
2
|
-
declare const _default: import("nuxt
|
|
2
|
+
declare const _default: import("#app/nuxt").Plugin<{
|
|
3
3
|
mazWait: WaitHandler;
|
|
4
|
-
}> & import("nuxt
|
|
4
|
+
}> & import("#app/nuxt").ObjectPlugin<{
|
|
5
5
|
mazWait: WaitHandler;
|
|
6
6
|
}>;
|
|
7
7
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maz-ui/nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.0.0
|
|
4
|
+
"version": "5.0.0",
|
|
5
5
|
"description": "Nuxt module for Maz-UI",
|
|
6
6
|
"author": "Louis Mazel <me@loicmazuel.com>",
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"homepage": "https://maz-ui.com/
|
|
8
|
+
"homepage": "https://maz-ui.com/ecosystem/nuxt",
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
11
11
|
"url": "git+https://github.com/LouisMazel/maz-ui.git"
|
|
@@ -33,7 +33,8 @@
|
|
|
33
33
|
"exports": {
|
|
34
34
|
".": {
|
|
35
35
|
"types": "./dist/types.d.mts",
|
|
36
|
-
"import": "./dist/module.mjs"
|
|
36
|
+
"import": "./dist/module.mjs",
|
|
37
|
+
"default": "./dist/module.mjs"
|
|
37
38
|
}
|
|
38
39
|
},
|
|
39
40
|
"main": "./dist/module.mjs",
|
|
@@ -43,32 +44,35 @@
|
|
|
43
44
|
"README.md",
|
|
44
45
|
"dist"
|
|
45
46
|
],
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=22.12.0"
|
|
49
|
+
},
|
|
46
50
|
"peerDependencies": {
|
|
47
51
|
"nuxt": ">=3.4.0 <5.0.0"
|
|
48
52
|
},
|
|
49
53
|
"dependencies": {
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
54
|
+
"@maz-ui/themes": "5.0.0",
|
|
55
|
+
"@maz-ui/translations": "5.0.0",
|
|
56
|
+
"@maz-ui/utils": "5.0.0",
|
|
57
|
+
"@nuxt/devtools-kit": "^3.4.4",
|
|
58
|
+
"@nuxt/kit": "^4.6.2",
|
|
52
59
|
"defu": "^6.1.7",
|
|
53
|
-
"
|
|
54
|
-
"@maz-ui/themes": "5.0.0-canary.ef64a02.0",
|
|
55
|
-
"maz-ui": "5.0.0-canary.ef64a02.0",
|
|
56
|
-
"@maz-ui/translations": "5.0.0-canary.ef64a02.0"
|
|
60
|
+
"maz-ui": "5.0.0"
|
|
57
61
|
},
|
|
58
62
|
"devDependencies": {
|
|
59
|
-
"@
|
|
60
|
-
"@nuxt/
|
|
61
|
-
"@nuxt/
|
|
62
|
-
"@nuxt/
|
|
63
|
-
"nuxt": "^4.
|
|
63
|
+
"@maz-ui/eslint-config": "5.0.0",
|
|
64
|
+
"@nuxt/devtools": "^3.4.4",
|
|
65
|
+
"@nuxt/module-builder": "^1.0.3",
|
|
66
|
+
"@nuxt/schema": "^4.6.2",
|
|
67
|
+
"@nuxt/test-utils": "^4.3.4",
|
|
68
|
+
"nuxt": "^4.6.2"
|
|
64
69
|
},
|
|
65
70
|
"lint-staged": {
|
|
66
71
|
"*.{js,ts,mjs,mts,cjs,md,yml,json}": "cross-env NODE_ENV=production eslint --fix"
|
|
67
72
|
},
|
|
68
73
|
"scripts": {
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"dev": "nuxt-module-build build --stub && nuxt-module-build prepare",
|
|
74
|
+
"build": "pnpm dev && pnpm prepack",
|
|
75
|
+
"dev": "pnpm prepack --stub && nuxt-module-build prepare",
|
|
72
76
|
"test:unit": "vitest run",
|
|
73
77
|
"test:unit:watch": "vitest watch",
|
|
74
78
|
"test:unit:coverage": "vitest run --coverage",
|