@maz-ui/nuxt 4.0.0-beta.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/LICENSE +21 -0
- package/README.md +299 -0
- package/dist/module.d.mts +275 -0
- package/dist/module.json +12 -0
- package/dist/module.mjs +348 -0
- package/dist/runtime/composables/useAos.d.ts +2 -0
- package/dist/runtime/composables/useAos.js +5 -0
- package/dist/runtime/composables/useDialog.d.ts +2 -0
- package/dist/runtime/composables/useDialog.js +5 -0
- package/dist/runtime/composables/useToast.d.ts +2 -0
- package/dist/runtime/composables/useToast.js +5 -0
- package/dist/runtime/composables/useWait.d.ts +2 -0
- package/dist/runtime/composables/useWait.js +5 -0
- package/dist/runtime/plugins/aos.d.ts +12 -0
- package/dist/runtime/plugins/aos.js +12 -0
- package/dist/runtime/plugins/dialog.d.ts +12 -0
- package/dist/runtime/plugins/dialog.js +23 -0
- package/dist/runtime/plugins/maz-icon-path.d.ts +11 -0
- package/dist/runtime/plugins/maz-icon-path.js +10 -0
- package/dist/runtime/plugins/theme.d.ts +8 -0
- package/dist/runtime/plugins/theme.js +92 -0
- package/dist/runtime/plugins/toast.d.ts +12 -0
- package/dist/runtime/plugins/toast.js +26 -0
- package/dist/runtime/plugins/translations.d.ts +8 -0
- package/dist/runtime/plugins/translations.js +6 -0
- package/dist/runtime/plugins/v-click-outside.d.ts +2 -0
- package/dist/runtime/plugins/v-click-outside.js +5 -0
- package/dist/runtime/plugins/v-fullscreen-img.d.ts +2 -0
- package/dist/runtime/plugins/v-fullscreen-img.js +5 -0
- package/dist/runtime/plugins/v-lazy-img.d.ts +2 -0
- package/dist/runtime/plugins/v-lazy-img.js +7 -0
- package/dist/runtime/plugins/v-tooltip.d.ts +2 -0
- package/dist/runtime/plugins/v-tooltip.js +7 -0
- package/dist/runtime/plugins/v-zoom-img.d.ts +2 -0
- package/dist/runtime/plugins/v-zoom-img.js +5 -0
- package/dist/runtime/plugins/wait.d.ts +12 -0
- package/dist/runtime/plugins/wait.js +18 -0
- package/dist/types.d.mts +7 -0
- package/package.json +80 -0
package/dist/module.mjs
ADDED
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { dirname } from 'node:path';
|
|
2
|
+
import { fileURLToPath } from 'node:url';
|
|
3
|
+
import { defineNuxtModule, createResolver, addPlugin, addComponent, addImports } from '@nuxt/kit';
|
|
4
|
+
import { defu } from 'defu';
|
|
5
|
+
import { capitalize } from 'maz-ui';
|
|
6
|
+
|
|
7
|
+
const COMPONENT_NAMES = {
|
|
8
|
+
MazAccordion: true,
|
|
9
|
+
MazAnimatedCounter: true,
|
|
10
|
+
MazAnimatedElement: true,
|
|
11
|
+
MazAnimatedText: true,
|
|
12
|
+
MazAvatar: true,
|
|
13
|
+
MazBackdrop: true,
|
|
14
|
+
MazBadge: true,
|
|
15
|
+
MazBottomSheet: true,
|
|
16
|
+
MazBtn: true,
|
|
17
|
+
MazCard: true,
|
|
18
|
+
MazCardSpotlight: true,
|
|
19
|
+
MazCarousel: true,
|
|
20
|
+
MazChart: true,
|
|
21
|
+
MazCheckbox: true,
|
|
22
|
+
MazChecklist: true,
|
|
23
|
+
MazCircularProgressBar: true,
|
|
24
|
+
MazDialog: true,
|
|
25
|
+
MazDialogPromise: true,
|
|
26
|
+
MazDrawer: true,
|
|
27
|
+
MazDropdown: true,
|
|
28
|
+
MazDropzone: true,
|
|
29
|
+
MazExpandAnimation: true,
|
|
30
|
+
MazFullscreenLoader: true,
|
|
31
|
+
MazGallery: true,
|
|
32
|
+
MazIcon: true,
|
|
33
|
+
MazInput: true,
|
|
34
|
+
MazInputCode: true,
|
|
35
|
+
MazInputNumber: true,
|
|
36
|
+
MazInputPhoneNumber: true,
|
|
37
|
+
MazInputPrice: true,
|
|
38
|
+
MazInputTags: true,
|
|
39
|
+
MazLazyImg: true,
|
|
40
|
+
MazLink: true,
|
|
41
|
+
MazLoadingBar: true,
|
|
42
|
+
MazPagination: true,
|
|
43
|
+
MazDatePicker: true,
|
|
44
|
+
MazPullToRefresh: true,
|
|
45
|
+
MazRadio: true,
|
|
46
|
+
MazRadioButtons: true,
|
|
47
|
+
MazReadingProgressBar: true,
|
|
48
|
+
MazSelect: true,
|
|
49
|
+
MazSelectCountry: true,
|
|
50
|
+
MazSlider: true,
|
|
51
|
+
MazSpinner: true,
|
|
52
|
+
MazStepper: true,
|
|
53
|
+
MazSwitch: true,
|
|
54
|
+
MazTable: true,
|
|
55
|
+
MazTableCell: true,
|
|
56
|
+
MazTableRow: true,
|
|
57
|
+
MazTableTitle: true,
|
|
58
|
+
MazTabs: true,
|
|
59
|
+
MazTabsBar: true,
|
|
60
|
+
MazTabsContent: true,
|
|
61
|
+
MazTabsContentItem: true,
|
|
62
|
+
MazTextarea: true,
|
|
63
|
+
MazPopover: true
|
|
64
|
+
};
|
|
65
|
+
const _dirname = dirname(fileURLToPath(import.meta.url));
|
|
66
|
+
const defaults = {
|
|
67
|
+
general: {
|
|
68
|
+
autoImportPrefix: "",
|
|
69
|
+
defaultMazIconPath: "",
|
|
70
|
+
devtools: true
|
|
71
|
+
},
|
|
72
|
+
css: {
|
|
73
|
+
injectMainCss: true
|
|
74
|
+
},
|
|
75
|
+
theme: {
|
|
76
|
+
preset: "maz-ui",
|
|
77
|
+
strategy: "hybrid",
|
|
78
|
+
darkModeStrategy: "class",
|
|
79
|
+
prefix: "maz",
|
|
80
|
+
colorMode: "auto"
|
|
81
|
+
},
|
|
82
|
+
translations: {
|
|
83
|
+
locale: "en"
|
|
84
|
+
},
|
|
85
|
+
components: {
|
|
86
|
+
autoImport: true
|
|
87
|
+
},
|
|
88
|
+
composables: {
|
|
89
|
+
useTheme: true,
|
|
90
|
+
useAos: true,
|
|
91
|
+
useToast: true,
|
|
92
|
+
useDialog: true,
|
|
93
|
+
useWait: true,
|
|
94
|
+
useIdleTimeout: true,
|
|
95
|
+
useReadingTime: true,
|
|
96
|
+
useTranslations: true,
|
|
97
|
+
useFormField: true,
|
|
98
|
+
useWindowSize: true,
|
|
99
|
+
useBreakpoints: true,
|
|
100
|
+
useUserVisibility: true,
|
|
101
|
+
useStringMatching: true,
|
|
102
|
+
useTimer: true,
|
|
103
|
+
useFormValidator: true,
|
|
104
|
+
useDisplayNames: true,
|
|
105
|
+
useFreezeValue: true,
|
|
106
|
+
useInjectStrict: true,
|
|
107
|
+
useInstanceUniqId: true,
|
|
108
|
+
useMountComponent: true,
|
|
109
|
+
useSwipe: true
|
|
110
|
+
},
|
|
111
|
+
directives: {
|
|
112
|
+
vZoomImg: false,
|
|
113
|
+
vLazyImg: false,
|
|
114
|
+
vClickOutside: false,
|
|
115
|
+
vFullscreenImg: false,
|
|
116
|
+
vTooltip: false
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
function addComposableImport({
|
|
120
|
+
name,
|
|
121
|
+
from,
|
|
122
|
+
prefix = ""
|
|
123
|
+
}) {
|
|
124
|
+
addImports({
|
|
125
|
+
from,
|
|
126
|
+
name,
|
|
127
|
+
// typeFrom: `maz-ui/dist/types/composables/${name}.d.ts`,
|
|
128
|
+
as: `use${capitalize(prefix)}${name.replace("use", "")}`
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const module = defineNuxtModule({
|
|
132
|
+
meta: {
|
|
133
|
+
name: "maz-ui",
|
|
134
|
+
configKey: "mazUi",
|
|
135
|
+
compatibility: {
|
|
136
|
+
nuxt: ">=3.0.0"
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
defaults,
|
|
140
|
+
/* eslint-disable complexity, sonarjs/cognitive-complexity */
|
|
141
|
+
setup(options, nuxt) {
|
|
142
|
+
const { resolve } = createResolver(import.meta.url);
|
|
143
|
+
nuxt.options.build.transpile = ["maz-ui", "@maz-ui/themes", ...nuxt.options.build.transpile];
|
|
144
|
+
const moduleOptions = defu(nuxt.options.runtimeConfig.public.mazUi, options, defaults);
|
|
145
|
+
nuxt.options.runtimeConfig.public.mazUi = moduleOptions;
|
|
146
|
+
if (moduleOptions.css.injectMainCss) {
|
|
147
|
+
nuxt.options.css = ["maz-ui/dist/css/main.css", ...nuxt.options.css];
|
|
148
|
+
}
|
|
149
|
+
addPlugin(resolve(_dirname, "./runtime/plugins/theme"));
|
|
150
|
+
addPlugin(resolve(_dirname, "./runtime/plugins/translations"));
|
|
151
|
+
if (moduleOptions.components.autoImport) {
|
|
152
|
+
for (const name of Object.keys(COMPONENT_NAMES)) {
|
|
153
|
+
addComponent({
|
|
154
|
+
name,
|
|
155
|
+
filePath: `maz-ui/components/${name}`
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (moduleOptions.composables.useAos) {
|
|
160
|
+
addPlugin(resolve(_dirname, "./runtime/plugins/aos"));
|
|
161
|
+
addComposableImport({
|
|
162
|
+
name: "useAos",
|
|
163
|
+
from: resolve(_dirname, "./runtime/composables/useAos"),
|
|
164
|
+
prefix: moduleOptions.general?.autoImportPrefix
|
|
165
|
+
});
|
|
166
|
+
const injectAosCSS = typeof moduleOptions.composables.useAos === "object" && typeof moduleOptions.composables.useAos.injectCss === "boolean" ? moduleOptions.composables.useAos.injectCss : true;
|
|
167
|
+
if (injectAosCSS) {
|
|
168
|
+
nuxt.options.css = ["maz-ui/aos-styles", ...nuxt.options.css];
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (moduleOptions.directives.vZoomImg) {
|
|
172
|
+
addPlugin(resolve(_dirname, "./runtime/plugins/v-zoom-img"));
|
|
173
|
+
}
|
|
174
|
+
if (moduleOptions.directives.vLazyImg) {
|
|
175
|
+
addPlugin(resolve(_dirname, "./runtime/plugins/v-lazy-img"));
|
|
176
|
+
}
|
|
177
|
+
if (moduleOptions.directives.vClickOutside) {
|
|
178
|
+
addPlugin(resolve(_dirname, "./runtime/plugins/v-click-outside"));
|
|
179
|
+
}
|
|
180
|
+
if (moduleOptions.directives.vFullscreenImg) {
|
|
181
|
+
addPlugin(resolve(_dirname, "./runtime/plugins/v-fullscreen-img"));
|
|
182
|
+
}
|
|
183
|
+
if (moduleOptions.directives.vTooltip) {
|
|
184
|
+
addPlugin(resolve(_dirname, "./runtime/plugins/v-tooltip"));
|
|
185
|
+
}
|
|
186
|
+
if (moduleOptions.composables.useToast) {
|
|
187
|
+
addPlugin(resolve(_dirname, "./runtime/plugins/toast"));
|
|
188
|
+
addComposableImport({
|
|
189
|
+
name: "useToast",
|
|
190
|
+
from: resolve(_dirname, "./runtime/composables/useToast"),
|
|
191
|
+
prefix: moduleOptions.general?.autoImportPrefix
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
if (moduleOptions.composables.useDialog) {
|
|
195
|
+
addPlugin(resolve(_dirname, "./runtime/plugins/dialog"));
|
|
196
|
+
addComposableImport({
|
|
197
|
+
name: "useDialog",
|
|
198
|
+
from: resolve(_dirname, "./runtime/composables/useDialog"),
|
|
199
|
+
prefix: moduleOptions.general?.autoImportPrefix
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
if (moduleOptions.composables.useWait) {
|
|
203
|
+
addPlugin(resolve(_dirname, "./runtime/plugins/wait"));
|
|
204
|
+
addComposableImport({
|
|
205
|
+
name: "useWait",
|
|
206
|
+
from: resolve(_dirname, "./runtime/composables/useWait"),
|
|
207
|
+
prefix: moduleOptions.general?.autoImportPrefix
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
if (moduleOptions.composables.useIdleTimeout) {
|
|
211
|
+
addComposableImport({
|
|
212
|
+
name: "useIdleTimeout",
|
|
213
|
+
from: "maz-ui/composables/useIdleTimeout",
|
|
214
|
+
prefix: moduleOptions.general?.autoImportPrefix
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
if (moduleOptions.composables.useReadingTime) {
|
|
218
|
+
addComposableImport({
|
|
219
|
+
name: "useReadingTime",
|
|
220
|
+
from: "maz-ui/composables/useReadingTime",
|
|
221
|
+
prefix: moduleOptions.general?.autoImportPrefix
|
|
222
|
+
});
|
|
223
|
+
}
|
|
224
|
+
if (moduleOptions.composables.useWindowSize) {
|
|
225
|
+
addComposableImport({
|
|
226
|
+
name: "useWindowSize",
|
|
227
|
+
from: "maz-ui/composables/useWindowSize",
|
|
228
|
+
prefix: moduleOptions.general?.autoImportPrefix
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
if (moduleOptions.composables.useBreakpoints) {
|
|
232
|
+
addImports({
|
|
233
|
+
from: "maz-ui/composables/useBreakpoints",
|
|
234
|
+
name: "useBreakpoints",
|
|
235
|
+
as: "useBreakpoints"
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
if (moduleOptions.composables.useUserVisibility) {
|
|
239
|
+
addComposableImport({
|
|
240
|
+
name: "useUserVisibility",
|
|
241
|
+
from: "maz-ui/composables/useUserVisibility",
|
|
242
|
+
prefix: moduleOptions.general?.autoImportPrefix
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
if (moduleOptions.composables.useStringMatching) {
|
|
246
|
+
addComposableImport({
|
|
247
|
+
name: "useStringMatching",
|
|
248
|
+
from: "maz-ui/composables/useStringMatching",
|
|
249
|
+
prefix: moduleOptions.general?.autoImportPrefix
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
if (moduleOptions.composables.useTimer) {
|
|
253
|
+
addComposableImport({
|
|
254
|
+
name: "useTimer",
|
|
255
|
+
from: "maz-ui/composables/useTimer",
|
|
256
|
+
prefix: moduleOptions.general?.autoImportPrefix
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
if (moduleOptions.composables.useFreezeValue) {
|
|
260
|
+
addComposableImport({
|
|
261
|
+
name: "useFreezeValue",
|
|
262
|
+
from: "maz-ui/composables/useFreezeValue",
|
|
263
|
+
prefix: moduleOptions.general?.autoImportPrefix
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
if (moduleOptions.composables.useInjectStrict) {
|
|
267
|
+
addComposableImport({
|
|
268
|
+
name: "useInjectStrict",
|
|
269
|
+
from: "maz-ui/composables/useInjectStrict",
|
|
270
|
+
prefix: moduleOptions.general?.autoImportPrefix
|
|
271
|
+
});
|
|
272
|
+
}
|
|
273
|
+
if (moduleOptions.composables.useInstanceUniqId) {
|
|
274
|
+
addComposableImport({
|
|
275
|
+
name: "useInstanceUniqId",
|
|
276
|
+
from: "maz-ui/composables/useInstanceUniqId",
|
|
277
|
+
prefix: moduleOptions.general?.autoImportPrefix
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
if (moduleOptions.composables.useMountComponent) {
|
|
281
|
+
addComposableImport({
|
|
282
|
+
name: "useMountComponent",
|
|
283
|
+
from: "maz-ui/composables/useMountComponent",
|
|
284
|
+
prefix: moduleOptions.general?.autoImportPrefix
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
if (moduleOptions.composables.useSwipe) {
|
|
288
|
+
addComposableImport({
|
|
289
|
+
name: "useSwipe",
|
|
290
|
+
from: "maz-ui/composables/useSwipe",
|
|
291
|
+
prefix: moduleOptions.general?.autoImportPrefix
|
|
292
|
+
});
|
|
293
|
+
}
|
|
294
|
+
if (moduleOptions.composables.useFormValidator) {
|
|
295
|
+
addComposableImport({
|
|
296
|
+
name: "useFormValidator",
|
|
297
|
+
from: "maz-ui/composables/useFormValidator",
|
|
298
|
+
prefix: moduleOptions.general?.autoImportPrefix
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
if (moduleOptions.composables.useFormField) {
|
|
302
|
+
addComposableImport({
|
|
303
|
+
name: "useFormField",
|
|
304
|
+
from: "maz-ui/composables/useFormField",
|
|
305
|
+
prefix: moduleOptions.general?.autoImportPrefix
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
if (moduleOptions.composables.useDisplayNames) {
|
|
309
|
+
addComposableImport({
|
|
310
|
+
name: "useDisplayNames",
|
|
311
|
+
from: "maz-ui/composables/useDisplayNames",
|
|
312
|
+
prefix: moduleOptions.general?.autoImportPrefix
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
if (moduleOptions.composables.useTheme) {
|
|
316
|
+
addComposableImport({
|
|
317
|
+
name: "useTheme",
|
|
318
|
+
from: "@maz-ui/themes/composables/useTheme",
|
|
319
|
+
prefix: moduleOptions.general?.autoImportPrefix
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
if (moduleOptions.composables.useTranslations) {
|
|
323
|
+
addComposableImport({
|
|
324
|
+
name: "useTranslations",
|
|
325
|
+
from: "@maz-ui/translations",
|
|
326
|
+
prefix: moduleOptions.general?.autoImportPrefix
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
if (moduleOptions.general.defaultMazIconPath) {
|
|
330
|
+
addPlugin(resolve(_dirname, "./runtime/plugins/maz-icon-path"));
|
|
331
|
+
}
|
|
332
|
+
if (moduleOptions.general.devtools) {
|
|
333
|
+
nuxt.hook("devtools:customTabs", (iframeTabs) => {
|
|
334
|
+
iframeTabs.push({
|
|
335
|
+
name: "maz-ui",
|
|
336
|
+
title: "maz-ui",
|
|
337
|
+
icon: "https://maz-ui.com/img/icons/android-chrome-512x512.png",
|
|
338
|
+
view: {
|
|
339
|
+
type: "iframe",
|
|
340
|
+
src: "https://maz-ui.com"
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
export { module as default };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AosHandler } from 'maz-ui/plugins/aos';
|
|
2
|
+
declare const _default: import("#app").Plugin<{
|
|
3
|
+
mazAos: AosHandler;
|
|
4
|
+
}> & import("#app").ObjectPlugin<{
|
|
5
|
+
mazAos: AosHandler;
|
|
6
|
+
}>;
|
|
7
|
+
export default _default;
|
|
8
|
+
declare module '#app' {
|
|
9
|
+
interface NuxtApp {
|
|
10
|
+
$mazAos: AosHandler;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AosHandler, AosPlugin } from "maz-ui/plugins/aos";
|
|
2
|
+
import { defineNuxtPlugin, useRouter } from "nuxt/app";
|
|
3
|
+
export default defineNuxtPlugin(({ $config, vueApp }) => {
|
|
4
|
+
const aosOptions = $config.public.mazUi?.composables?.useAos;
|
|
5
|
+
const options = typeof aosOptions === "object" ? { ...aosOptions, router: aosOptions.router ? useRouter() : void 0 } : {};
|
|
6
|
+
vueApp.use(AosPlugin, options);
|
|
7
|
+
return {
|
|
8
|
+
provide: {
|
|
9
|
+
mazAos: new AosHandler(options)
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { DialogHandler } from 'maz-ui/plugins/dialog';
|
|
2
|
+
declare const _default: import("#app").Plugin<{
|
|
3
|
+
mazDialog: DialogHandler;
|
|
4
|
+
}> & import("#app").ObjectPlugin<{
|
|
5
|
+
mazDialog: DialogHandler;
|
|
6
|
+
}>;
|
|
7
|
+
export default _default;
|
|
8
|
+
declare module '#app' {
|
|
9
|
+
interface NuxtApp {
|
|
10
|
+
$mazDialog: DialogHandler;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DialogHandler } from "maz-ui/plugins/dialog";
|
|
2
|
+
import { defineNuxtPlugin } from "nuxt/app";
|
|
3
|
+
export default defineNuxtPlugin(({ vueApp, $config }) => {
|
|
4
|
+
const dialogOptions = $config.public.mazUi?.composables?.useDialog;
|
|
5
|
+
const options = typeof dialogOptions === "object" ? dialogOptions : void 0;
|
|
6
|
+
const instance = new DialogHandler(vueApp, options);
|
|
7
|
+
const dialogServer = {
|
|
8
|
+
open: () => {
|
|
9
|
+
return {
|
|
10
|
+
promise: Promise.resolve(),
|
|
11
|
+
destroy: () => {
|
|
12
|
+
},
|
|
13
|
+
close: () => {
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
return {
|
|
19
|
+
provide: {
|
|
20
|
+
mazDialog: import.meta.server ? dialogServer : instance
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { defineNuxtPlugin } from "nuxt/app";
|
|
2
|
+
export default defineNuxtPlugin(({ $config, vueApp }) => {
|
|
3
|
+
const defaultMazIconPath = $config.public.mazUi?.general?.defaultMazIconPath;
|
|
4
|
+
vueApp.provide("mazIconPath", defaultMazIconPath);
|
|
5
|
+
return {
|
|
6
|
+
provide: {
|
|
7
|
+
mazIconPath: defaultMazIconPath
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type ThemeState } from '@maz-ui/themes';
|
|
2
|
+
declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
|
|
3
|
+
export default _default;
|
|
4
|
+
declare module '#app' {
|
|
5
|
+
interface NuxtApp {
|
|
6
|
+
$mazThemeState: ThemeState;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {
|
|
2
|
+
generateFullCSS,
|
|
3
|
+
mergePresets
|
|
4
|
+
} from "@maz-ui/themes";
|
|
5
|
+
import { MazUiTheme } from "@maz-ui/themes/plugin";
|
|
6
|
+
import { getPreset } from "@maz-ui/themes/utils";
|
|
7
|
+
import { generateCriticalCSS } from "@maz-ui/themes/utils/css-generator";
|
|
8
|
+
import { defineNuxtPlugin, useCookie, useHead, useRequestHeaders } from "nuxt/app";
|
|
9
|
+
function getServerInitialColorMode() {
|
|
10
|
+
const colorModeCookie = useCookie("maz-color-mode");
|
|
11
|
+
if (colorModeCookie.value && ["light", "dark", "auto"].includes(colorModeCookie.value)) {
|
|
12
|
+
return colorModeCookie.value;
|
|
13
|
+
}
|
|
14
|
+
if (import.meta.server) {
|
|
15
|
+
const headers = useRequestHeaders();
|
|
16
|
+
if (headers["sec-ch-prefers-color-scheme"] === "dark") {
|
|
17
|
+
return "dark";
|
|
18
|
+
}
|
|
19
|
+
const userAgent = headers["user-agent"]?.toLowerCase();
|
|
20
|
+
if (userAgent?.includes("dark")) {
|
|
21
|
+
return "dark";
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return "auto";
|
|
25
|
+
}
|
|
26
|
+
function getServerIsDark(colorMode) {
|
|
27
|
+
return colorMode === "dark";
|
|
28
|
+
}
|
|
29
|
+
export default defineNuxtPlugin(async ({ vueApp, $config }) => {
|
|
30
|
+
const themeConfig = $config.public.mazUi?.theme;
|
|
31
|
+
let preset = await getPreset(themeConfig?.preset);
|
|
32
|
+
if (themeConfig?.overrides) {
|
|
33
|
+
preset = mergePresets(preset, themeConfig.overrides);
|
|
34
|
+
}
|
|
35
|
+
const config = {
|
|
36
|
+
strategy: "hybrid",
|
|
37
|
+
darkModeStrategy: "class",
|
|
38
|
+
prefix: "maz",
|
|
39
|
+
colorMode: "auto",
|
|
40
|
+
injectFullCSSOnServer: true,
|
|
41
|
+
...themeConfig,
|
|
42
|
+
preset
|
|
43
|
+
};
|
|
44
|
+
const initialColorMode = config.colorMode === "auto" ? getServerInitialColorMode() : config.colorMode ?? "auto";
|
|
45
|
+
const serverIsDark = getServerIsDark(initialColorMode);
|
|
46
|
+
const initialIsDark = initialColorMode === "dark" || initialColorMode === "auto" && serverIsDark;
|
|
47
|
+
const themeState = {
|
|
48
|
+
currentPreset: config.preset,
|
|
49
|
+
colorMode: initialColorMode,
|
|
50
|
+
isDark: initialIsDark,
|
|
51
|
+
strategy: config.strategy,
|
|
52
|
+
darkModeStrategy: config.darkModeStrategy
|
|
53
|
+
};
|
|
54
|
+
if (import.meta.server) {
|
|
55
|
+
const cssOptions = {
|
|
56
|
+
mode: config.colorMode === "auto" ? "both" : config.colorMode,
|
|
57
|
+
darkSelectorStrategy: config.darkModeStrategy ?? "class",
|
|
58
|
+
prefix: config.prefix
|
|
59
|
+
};
|
|
60
|
+
const criticalCSS = generateCriticalCSS(themeState.currentPreset, cssOptions);
|
|
61
|
+
useHead({
|
|
62
|
+
style: [
|
|
63
|
+
{
|
|
64
|
+
innerHTML: criticalCSS,
|
|
65
|
+
id: "maz-theme-critical"
|
|
66
|
+
}
|
|
67
|
+
]
|
|
68
|
+
});
|
|
69
|
+
if (config.injectFullCSSOnServer) {
|
|
70
|
+
const fullCSS = generateFullCSS(themeState.currentPreset, cssOptions);
|
|
71
|
+
useHead({
|
|
72
|
+
style: [{ innerHTML: fullCSS, id: "maz-theme-full" }]
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
if (initialIsDark && config.darkModeStrategy === "class") {
|
|
76
|
+
useHead({
|
|
77
|
+
htmlAttrs: {
|
|
78
|
+
class: "dark"
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
MazUiTheme.install(vueApp, {
|
|
84
|
+
...config,
|
|
85
|
+
preset: themeState.currentPreset,
|
|
86
|
+
colorMode: themeState.colorMode,
|
|
87
|
+
strategy: themeState.strategy,
|
|
88
|
+
darkModeStrategy: themeState.darkModeStrategy,
|
|
89
|
+
injectFullCSS: !config.injectFullCSSOnServer,
|
|
90
|
+
injectCriticalCSS: false
|
|
91
|
+
});
|
|
92
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ToastHandler } from 'maz-ui/plugins/toast';
|
|
2
|
+
declare const _default: import("#app").Plugin<{
|
|
3
|
+
mazToast: ToastHandler;
|
|
4
|
+
}> & import("#app").ObjectPlugin<{
|
|
5
|
+
mazToast: ToastHandler;
|
|
6
|
+
}>;
|
|
7
|
+
export default _default;
|
|
8
|
+
declare module '#app' {
|
|
9
|
+
interface NuxtApp {
|
|
10
|
+
$mazToast: ToastHandler;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ToastHandler } from "maz-ui/plugins/toast";
|
|
2
|
+
import { defineNuxtPlugin } from "nuxt/app";
|
|
3
|
+
export default defineNuxtPlugin(({ vueApp, $config }) => {
|
|
4
|
+
const toastOptions = $config.public.mazUi?.composables?.useToast;
|
|
5
|
+
const options = typeof toastOptions === "object" ? toastOptions : void 0;
|
|
6
|
+
const instance = new ToastHandler(vueApp, options);
|
|
7
|
+
const toastServer = {
|
|
8
|
+
show: (_message) => {
|
|
9
|
+
},
|
|
10
|
+
success: (_message) => {
|
|
11
|
+
},
|
|
12
|
+
error: (_message) => {
|
|
13
|
+
},
|
|
14
|
+
warning: (_message) => {
|
|
15
|
+
},
|
|
16
|
+
info: (_message) => {
|
|
17
|
+
},
|
|
18
|
+
message: (_message) => {
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
provide: {
|
|
23
|
+
mazToast: import.meta.server ? toastServer : instance
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type MazTranslationsInstance } from '@maz-ui/translations';
|
|
2
|
+
declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
|
|
3
|
+
export default _default;
|
|
4
|
+
declare module '#app' {
|
|
5
|
+
interface NuxtApp {
|
|
6
|
+
$mazTranslations: MazTranslationsInstance;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { MazTranslations } from "@maz-ui/translations";
|
|
2
|
+
import { defineNuxtPlugin } from "nuxt/app";
|
|
3
|
+
export default defineNuxtPlugin(async ({ vueApp, $config }) => {
|
|
4
|
+
const translationsOptions = $config.public.mazUi?.translations;
|
|
5
|
+
await MazTranslations.install(vueApp, translationsOptions);
|
|
6
|
+
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { vLazyImgInstall } from "maz-ui/directives/vLazyImg";
|
|
2
|
+
import { defineNuxtPlugin } from "nuxt/app";
|
|
3
|
+
export default defineNuxtPlugin(({ vueApp, $config }) => {
|
|
4
|
+
const vLazyImgOptions = $config.public.mazUi?.directives?.vLazyImg;
|
|
5
|
+
const options = typeof vLazyImgOptions === "object" ? vLazyImgOptions : void 0;
|
|
6
|
+
vueApp.use(vLazyImgInstall, options);
|
|
7
|
+
});
|