@maz-ui/nuxt 5.0.0-beta.5 → 5.0.0-beta.50
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 +20 -0
- package/dist/module.json +4 -4
- package/dist/module.mjs +30 -2
- package/dist/runtime/plugins/defaults.d.ts +2 -0
- package/dist/runtime/plugins/defaults.js +8 -0
- package/dist/runtime/plugins/theme.js +48 -30
- package/package.json +16 -15
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
|
|
|
@@ -55,6 +56,19 @@ interface MazUiNuxtOptions {
|
|
|
55
56
|
* }
|
|
56
57
|
*/
|
|
57
58
|
translations?: MazUiTranslationsOptions;
|
|
59
|
+
/**
|
|
60
|
+
* Global default prop values for components
|
|
61
|
+
* @description Set default prop values once for every component, with the priority:
|
|
62
|
+
* instance prop > `defaults[Component]` > `defaults.global` > library default.
|
|
63
|
+
* A global default never wins over a prop set on the component instance.
|
|
64
|
+
* @default {}
|
|
65
|
+
* @example {
|
|
66
|
+
* global: { roundedSize: 'lg' },
|
|
67
|
+
* MazBtn: { roundedSize: 'full' },
|
|
68
|
+
* MazCard: { bordered: false, elevation: true },
|
|
69
|
+
* }
|
|
70
|
+
*/
|
|
71
|
+
defaults?: MazUiDefaultsOptions;
|
|
58
72
|
/**
|
|
59
73
|
* CSS and styles configuration
|
|
60
74
|
*/
|
|
@@ -223,6 +237,12 @@ interface MazUiNuxtOptions {
|
|
|
223
237
|
* @default true
|
|
224
238
|
*/
|
|
225
239
|
useSwipe?: boolean;
|
|
240
|
+
/**
|
|
241
|
+
* Enable auto-import of usePullToRefresh composable
|
|
242
|
+
* @description Headless pull to refresh gesture on a scroll container
|
|
243
|
+
* @default true
|
|
244
|
+
*/
|
|
245
|
+
usePullToRefresh?: boolean;
|
|
226
246
|
};
|
|
227
247
|
/**
|
|
228
248
|
* 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-beta.
|
|
7
|
+
"version": "5.0.0-beta.50",
|
|
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,7 +108,9 @@ 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: {
|
|
@@ -116,6 +133,7 @@ const defaults = {
|
|
|
116
133
|
fallbackLocale: "en",
|
|
117
134
|
preloadFallback: true
|
|
118
135
|
},
|
|
136
|
+
defaults: {},
|
|
119
137
|
components: {
|
|
120
138
|
autoImport: true
|
|
121
139
|
},
|
|
@@ -153,7 +171,7 @@ const module$1 = defineNuxtModule({
|
|
|
153
171
|
name: "maz-ui",
|
|
154
172
|
configKey: "mazUi",
|
|
155
173
|
compatibility: {
|
|
156
|
-
nuxt: ">=3.0.0"
|
|
174
|
+
nuxt: ">=3.4.0 <5.0.0"
|
|
157
175
|
}
|
|
158
176
|
},
|
|
159
177
|
defaults,
|
|
@@ -170,9 +188,19 @@ const module$1 = defineNuxtModule({
|
|
|
170
188
|
if (moduleOptions.css.injectCss) {
|
|
171
189
|
nuxt.options.css.unshift("maz-ui/style.css");
|
|
172
190
|
}
|
|
191
|
+
nuxt.options.postcss ??= { plugins: {}, order: [] };
|
|
192
|
+
nuxt.options.postcss.plugins ??= {};
|
|
193
|
+
const postcssPlugins = nuxt.options.postcss.plugins;
|
|
194
|
+
if (postcssPlugins.cssnano !== false) {
|
|
195
|
+
const current = typeof postcssPlugins.cssnano === "object" && postcssPlugins.cssnano !== null ? postcssPlugins.cssnano : {};
|
|
196
|
+
postcssPlugins.cssnano = { ...current, preset: ["default", { calc: false }] };
|
|
197
|
+
}
|
|
173
198
|
addPlugin(resolve(_dirname, "./runtime/plugins/theme"));
|
|
174
199
|
addPlugin(resolve(_dirname, "./runtime/plugins/translations"));
|
|
175
200
|
addPlugin(resolve(_dirname, "./runtime/plugins/maz-link-component"));
|
|
201
|
+
if (Object.keys(moduleOptions.defaults).length > 0) {
|
|
202
|
+
addPlugin(resolve(_dirname, "./runtime/plugins/defaults"));
|
|
203
|
+
}
|
|
176
204
|
if (moduleOptions.components.autoImport) {
|
|
177
205
|
for (const name of Object.keys(COMPONENT_NAMES)) {
|
|
178
206
|
addComponent({
|
|
@@ -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,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;
|
|
@@ -51,7 +47,7 @@ function injectThemeCSS(config) {
|
|
|
51
47
|
darkSelectorStrategy: config.darkModeStrategy,
|
|
52
48
|
prefix: "maz",
|
|
53
49
|
darkClass: config.darkClass,
|
|
54
|
-
|
|
50
|
+
lightClass: config.lightClass
|
|
55
51
|
});
|
|
56
52
|
useHead({
|
|
57
53
|
style: [{
|
|
@@ -60,26 +56,39 @@ function injectThemeCSS(config) {
|
|
|
60
56
|
}]
|
|
61
57
|
});
|
|
62
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
|
+
}
|
|
63
71
|
async function resolvePreset(options, persistPreset) {
|
|
64
|
-
const presetCookie = useCookie("maz-preset");
|
|
65
|
-
const savedName = persistPreset ? presetCookie.value : void 0;
|
|
66
72
|
const presetObject = options?.preset && typeof options.preset !== "string" ? options.preset : void 0;
|
|
67
|
-
|
|
68
|
-
|
|
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 };
|
|
69
78
|
}
|
|
70
|
-
if (
|
|
79
|
+
if (saved && saved.base === baseName && saved.active !== baseName) {
|
|
71
80
|
try {
|
|
72
|
-
return await getPreset(
|
|
81
|
+
return { preset: await getPreset(saved.active), baseName };
|
|
73
82
|
} catch {
|
|
74
|
-
presetCookie.value = null;
|
|
75
83
|
}
|
|
76
84
|
}
|
|
77
|
-
return
|
|
85
|
+
return { preset: basePreset, baseName };
|
|
78
86
|
}
|
|
79
87
|
export default defineNuxtPlugin(async ({ vueApp, $config }) => {
|
|
80
88
|
const options = $config.public.mazUi.theme;
|
|
81
89
|
const persistPreset = options?.persistPreset !== false;
|
|
82
|
-
|
|
90
|
+
const resolved = await resolvePreset(options, persistPreset);
|
|
91
|
+
let preset = resolved.preset;
|
|
83
92
|
if (options?.overrides) {
|
|
84
93
|
preset = mergePresets(preset, options.overrides);
|
|
85
94
|
}
|
|
@@ -89,13 +98,15 @@ export default defineNuxtPlugin(async ({ vueApp, $config }) => {
|
|
|
89
98
|
sameSite: "lax",
|
|
90
99
|
path: "/"
|
|
91
100
|
});
|
|
92
|
-
|
|
93
|
-
|
|
101
|
+
const value = `${resolved.baseName}:${preset.name}`;
|
|
102
|
+
if (presetCookie.value !== value) {
|
|
103
|
+
presetCookie.value = value;
|
|
94
104
|
}
|
|
95
105
|
}
|
|
96
106
|
const config = {
|
|
97
107
|
strategy: "runtime",
|
|
98
108
|
darkClass: "dark",
|
|
109
|
+
lightClass: "light",
|
|
99
110
|
darkModeStrategy: "class",
|
|
100
111
|
mode: "both",
|
|
101
112
|
overrides: {},
|
|
@@ -105,15 +116,22 @@ export default defineNuxtPlugin(async ({ vueApp, $config }) => {
|
|
|
105
116
|
preset
|
|
106
117
|
};
|
|
107
118
|
const isDark = config.colorMode === "auto" && config.mode === "both" ? getInitialColorMode() === "dark" : config.colorMode === "dark" || config.mode === "dark";
|
|
108
|
-
if (isDark && config.darkModeStrategy === "class") {
|
|
109
|
-
useHead({
|
|
110
|
-
htmlAttrs: {
|
|
111
|
-
class: config.darkClass
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
119
|
if (import.meta.server) {
|
|
120
|
+
if (isDark && config.darkModeStrategy === "class") {
|
|
121
|
+
useHead({
|
|
122
|
+
htmlAttrs: {
|
|
123
|
+
class: config.darkClass
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
116
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
|
+
});
|
|
117
135
|
if (config.colorMode === "auto" && config.mode === "both" && config.darkModeStrategy === "class") {
|
|
118
136
|
useHead({
|
|
119
137
|
script: [{ innerHTML: getColorModeBlockingScript(config), tagPosition: "head", id: "maz-color-mode-blocking" }],
|
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-beta.
|
|
4
|
+
"version": "5.0.0-beta.50",
|
|
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",
|
|
@@ -47,28 +48,28 @@
|
|
|
47
48
|
"nuxt": ">=3.4.0 <5.0.0"
|
|
48
49
|
},
|
|
49
50
|
"dependencies": {
|
|
51
|
+
"@maz-ui/themes": "5.0.0-beta.46",
|
|
52
|
+
"@maz-ui/translations": "5.0.0-beta.50",
|
|
53
|
+
"@maz-ui/utils": "5.0.0-beta.46",
|
|
50
54
|
"@nuxt/devtools-kit": "^3.2.3",
|
|
51
|
-
"@nuxt/kit": "^4.
|
|
55
|
+
"@nuxt/kit": "^4.5.2",
|
|
52
56
|
"defu": "^6.1.7",
|
|
53
|
-
"
|
|
54
|
-
"@maz-ui/utils": "5.0.0-beta.5",
|
|
55
|
-
"@maz-ui/translations": "5.0.0-beta.5",
|
|
56
|
-
"maz-ui": "5.0.0-beta.5"
|
|
57
|
+
"maz-ui": "5.0.0-beta.50"
|
|
57
58
|
},
|
|
58
59
|
"devDependencies": {
|
|
60
|
+
"@maz-ui/eslint-config": "5.0.0-beta.47",
|
|
59
61
|
"@nuxt/devtools": "^3.2.3",
|
|
60
|
-
"@nuxt/module-builder": "^1.0.
|
|
61
|
-
"@nuxt/schema": "^4.
|
|
62
|
-
"@nuxt/test-utils": "^4.
|
|
63
|
-
"nuxt": "^4.
|
|
62
|
+
"@nuxt/module-builder": "^1.0.3",
|
|
63
|
+
"@nuxt/schema": "^4.5.2",
|
|
64
|
+
"@nuxt/test-utils": "^4.3.3",
|
|
65
|
+
"nuxt": "^4.5.2"
|
|
64
66
|
},
|
|
65
67
|
"lint-staged": {
|
|
66
68
|
"*.{js,ts,mjs,mts,cjs,md,yml,json}": "cross-env NODE_ENV=production eslint --fix"
|
|
67
69
|
},
|
|
68
70
|
"scripts": {
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"dev": "nuxt-module-build build --stub && nuxt-module-build prepare",
|
|
71
|
+
"build": "pnpm dev && pnpm prepack",
|
|
72
|
+
"dev": "pnpm prepack --stub && nuxt-module-build prepare",
|
|
72
73
|
"test:unit": "vitest run",
|
|
73
74
|
"test:unit:watch": "vitest watch",
|
|
74
75
|
"test:unit:coverage": "vitest run --coverage",
|