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