@maz-ui/mcp 4.0.0-beta.26
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 +264 -0
- package/bin/maz-ui-mcp.mjs +7 -0
- package/dist/mcp.d.mts +13 -0
- package/dist/mcp.d.ts +13 -0
- package/dist/mcp.mjs +586 -0
- package/docs/generated-docs/maz-accordion.doc.md +21 -0
- package/docs/generated-docs/maz-animated-counter.doc.md +17 -0
- package/docs/generated-docs/maz-animated-element.doc.md +14 -0
- package/docs/generated-docs/maz-animated-text.doc.md +14 -0
- package/docs/generated-docs/maz-avatar.doc.md +44 -0
- package/docs/generated-docs/maz-backdrop.doc.md +61 -0
- package/docs/generated-docs/maz-badge.doc.md +16 -0
- package/docs/generated-docs/maz-bottom-sheet.doc.md +21 -0
- package/docs/generated-docs/maz-btn.doc.md +30 -0
- package/docs/generated-docs/maz-card-spotlight.doc.md +16 -0
- package/docs/generated-docs/maz-card.doc.md +39 -0
- package/docs/generated-docs/maz-carousel.doc.md +16 -0
- package/docs/generated-docs/maz-chart.doc.md +10 -0
- package/docs/generated-docs/maz-checkbox.doc.md +34 -0
- package/docs/generated-docs/maz-checklist.doc.md +30 -0
- package/docs/generated-docs/maz-circular-progress-bar.doc.md +27 -0
- package/docs/generated-docs/maz-date-picker.doc.md +52 -0
- package/docs/generated-docs/maz-dialog-confirm.doc.md +24 -0
- package/docs/generated-docs/maz-dialog.doc.md +22 -0
- package/docs/generated-docs/maz-drawer.doc.md +26 -0
- package/docs/generated-docs/maz-dropdown.doc.md +42 -0
- package/docs/generated-docs/maz-dropzone.doc.md +82 -0
- package/docs/generated-docs/maz-expand-animation.doc.md +12 -0
- package/docs/generated-docs/maz-fullscreen-loader.doc.md +13 -0
- package/docs/generated-docs/maz-gallery.doc.md +17 -0
- package/docs/generated-docs/maz-icon.doc.md +18 -0
- package/docs/generated-docs/maz-input-code.doc.md +25 -0
- package/docs/generated-docs/maz-input-number.doc.md +31 -0
- package/docs/generated-docs/maz-input-phone-number.doc.md +56 -0
- package/docs/generated-docs/maz-input-price.doc.md +26 -0
- package/docs/generated-docs/maz-input-tags.doc.md +24 -0
- package/docs/generated-docs/maz-input.doc.md +54 -0
- package/docs/generated-docs/maz-lazy-img.doc.md +31 -0
- package/docs/generated-docs/maz-link.doc.md +31 -0
- package/docs/generated-docs/maz-loading-bar.doc.md +6 -0
- package/docs/generated-docs/maz-pagination.doc.md +22 -0
- package/docs/generated-docs/maz-popover.doc.md +70 -0
- package/docs/generated-docs/maz-pull-to-refresh.doc.md +31 -0
- package/docs/generated-docs/maz-radio-buttons.doc.md +33 -0
- package/docs/generated-docs/maz-radio.doc.md +33 -0
- package/docs/generated-docs/maz-reading-progress-bar.doc.md +18 -0
- package/docs/generated-docs/maz-select-country.doc.md +44 -0
- package/docs/generated-docs/maz-select.doc.md +65 -0
- package/docs/generated-docs/maz-slider.doc.md +20 -0
- package/docs/generated-docs/maz-spinner.doc.md +6 -0
- package/docs/generated-docs/maz-stepper.doc.md +29 -0
- package/docs/generated-docs/maz-switch.doc.md +31 -0
- package/docs/generated-docs/maz-table-cell.doc.md +5 -0
- package/docs/generated-docs/maz-table-row.doc.md +11 -0
- package/docs/generated-docs/maz-table-title.doc.md +5 -0
- package/docs/generated-docs/maz-table.doc.md +66 -0
- package/docs/generated-docs/maz-tabs-bar.doc.md +18 -0
- package/docs/generated-docs/maz-tabs-content-item.doc.md +11 -0
- package/docs/generated-docs/maz-tabs-content.doc.md +5 -0
- package/docs/generated-docs/maz-tabs.doc.md +17 -0
- package/docs/generated-docs/maz-textarea.doc.md +41 -0
- package/docs/src/components/index.md +8 -0
- package/docs/src/components/maz-accordion.md +80 -0
- package/docs/src/components/maz-animated-counter.md +124 -0
- package/docs/src/components/maz-animated-element.md +36 -0
- package/docs/src/components/maz-animated-text.md +36 -0
- package/docs/src/components/maz-avatar.md +179 -0
- package/docs/src/components/maz-backdrop.md +16 -0
- package/docs/src/components/maz-badge.md +222 -0
- package/docs/src/components/maz-bottom-sheet.md +398 -0
- package/docs/src/components/maz-btn.md +526 -0
- package/docs/src/components/maz-card-spotlight.md +163 -0
- package/docs/src/components/maz-card.md +447 -0
- package/docs/src/components/maz-carousel.md +127 -0
- package/docs/src/components/maz-chart.md +346 -0
- package/docs/src/components/maz-checkbox.md +168 -0
- package/docs/src/components/maz-checklist.md +414 -0
- package/docs/src/components/maz-circular-progress-bar.md +147 -0
- package/docs/src/components/maz-date-picker.md +1078 -0
- package/docs/src/components/maz-dialog-confirm.md +240 -0
- package/docs/src/components/maz-dialog.md +208 -0
- package/docs/src/components/maz-drawer.md +177 -0
- package/docs/src/components/maz-dropdown.md +650 -0
- package/docs/src/components/maz-dropzone.md +442 -0
- package/docs/src/components/maz-expand-animation.md +99 -0
- package/docs/src/components/maz-fullscreen-loader.md +58 -0
- package/docs/src/components/maz-gallery.md +85 -0
- package/docs/src/components/maz-icon.md +85 -0
- package/docs/src/components/maz-input-code.md +61 -0
- package/docs/src/components/maz-input-number.md +81 -0
- package/docs/src/components/maz-input-phone-number.md +867 -0
- package/docs/src/components/maz-input-price.md +58 -0
- package/docs/src/components/maz-input-tags.md +114 -0
- package/docs/src/components/maz-input.md +453 -0
- package/docs/src/components/maz-lazy-img.md +24 -0
- package/docs/src/components/maz-link.md +156 -0
- package/docs/src/components/maz-loading-bar.md +26 -0
- package/docs/src/components/maz-pagination.md +81 -0
- package/docs/src/components/maz-popover.md +1414 -0
- package/docs/src/components/maz-pull-to-refresh.md +49 -0
- package/docs/src/components/maz-radio-buttons.md +456 -0
- package/docs/src/components/maz-radio.md +141 -0
- package/docs/src/components/maz-reading-progress-bar.md +74 -0
- package/docs/src/components/maz-select-country.md +636 -0
- package/docs/src/components/maz-select.md +439 -0
- package/docs/src/components/maz-slider.md +191 -0
- package/docs/src/components/maz-spinner.md +93 -0
- package/docs/src/components/maz-stepper.md +418 -0
- package/docs/src/components/maz-switch.md +92 -0
- package/docs/src/components/maz-table.md +571 -0
- package/docs/src/components/maz-tabs.md +231 -0
- package/docs/src/components/maz-textarea.md +218 -0
- package/docs/src/composables/use-aos.md +34 -0
- package/docs/src/composables/use-breakpoints.md +35 -0
- package/docs/src/composables/use-dialog.md +88 -0
- package/docs/src/composables/use-display-names.md +174 -0
- package/docs/src/composables/use-form-validator.md +1149 -0
- package/docs/src/composables/use-idle-timeout.md +256 -0
- package/docs/src/composables/use-reading-time.md +168 -0
- package/docs/src/composables/use-string-matching.md +63 -0
- package/docs/src/composables/use-swipe.md +223 -0
- package/docs/src/composables/use-timer.md +130 -0
- package/docs/src/composables/use-toast.md +71 -0
- package/docs/src/composables/use-user-visibility.md +169 -0
- package/docs/src/composables/use-wait.md +62 -0
- package/docs/src/composables/use-window-size.md +18 -0
- package/docs/src/demo/DemoAuthPage.vue +178 -0
- package/docs/src/demo/DemoDashboardPage.vue +298 -0
- package/docs/src/demo/DemoProductPage.vue +135 -0
- package/docs/src/directives/click-outside.md +275 -0
- package/docs/src/directives/fullscreen-img.md +101 -0
- package/docs/src/directives/lazy-img.md +184 -0
- package/docs/src/directives/tooltip.md +458 -0
- package/docs/src/directives/zoom-img.md +127 -0
- package/docs/src/guide/cli.md +144 -0
- package/docs/src/guide/getting-started.md +284 -0
- package/docs/src/guide/icon-set.md +60 -0
- package/docs/src/guide/icons.md +481 -0
- package/docs/src/guide/mcp.md +210 -0
- package/docs/src/guide/migration-v4.md +898 -0
- package/docs/src/guide/nuxt.md +411 -0
- package/docs/src/guide/resolvers.md +697 -0
- package/docs/src/guide/themes.md +789 -0
- package/docs/src/guide/translations.md +1173 -0
- package/docs/src/guide/vue.md +243 -0
- package/docs/src/helpers/camel-case.md +14 -0
- package/docs/src/helpers/capitalize.md +51 -0
- package/docs/src/helpers/check-availability.md +14 -0
- package/docs/src/helpers/country-code-to-unicode-flag.md +213 -0
- package/docs/src/helpers/currency.md +67 -0
- package/docs/src/helpers/date.md +67 -0
- package/docs/src/helpers/debounce-callback.md +14 -0
- package/docs/src/helpers/debounce-id.md +14 -0
- package/docs/src/helpers/debounce.md +14 -0
- package/docs/src/helpers/get-country-flag-url.md +156 -0
- package/docs/src/helpers/is-client.md +14 -0
- package/docs/src/helpers/is-equal.md +14 -0
- package/docs/src/helpers/is-standalone-mode.md +14 -0
- package/docs/src/helpers/kebab-case.md +14 -0
- package/docs/src/helpers/normalize-string.md +14 -0
- package/docs/src/helpers/number.md +65 -0
- package/docs/src/helpers/pascal-case.md +14 -0
- package/docs/src/helpers/script-loader.md +14 -0
- package/docs/src/helpers/sleep.md +14 -0
- package/docs/src/helpers/snake-case.md +14 -0
- package/docs/src/helpers/throttle-id.md +14 -0
- package/docs/src/helpers/throttle.md +14 -0
- package/docs/src/index.md +555 -0
- package/docs/src/made-with-maz-ui.md +58 -0
- package/docs/src/plugins/aos.md +347 -0
- package/docs/src/plugins/dialog.md +411 -0
- package/docs/src/plugins/toast.md +349 -0
- package/docs/src/plugins/wait.md +109 -0
- package/package.json +84 -0
|
@@ -0,0 +1,697 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Auto-Import Resolvers
|
|
3
|
+
description: Complete guide to Maz-UI auto-import resolvers for effortless component, directive, and composable imports
|
|
4
|
+
head:
|
|
5
|
+
- - meta
|
|
6
|
+
- name: keywords
|
|
7
|
+
content: vue auto import, unplugin resolvers, maz-ui resolver, vue components auto import
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Auto-Import Resolvers
|
|
11
|
+
|
|
12
|
+
Supercharge your Vue development with Maz-UI's intelligent auto-import resolvers. Never write import statements again while maintaining perfect tree-shaking and TypeScript support.
|
|
13
|
+
|
|
14
|
+
::: tip Vue Only Feature
|
|
15
|
+
Auto-import resolvers are designed for Vue projects using build tools like Vite or Webpack. For Nuxt users, everything is already integrated in the [@maz-ui/nuxt module](/guide/nuxt).
|
|
16
|
+
:::
|
|
17
|
+
|
|
18
|
+
## Why Use Auto-Import Resolvers?
|
|
19
|
+
|
|
20
|
+
<div class="features-grid">
|
|
21
|
+
|
|
22
|
+
### Zero Boilerplate
|
|
23
|
+
|
|
24
|
+
- No manual imports required
|
|
25
|
+
- Components, composables, and directives automatically available
|
|
26
|
+
- IntelliSense support with full TypeScript definitions
|
|
27
|
+
|
|
28
|
+
### Perfect Tree-Shaking
|
|
29
|
+
|
|
30
|
+
- Only imports what you actually use
|
|
31
|
+
- Maintains optimal bundle sizes
|
|
32
|
+
- Same performance as manual imports
|
|
33
|
+
|
|
34
|
+
### Type Safety
|
|
35
|
+
|
|
36
|
+
- Full TypeScript support
|
|
37
|
+
- Auto-generated type definitions
|
|
38
|
+
- Compile-time error checking
|
|
39
|
+
|
|
40
|
+
### Conflict Prevention
|
|
41
|
+
|
|
42
|
+
- Configurable prefixes to avoid naming conflicts
|
|
43
|
+
- Flexible naming strategies
|
|
44
|
+
- Compatible with other UI libraries
|
|
45
|
+
|
|
46
|
+
</div>
|
|
47
|
+
|
|
48
|
+
## Quick Setup
|
|
49
|
+
|
|
50
|
+
Install the required packages:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm install unplugin-vue-components unplugin-auto-import
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Configure your build tool:
|
|
57
|
+
|
|
58
|
+
::: code-group
|
|
59
|
+
|
|
60
|
+
```typescript [Vite]
|
|
61
|
+
import vue from '@vitejs/plugin-vue'
|
|
62
|
+
import {
|
|
63
|
+
MazComponentsResolver,
|
|
64
|
+
MazDirectivesResolver,
|
|
65
|
+
MazModulesResolver
|
|
66
|
+
} from 'maz-ui/resolvers'
|
|
67
|
+
import AutoImport from 'unplugin-auto-import/vite'
|
|
68
|
+
import Components from 'unplugin-vue-components/vite'
|
|
69
|
+
// vite.config.ts
|
|
70
|
+
import { defineConfig } from 'vite'
|
|
71
|
+
|
|
72
|
+
export default defineConfig({
|
|
73
|
+
plugins: [
|
|
74
|
+
vue(),
|
|
75
|
+
Components({
|
|
76
|
+
resolvers: [
|
|
77
|
+
MazComponentsResolver(),
|
|
78
|
+
MazDirectivesResolver(),
|
|
79
|
+
],
|
|
80
|
+
dts: true,
|
|
81
|
+
}),
|
|
82
|
+
AutoImport({
|
|
83
|
+
resolvers: [MazModulesResolver()],
|
|
84
|
+
dts: true,
|
|
85
|
+
}),
|
|
86
|
+
],
|
|
87
|
+
})
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
```typescript [Webpack]
|
|
91
|
+
const { MazComponentsResolver, MazDirectivesResolver, MazModulesResolver } = require('maz-ui/resolvers')
|
|
92
|
+
const AutoImport = require('unplugin-auto-import/webpack')
|
|
93
|
+
// webpack.config.js
|
|
94
|
+
const Components = require('unplugin-vue-components/webpack')
|
|
95
|
+
|
|
96
|
+
module.exports = {
|
|
97
|
+
plugins: [
|
|
98
|
+
Components({
|
|
99
|
+
resolvers: [
|
|
100
|
+
MazComponentsResolver(),
|
|
101
|
+
MazDirectivesResolver(),
|
|
102
|
+
],
|
|
103
|
+
}),
|
|
104
|
+
AutoImport({
|
|
105
|
+
resolvers: [MazModulesResolver()],
|
|
106
|
+
}),
|
|
107
|
+
],
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
:::
|
|
112
|
+
|
|
113
|
+
## Available Resolvers
|
|
114
|
+
|
|
115
|
+
### MazComponentsResolver
|
|
116
|
+
|
|
117
|
+
Auto-imports all Maz-UI components (50+ available):
|
|
118
|
+
|
|
119
|
+
```vue
|
|
120
|
+
<script setup lang="ts">
|
|
121
|
+
// No imports needed!
|
|
122
|
+
const text = ref('')
|
|
123
|
+
const selected = ref('')
|
|
124
|
+
const options = ['Option 1', 'Option 2']
|
|
125
|
+
</script>
|
|
126
|
+
|
|
127
|
+
<template>
|
|
128
|
+
<!-- All components auto-imported -->
|
|
129
|
+
<MazBtn color="primary">
|
|
130
|
+
Button
|
|
131
|
+
</MazBtn>
|
|
132
|
+
<MazInput v-model="text" placeholder="Type here..." />
|
|
133
|
+
<MazSelect v-model="selected" :options="options" />
|
|
134
|
+
<MazCard>
|
|
135
|
+
<template #header>
|
|
136
|
+
Card Title
|
|
137
|
+
</template>
|
|
138
|
+
<p>Content goes here</p>
|
|
139
|
+
</MazCard>
|
|
140
|
+
</template>
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### MazDirectivesResolver
|
|
144
|
+
|
|
145
|
+
Auto-imports powerful Vue directives:
|
|
146
|
+
|
|
147
|
+
```vue
|
|
148
|
+
<script setup lang="ts">
|
|
149
|
+
// No directive imports needed!
|
|
150
|
+
const showDropdown = ref(false)
|
|
151
|
+
|
|
152
|
+
function handleClickOutside() {
|
|
153
|
+
showDropdown.value = false
|
|
154
|
+
}
|
|
155
|
+
</script>
|
|
156
|
+
|
|
157
|
+
<template>
|
|
158
|
+
<div>
|
|
159
|
+
<!-- Tooltip directive -->
|
|
160
|
+
<MazBtn v-tooltip="'This is a helpful tooltip'">
|
|
161
|
+
Hover me
|
|
162
|
+
</MazBtn>
|
|
163
|
+
|
|
164
|
+
<!-- Click outside detection -->
|
|
165
|
+
<div v-click-outside="handleClickOutside" class="dropdown">
|
|
166
|
+
<button @click="showDropdown = !showDropdown">
|
|
167
|
+
Toggle
|
|
168
|
+
</button>
|
|
169
|
+
<div v-show="showDropdown">
|
|
170
|
+
Dropdown content
|
|
171
|
+
</div>
|
|
172
|
+
</div>
|
|
173
|
+
|
|
174
|
+
<!-- Lazy image loading -->
|
|
175
|
+
<img v-lazy-img="{ src: '/large-image.jpg', loading: '/loading.gif' }">
|
|
176
|
+
|
|
177
|
+
<!-- Image zoom and fullscreen -->
|
|
178
|
+
<img v-zoom-img src="/photo.jpg" alt="Zoomable image">
|
|
179
|
+
<img v-fullscreen-img src="/gallery-1.jpg" alt="Gallery image">
|
|
180
|
+
</div>
|
|
181
|
+
</template>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
**Available Directives:**
|
|
185
|
+
|
|
186
|
+
- **[`v-tooltip`](./../directives/tooltip.md)** - Flexible tooltip positioning and content
|
|
187
|
+
- **[`v-click-outside`](./../directives/click-outside.md)** - Detect clicks outside an element and execute a callback function
|
|
188
|
+
- **[`v-lazy-img`](./../directives/lazy-img.md)** - Lazy load images with intersection observer
|
|
189
|
+
- **[`v-zoom-img`](./../directives/zoom-img.md)** - Click to zoom images with smooth animations
|
|
190
|
+
- **[`v-fullscreen-img`](./../directives/fullscreen-img.md)** - Fullscreen image viewer with navigation
|
|
191
|
+
|
|
192
|
+
### MazModulesResolver
|
|
193
|
+
|
|
194
|
+
Auto-imports composables and utility functions:
|
|
195
|
+
|
|
196
|
+
```vue
|
|
197
|
+
<script setup lang="ts">
|
|
198
|
+
// Composables auto-imported
|
|
199
|
+
const toast = useToast()
|
|
200
|
+
const { width, height } = useWindowSize()
|
|
201
|
+
const { isMobile, isTablet } = useBreakpoints()
|
|
202
|
+
const { toggleDarkMode, isDark } = useTheme()
|
|
203
|
+
|
|
204
|
+
// Utility functions auto-imported
|
|
205
|
+
const debouncedSearch = debounce((query) => {
|
|
206
|
+
console.log('Searching:', query)
|
|
207
|
+
}, 300)
|
|
208
|
+
|
|
209
|
+
const formattedPrice = formatCurrency(29.99, { currency: 'EUR' })
|
|
210
|
+
const readableDate = date(new Date(), { format: 'short' })
|
|
211
|
+
|
|
212
|
+
// Timer composable
|
|
213
|
+
const { start, pause, reset, time } = useTimer()
|
|
214
|
+
|
|
215
|
+
function handleSearch(query) {
|
|
216
|
+
debouncedSearch(query)
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function showSuccess() {
|
|
220
|
+
toast.success('Operation completed!', {
|
|
221
|
+
position: 'top-right',
|
|
222
|
+
timeout: 3000
|
|
223
|
+
})
|
|
224
|
+
}
|
|
225
|
+
</script>
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
**Most used available composables:**
|
|
229
|
+
|
|
230
|
+
| Category | Composables |
|
|
231
|
+
| -------------------- | --------------------------------------------------- |
|
|
232
|
+
| **UI Management** | [`useToast`](./../composables/use-toast.md), [`useDialog`](./../composables/use-dialog.md), [`useTheme`](./../composables/use-theme.md), [`useWait`](./../composables/use-wait.md) |
|
|
233
|
+
| **Responsive** | [`useBreakpoints`](./../composables/use-breakpoints.md), [`useWindowSize`](./../composables/use-window-size.md) |
|
|
234
|
+
| **User Interaction** | [`useUserVisibility`](./../composables/use-user-visibility.md), [`useIdleTimeout`](./../composables/use-idle-timeout.md), [`useSwipe`](./../composables/use-swipe.md) |
|
|
235
|
+
| **Form Handling** | [`useFormValidator`](./../composables/use-form-validator.md), [`useFormField`](./../composables/use-form-field.md) |
|
|
236
|
+
| **Advanced** | [`useTimer`](./../composables/use-timer.md), [`useStringMatching`](./../composables/use-string-matching.md) |
|
|
237
|
+
|
|
238
|
+
**Most used available formatters and utilities:**
|
|
239
|
+
|
|
240
|
+
| Category | Utilities/Formatters |
|
|
241
|
+
| -------------------- | --------------------------------------------------- |
|
|
242
|
+
| **Formatters** | [`formatCurrency`](./../helpers/currency.md), [`formatDate`](./../helpers/date.md), [`sleep`](./../helpers/sleep.md) |
|
|
243
|
+
| **Utilities** | [`debounce`](./../helpers/debounce.md), [`throttle`](./../helpers/throttle.md), [`isEqual`](./../helpers/is-equal.md) |
|
|
244
|
+
|
|
245
|
+
## Advanced Configuration
|
|
246
|
+
|
|
247
|
+
### Avoiding Naming Conflicts with Prefixes
|
|
248
|
+
|
|
249
|
+
When using multiple UI libraries or when you have naming conflicts, use prefixes:
|
|
250
|
+
|
|
251
|
+
```typescript
|
|
252
|
+
// vite.config.ts
|
|
253
|
+
export default defineConfig({
|
|
254
|
+
plugins: [
|
|
255
|
+
vue(),
|
|
256
|
+
Components({
|
|
257
|
+
resolvers: [
|
|
258
|
+
MazComponentsResolver(), // No prefix needed
|
|
259
|
+
MazDirectivesResolver({ prefix: 'maz' }), // vMazTooltip, vMazClickOutside, vMazLazyImg, vMazZoomImg, vMazFullscreenImg
|
|
260
|
+
],
|
|
261
|
+
}),
|
|
262
|
+
AutoImport({
|
|
263
|
+
resolvers: [
|
|
264
|
+
MazModulesResolver({ prefix: 'maz' }), // useMazToast, useMazTheme, mazSleep, mazDebounce, etc.
|
|
265
|
+
],
|
|
266
|
+
}),
|
|
267
|
+
],
|
|
268
|
+
})
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
With prefixes enabled:
|
|
272
|
+
|
|
273
|
+
```vue
|
|
274
|
+
<script setup lang="ts">
|
|
275
|
+
// Prefixed composables
|
|
276
|
+
const toast = useMazToast()
|
|
277
|
+
const theme = useMazTheme()
|
|
278
|
+
|
|
279
|
+
// Prefixed utilities (for composables only)
|
|
280
|
+
const mazDebounce = debounce // Note: utility functions are not prefixed
|
|
281
|
+
</script>
|
|
282
|
+
|
|
283
|
+
<template>
|
|
284
|
+
<!-- Prefixed components -->
|
|
285
|
+
<MazMazBtn v-maz-tooltip="'Prefixed tooltip'">
|
|
286
|
+
Prefixed Button
|
|
287
|
+
</MazMazBtn>
|
|
288
|
+
</template>
|
|
289
|
+
```
|
|
290
|
+
|
|
291
|
+
::: warning Prefix Limitation
|
|
292
|
+
Currently, utility functions (like `debounce`, `currency`) are not prefixed by the `MazModulesResolver`. Only composables (functions starting with `use`) are prefixed. This is a limitation that may be addressed in future versions.
|
|
293
|
+
:::
|
|
294
|
+
|
|
295
|
+
### Development Mode
|
|
296
|
+
|
|
297
|
+
Enable development mode for better debugging and faster builds during development:
|
|
298
|
+
|
|
299
|
+
```typescript
|
|
300
|
+
export default defineConfig({
|
|
301
|
+
plugins: [
|
|
302
|
+
Components({
|
|
303
|
+
resolvers: [
|
|
304
|
+
MazComponentsResolver({ devMode: process.env.NODE_ENV === 'development' }),
|
|
305
|
+
MazDirectivesResolver({ devMode: process.env.NODE_ENV === 'development' }),
|
|
306
|
+
],
|
|
307
|
+
}),
|
|
308
|
+
AutoImport({
|
|
309
|
+
resolvers: [
|
|
310
|
+
MazModulesResolver({ devMode: process.env.NODE_ENV === 'development' }),
|
|
311
|
+
],
|
|
312
|
+
}),
|
|
313
|
+
],
|
|
314
|
+
})
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### Custom Resolver Configuration
|
|
318
|
+
|
|
319
|
+
Combine with other popular resolvers:
|
|
320
|
+
|
|
321
|
+
```typescript
|
|
322
|
+
import {
|
|
323
|
+
AntDesignVueResolver,
|
|
324
|
+
ElementPlusResolver,
|
|
325
|
+
MazComponentsResolver
|
|
326
|
+
} from 'unplugin-vue-components/resolvers'
|
|
327
|
+
import Components from 'unplugin-vue-components/vite'
|
|
328
|
+
import { defineConfig } from 'vite'
|
|
329
|
+
|
|
330
|
+
export default defineConfig({
|
|
331
|
+
plugins: [
|
|
332
|
+
Components({
|
|
333
|
+
resolvers: [
|
|
334
|
+
// Multiple UI libraries with prefixes
|
|
335
|
+
MazComponentsResolver({ prefix: 'Maz' }),
|
|
336
|
+
ElementPlusResolver({ prefix: 'El' }),
|
|
337
|
+
AntDesignVueResolver({ prefix: 'A' }),
|
|
338
|
+
],
|
|
339
|
+
}),
|
|
340
|
+
],
|
|
341
|
+
})
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
## Real-World Examples
|
|
345
|
+
|
|
346
|
+
### Complete Dashboard Setup
|
|
347
|
+
|
|
348
|
+
```typescript
|
|
349
|
+
import vue from '@vitejs/plugin-vue'
|
|
350
|
+
import { MazComponentsResolver, MazDirectivesResolver, MazModulesResolver } from 'maz-ui/resolvers'
|
|
351
|
+
import AutoImport from 'unplugin-auto-import/vite'
|
|
352
|
+
import Components from 'unplugin-vue-components/vite'
|
|
353
|
+
// vite.config.ts - Production-ready configuration
|
|
354
|
+
import { defineConfig } from 'vite'
|
|
355
|
+
|
|
356
|
+
export default defineConfig({
|
|
357
|
+
plugins: [
|
|
358
|
+
vue(),
|
|
359
|
+
Components({
|
|
360
|
+
resolvers: [MazComponentsResolver()],
|
|
361
|
+
dts: 'src/types/components.d.ts',
|
|
362
|
+
directoryAsNamespace: true,
|
|
363
|
+
}),
|
|
364
|
+
AutoImport({
|
|
365
|
+
resolvers: [MazModulesResolver()],
|
|
366
|
+
dts: 'src/types/auto-imports.d.ts',
|
|
367
|
+
imports: ['vue', 'vue-router'],
|
|
368
|
+
eslintrc: {
|
|
369
|
+
enabled: true,
|
|
370
|
+
},
|
|
371
|
+
}),
|
|
372
|
+
],
|
|
373
|
+
})
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### Dashboard Component Example
|
|
377
|
+
|
|
378
|
+
```vue
|
|
379
|
+
<script setup lang="ts">
|
|
380
|
+
// All auto-imported - no imports needed!
|
|
381
|
+
const toast = useToast()
|
|
382
|
+
const { width } = useWindowSize()
|
|
383
|
+
const { isMobile } = useBreakpoints()
|
|
384
|
+
|
|
385
|
+
// Reactive data
|
|
386
|
+
const currentPage = ref(1)
|
|
387
|
+
const perPage = ref(10)
|
|
388
|
+
const isLoading = ref(false)
|
|
389
|
+
const showUserDialog = ref(false)
|
|
390
|
+
const editingUser = ref({ name: '', role: '' })
|
|
391
|
+
|
|
392
|
+
// Computed
|
|
393
|
+
const paginatedUsers = computed(() => {
|
|
394
|
+
const start = (currentPage.value - 1) * perPage.value
|
|
395
|
+
return users.value.slice(start, start + perPage.value)
|
|
396
|
+
})
|
|
397
|
+
|
|
398
|
+
// Auto-imported utilities
|
|
399
|
+
const debouncedRefresh = debounce(refreshData, 1000)
|
|
400
|
+
|
|
401
|
+
// Mock data
|
|
402
|
+
const users = ref([
|
|
403
|
+
{ id: 1, name: 'John Doe', role: 'Admin' },
|
|
404
|
+
{ id: 2, name: 'Jane Smith', role: 'User' },
|
|
405
|
+
])
|
|
406
|
+
|
|
407
|
+
const stats = computed(() => [
|
|
408
|
+
{ label: 'Total Users', value: users.value.length, color: 'primary' },
|
|
409
|
+
{ label: 'Active', value: users.value.filter(u => u.role === 'User').length, color: 'success' },
|
|
410
|
+
])
|
|
411
|
+
|
|
412
|
+
const columns = [
|
|
413
|
+
{ key: 'name', label: 'Name' },
|
|
414
|
+
{ key: 'role', label: 'Role' },
|
|
415
|
+
]
|
|
416
|
+
|
|
417
|
+
const roleOptions = ['Admin', 'User', 'Moderator']
|
|
418
|
+
const totalUsers = computed(() => users.value.length)
|
|
419
|
+
|
|
420
|
+
// Methods
|
|
421
|
+
function refreshData() {
|
|
422
|
+
isLoading.value = true
|
|
423
|
+
// Simulate API call
|
|
424
|
+
setTimeout(() => {
|
|
425
|
+
isLoading.value = false
|
|
426
|
+
toast.success('Data refreshed!')
|
|
427
|
+
}, 1000)
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
function closeDialog() {
|
|
431
|
+
showUserDialog.value = false
|
|
432
|
+
editingUser.value = { name: '', role: '' }
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
function saveUser() {
|
|
436
|
+
toast.success('User saved successfully!')
|
|
437
|
+
closeDialog()
|
|
438
|
+
}
|
|
439
|
+
</script>
|
|
440
|
+
|
|
441
|
+
<template>
|
|
442
|
+
<div class="dashboard">
|
|
443
|
+
<!-- Auto-imported components -->
|
|
444
|
+
<MazCard class="stats-card">
|
|
445
|
+
<template #header>
|
|
446
|
+
<div class="flex items-center justify-between">
|
|
447
|
+
<h2>Statistics</h2>
|
|
448
|
+
<MazBtn
|
|
449
|
+
v-tooltip="'Refresh data'"
|
|
450
|
+
size="sm"
|
|
451
|
+
@click="refreshData"
|
|
452
|
+
>
|
|
453
|
+
<MazIcon name="refresh" />
|
|
454
|
+
</MazBtn>
|
|
455
|
+
</div>
|
|
456
|
+
</template>
|
|
457
|
+
|
|
458
|
+
<div class="grid grid-cols-2 gap-4">
|
|
459
|
+
<div v-for="stat in stats" :key="stat.label">
|
|
460
|
+
<MazBadge :color="stat.color">
|
|
461
|
+
{{ stat.value }}
|
|
462
|
+
</MazBadge>
|
|
463
|
+
<p class="text-sm text-muted">
|
|
464
|
+
{{ stat.label }}
|
|
465
|
+
</p>
|
|
466
|
+
</div>
|
|
467
|
+
</div>
|
|
468
|
+
</MazCard>
|
|
469
|
+
|
|
470
|
+
<!-- Data table with pagination -->
|
|
471
|
+
<MazCard>
|
|
472
|
+
<template #header>
|
|
473
|
+
Users
|
|
474
|
+
</template>
|
|
475
|
+
|
|
476
|
+
<MazTable
|
|
477
|
+
:data="paginatedUsers"
|
|
478
|
+
:columns="columns"
|
|
479
|
+
:loading="isLoading"
|
|
480
|
+
/>
|
|
481
|
+
|
|
482
|
+
<template #footer>
|
|
483
|
+
<MazPagination
|
|
484
|
+
v-model:current-page="currentPage"
|
|
485
|
+
:total="totalUsers"
|
|
486
|
+
:per-page="perPage"
|
|
487
|
+
/>
|
|
488
|
+
</template>
|
|
489
|
+
</MazCard>
|
|
490
|
+
|
|
491
|
+
<!-- Modal dialog -->
|
|
492
|
+
<MazDialog v-model="showUserDialog" title="User Details">
|
|
493
|
+
<MazInput
|
|
494
|
+
v-model="editingUser.name"
|
|
495
|
+
label="Name"
|
|
496
|
+
placeholder="Enter user name"
|
|
497
|
+
/>
|
|
498
|
+
<MazSelect
|
|
499
|
+
v-model="editingUser.role"
|
|
500
|
+
label="Role"
|
|
501
|
+
:options="roleOptions"
|
|
502
|
+
/>
|
|
503
|
+
|
|
504
|
+
<template #footer>
|
|
505
|
+
<MazBtn @click="closeDialog">
|
|
506
|
+
Cancel
|
|
507
|
+
</MazBtn>
|
|
508
|
+
<MazBtn @click="saveUser">
|
|
509
|
+
Save
|
|
510
|
+
</MazBtn>
|
|
511
|
+
</template>
|
|
512
|
+
</MazDialog>
|
|
513
|
+
</div>
|
|
514
|
+
</template>
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
## TypeScript Integration
|
|
518
|
+
|
|
519
|
+
### Auto-Generated Types
|
|
520
|
+
|
|
521
|
+
The resolvers automatically generate TypeScript definitions:
|
|
522
|
+
|
|
523
|
+
```typescript
|
|
524
|
+
// auto-imports.d.ts (generated)
|
|
525
|
+
declare global {
|
|
526
|
+
const useToast: typeof import('maz-ui/composables')['useToast']
|
|
527
|
+
const useTheme: typeof import('maz-ui/composables')['useTheme']
|
|
528
|
+
const debounce: typeof import('maz-ui')['debounce']
|
|
529
|
+
const currency: typeof import('maz-ui')['currency']
|
|
530
|
+
// ... all other auto-imports
|
|
531
|
+
}
|
|
532
|
+
|
|
533
|
+
// components.d.ts (generated)
|
|
534
|
+
declare module 'vue' {
|
|
535
|
+
export interface GlobalComponents {
|
|
536
|
+
MazBtn: typeof import('maz-ui/components')['MazBtn']
|
|
537
|
+
MazInput: typeof import('maz-ui/components')['MazInput']
|
|
538
|
+
// ... all other components
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
```
|
|
542
|
+
|
|
543
|
+
### ESLint Configuration
|
|
544
|
+
|
|
545
|
+
Prevent ESLint errors for auto-imported functions:
|
|
546
|
+
|
|
547
|
+
```javascript
|
|
548
|
+
// .eslintrc.js
|
|
549
|
+
module.exports = {
|
|
550
|
+
extends: [
|
|
551
|
+
'./.eslintrc-auto-import.json', // Generated by unplugin-auto-import
|
|
552
|
+
],
|
|
553
|
+
rules: {
|
|
554
|
+
'no-undef': 'off', // Disable for auto-imports
|
|
555
|
+
},
|
|
556
|
+
}
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
## Performance Tips
|
|
560
|
+
|
|
561
|
+
### Optimize Bundle Size
|
|
562
|
+
|
|
563
|
+
```typescript
|
|
564
|
+
// Only import specific resolvers you need
|
|
565
|
+
import { MazComponentsResolver } from 'maz-ui/resolvers'
|
|
566
|
+
|
|
567
|
+
// Use tree-shaking friendly configuration
|
|
568
|
+
export default defineConfig({
|
|
569
|
+
plugins: [
|
|
570
|
+
Components({
|
|
571
|
+
resolvers: [MazComponentsResolver()],
|
|
572
|
+
// Generate types for better tree-shaking
|
|
573
|
+
dts: true,
|
|
574
|
+
}),
|
|
575
|
+
],
|
|
576
|
+
build: {
|
|
577
|
+
rollupOptions: {
|
|
578
|
+
// Ensure proper tree-shaking
|
|
579
|
+
treeshake: true,
|
|
580
|
+
},
|
|
581
|
+
},
|
|
582
|
+
})
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
## Troubleshooting
|
|
586
|
+
|
|
587
|
+
### Common Issues
|
|
588
|
+
|
|
589
|
+
**Components not auto-importing:**
|
|
590
|
+
|
|
591
|
+
```typescript
|
|
592
|
+
// ✅ Make sure resolvers are properly configured
|
|
593
|
+
Components({
|
|
594
|
+
resolvers: [MazComponentsResolver()], // Must be included
|
|
595
|
+
})
|
|
596
|
+
```
|
|
597
|
+
|
|
598
|
+
**TypeScript errors:**
|
|
599
|
+
|
|
600
|
+
```typescript
|
|
601
|
+
// ✅ Ensure dts generation is enabled
|
|
602
|
+
Components({
|
|
603
|
+
dts: true, // Generate type definitions
|
|
604
|
+
})
|
|
605
|
+
```
|
|
606
|
+
|
|
607
|
+
**Prefix not working for utilities:**
|
|
608
|
+
|
|
609
|
+
```typescript
|
|
610
|
+
// ⚠️ Known limitation: utilities are not prefixed
|
|
611
|
+
MazModulesResolver({ prefix: 'Maz' }) // Only composables are prefixed
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
**Development performance:**
|
|
615
|
+
|
|
616
|
+
```typescript
|
|
617
|
+
// ✅ Enable development mode for faster builds
|
|
618
|
+
MazComponentsResolver({
|
|
619
|
+
devMode: process.env.NODE_ENV === 'development'
|
|
620
|
+
})
|
|
621
|
+
```
|
|
622
|
+
|
|
623
|
+
## Migration from Manual Imports
|
|
624
|
+
|
|
625
|
+
### Before (Manual Imports)
|
|
626
|
+
|
|
627
|
+
```vue
|
|
628
|
+
<script setup lang="ts">
|
|
629
|
+
import { formatCurrency, debounce } from 'maz-ui'
|
|
630
|
+
import { MazBtn, MazCard, MazInput } from 'maz-ui/components'
|
|
631
|
+
import { useTheme, useToast } from 'maz-ui/composables'
|
|
632
|
+
import { vTooltip } from 'maz-ui/directives'
|
|
633
|
+
|
|
634
|
+
const toast = useToast()
|
|
635
|
+
// ... rest of component
|
|
636
|
+
</script>
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
### After (Auto-Import)
|
|
640
|
+
|
|
641
|
+
```vue
|
|
642
|
+
<script setup lang="ts">
|
|
643
|
+
// Nothing to import! Everything is auto-imported
|
|
644
|
+
const toast = useToast()
|
|
645
|
+
// ... rest of component
|
|
646
|
+
</script>
|
|
647
|
+
```
|
|
648
|
+
|
|
649
|
+
## Related Resources
|
|
650
|
+
|
|
651
|
+
- [unplugin-vue-components](https://github.com/antfu/unplugin-vue-components) - The underlying auto-import system
|
|
652
|
+
- [unplugin-auto-import](https://github.com/antfu/unplugin-auto-import) - Auto-import for composables and utilities
|
|
653
|
+
- [Nuxt Module](/guide/nuxt) - All auto-imports included out of the box
|
|
654
|
+
|
|
655
|
+
---
|
|
656
|
+
|
|
657
|
+
Ready to boost your productivity? Set up auto-import resolvers and never write import statements again! 🚀
|
|
658
|
+
|
|
659
|
+
<style scoped>
|
|
660
|
+
.features-grid {
|
|
661
|
+
display: grid;
|
|
662
|
+
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
|
|
663
|
+
gap: 1rem;
|
|
664
|
+
margin: 2rem 0;
|
|
665
|
+
|
|
666
|
+
h3 {
|
|
667
|
+
margin-top: 0;
|
|
668
|
+
}
|
|
669
|
+
ul {
|
|
670
|
+
margin-top: 0;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
|
|
674
|
+
.features-grid > div {
|
|
675
|
+
padding: 1.5rem;
|
|
676
|
+
border-radius: 0.75rem;
|
|
677
|
+
border: 1px solid var(--vp-c-border);
|
|
678
|
+
background: var(--vp-c-bg-soft);
|
|
679
|
+
}
|
|
680
|
+
|
|
681
|
+
.dashboard {
|
|
682
|
+
display: grid;
|
|
683
|
+
gap: 1.5rem;
|
|
684
|
+
}
|
|
685
|
+
|
|
686
|
+
.stats-card {
|
|
687
|
+
border: 1px solid var(--vp-c-border);
|
|
688
|
+
border-radius: 0.5rem;
|
|
689
|
+
padding: 1rem;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
@media (max-width: 768px) {
|
|
693
|
+
.features-grid {
|
|
694
|
+
grid-template-columns: 1fr;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
</style>
|