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,231 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "MazUiProvider"
|
|
3
|
+
description: "A component-based alternative to the MazUi plugin for initializing theme and translations, ideal for lazy-loaded pages and micro-frontends."
|
|
4
|
+
package: "maz-ui"
|
|
5
|
+
url: "https://maz-ui.com/guide/maz-ui-provider"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# MazUiProvider
|
|
9
|
+
|
|
10
|
+
> A component-based alternative to the MazUi plugin for initializing theme and translations, ideal for lazy-loaded pages and micro-frontends.
|
|
11
|
+
|
|
12
|
+
- Package: `maz-ui`
|
|
13
|
+
- Web: https://maz-ui.com/guide/maz-ui-provider
|
|
14
|
+
|
|
15
|
+
## Why MazUiProvider?
|
|
16
|
+
|
|
17
|
+
The standard approach to initialize Maz-UI is the [`MazUi` plugin](./vue.md#install-plugin) in your `main.ts`. This works well, but it means theme and translation setup code is loaded in your **entry bundle** -- even on pages that don't use Maz-UI components.
|
|
18
|
+
|
|
19
|
+
`MazUiProvider` solves this by moving the initialization into a **component** that you place in a lazy-loaded route or subtree. The result: **zero Maz-UI footprint in your entry bundle**.
|
|
20
|
+
|
|
21
|
+
## Before & After
|
|
22
|
+
|
|
23
|
+
### Before: Plugin in main.ts (entry bundle)
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
// main.ts -- loaded on EVERY page
|
|
27
|
+
import { MazUi } from 'maz-ui/plugins/maz-ui'
|
|
28
|
+
import { mazUi } from '@maz-ui/themes/presets/mazUi'
|
|
29
|
+
import { fr } from '@maz-ui/translations'
|
|
30
|
+
import 'maz-ui/style.css'
|
|
31
|
+
|
|
32
|
+
app.use(MazUi, {
|
|
33
|
+
theme: {
|
|
34
|
+
preset: mazUi,
|
|
35
|
+
strategy: 'runtime',
|
|
36
|
+
},
|
|
37
|
+
translations: {
|
|
38
|
+
locale: 'fr',
|
|
39
|
+
messages: { fr },
|
|
40
|
+
},
|
|
41
|
+
})
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
All of `@maz-ui/themes`, `@maz-ui/translations`, and the preset data end up in the initial bundle.
|
|
45
|
+
|
|
46
|
+
### After: Provider in a lazy-loaded page
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
// main.ts -- clean, no Maz-UI code
|
|
50
|
+
import { createApp } from 'vue'
|
|
51
|
+
import { createRouter, createWebHistory } from 'vue-router'
|
|
52
|
+
import App from './App.vue'
|
|
53
|
+
|
|
54
|
+
const router = createRouter({
|
|
55
|
+
history: createWebHistory(),
|
|
56
|
+
routes: [
|
|
57
|
+
{
|
|
58
|
+
path: '/dashboard',
|
|
59
|
+
// Lazy-loaded -- Maz-UI code only loads when user navigates here
|
|
60
|
+
component: () => import('./pages/Dashboard.vue'),
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
createApp(App).use(router).mount('#app')
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
```vue
|
|
69
|
+
<!-- pages/Dashboard.vue -- lazy-loaded -->
|
|
70
|
+
<script setup lang="ts">
|
|
71
|
+
import { MazUiProvider } from 'maz-ui/components'
|
|
72
|
+
import { mazUi } from '@maz-ui/themes/presets/mazUi'
|
|
73
|
+
import { fr } from '@maz-ui/translations'
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<template>
|
|
77
|
+
<MazUiProvider
|
|
78
|
+
:theme="{ preset: mazUi, strategy: 'runtime' }"
|
|
79
|
+
:translations="{ locale: 'fr', messages: { fr } }"
|
|
80
|
+
>
|
|
81
|
+
<!-- All Maz-UI components inside this subtree work as expected -->
|
|
82
|
+
<MazBtn color="primary">Dashboard Action</MazBtn>
|
|
83
|
+
<MazInput placeholder="Search..." />
|
|
84
|
+
</MazUiProvider>
|
|
85
|
+
</template>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
The entire Maz-UI setup is now code-split into the Dashboard chunk.
|
|
89
|
+
|
|
90
|
+
## Props
|
|
91
|
+
|
|
92
|
+
| Prop | Type | Required | Description |
|
|
93
|
+
|------|------|----------|-------------|
|
|
94
|
+
| `theme` | `object` | Yes | Theme configuration. Must include `preset`. See [Theming](../ecosystem/themes.md) for details. |
|
|
95
|
+
| `translations` | `object` | Yes | Translations configuration. Must include `locale` and `messages` with at least the current locale's messages. See [Translations](../ecosystem/translations.md) for details. |
|
|
96
|
+
|
|
97
|
+
### theme
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
interface ThemeOptions {
|
|
101
|
+
preset: ThemePreset // Required - Theme preset (mazUi, ocean, pristine, obsidian, nova, or custom)
|
|
102
|
+
overrides?: ThemePresetOverrides // Partial overrides for colors, foundation, etc.
|
|
103
|
+
strategy?: 'runtime' | 'buildtime' // CSS generation strategy (default: 'runtime')
|
|
104
|
+
darkModeStrategy?: 'class' | 'media' // Dark mode handling (default: 'class')
|
|
105
|
+
colorMode?: 'light' | 'dark' | 'auto' // Initial color mode (default: 'auto')
|
|
106
|
+
mode?: 'light' | 'dark' | 'both' // Supported color modes (default: 'both')
|
|
107
|
+
darkClass?: string // Class on <html> when colorMode === 'dark' (default: 'dark')
|
|
108
|
+
lightClass?: string // Class on <html> when colorMode === 'light' (default: 'light')
|
|
109
|
+
persistPreset?: boolean // Persist active preset in cookie (default: true)
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Warning: Why is preset required?**
|
|
114
|
+
|
|
115
|
+
Providing the theme preset synchronously avoids FOUC (Flash of Unstyled Content). Without a preset, components would render without their CSS variables until the theme loads, causing a visible flash.
|
|
116
|
+
|
|
117
|
+
### translations
|
|
118
|
+
|
|
119
|
+
```typescript
|
|
120
|
+
interface TranslationsOptions {
|
|
121
|
+
locale: string // Required - Active locale (e.g. 'fr')
|
|
122
|
+
messages: MazUiTranslationsMessages // Required - Must contain at least the locale's messages
|
|
123
|
+
fallbackLocale?: string // Fallback locale (default: 'en')
|
|
124
|
+
preloadFallback?: boolean // Preload fallback locale (default: true)
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Warning: Why are locale and messages required?**
|
|
129
|
+
|
|
130
|
+
By default, Maz-UI does not bundle any translations to keep your bundle small. Translation files are loaded asynchronously on demand.
|
|
131
|
+
|
|
132
|
+
If you don't provide the messages for the current locale synchronously, components like `MazInputPhoneNumber` will briefly show translation keys (e.g. `inputPhoneNumber.countrySelect.placeholder`) instead of actual text until the async loading completes.
|
|
133
|
+
|
|
134
|
+
Providing messages upfront avoids this flash:
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
import { fr } from '@maz-ui/translations'
|
|
138
|
+
|
|
139
|
+
// Messages for 'fr' are available immediately -- no flash
|
|
140
|
+
const translations = { locale: 'fr', messages: { fr } }
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Plugin vs Provider
|
|
144
|
+
|
|
145
|
+
| | Plugin (`MazUi`) | Component (`MazUiProvider`) |
|
|
146
|
+
|---|---|---|
|
|
147
|
+
| **Setup location** | `main.ts` via `app.use()` | Any `.vue` template |
|
|
148
|
+
| **Bundle impact** | Loaded in the entry bundle | Can be lazy-loaded with the page |
|
|
149
|
+
| **Scope** | Global (entire app) | Subtree (children of the provider) |
|
|
150
|
+
| **Reconfigurable** | Configured once at install | Reactive to prop changes |
|
|
151
|
+
| **Best for** | Apps that use Maz-UI on every page | Apps with Maz-UI on specific pages, micro-frontends, testing |
|
|
152
|
+
|
|
153
|
+
### When to use the plugin
|
|
154
|
+
|
|
155
|
+
- Your app uses Maz-UI components on most or all pages
|
|
156
|
+
- You want a simple, one-time setup
|
|
157
|
+
- You're using Nuxt (the [Nuxt module](../ecosystem/nuxt.md) handles everything automatically)
|
|
158
|
+
|
|
159
|
+
### When to use the provider
|
|
160
|
+
|
|
161
|
+
- Maz-UI is only used on certain lazy-loaded routes
|
|
162
|
+
- You want zero Maz-UI overhead in the initial bundle
|
|
163
|
+
- You're building a micro-frontend or embedding Maz-UI in a larger app
|
|
164
|
+
- You need different theme/translation configurations in different parts of your app
|
|
165
|
+
- You want theme configuration to be reactive to prop changes
|
|
166
|
+
|
|
167
|
+
## Using Both Together
|
|
168
|
+
|
|
169
|
+
If you use both the plugin and the provider, **the provider takes precedence in its subtree**. Children of `MazUiProvider` will use the provider's theme and translations, while the rest of the app uses the plugin's configuration.
|
|
170
|
+
|
|
171
|
+
```vue
|
|
172
|
+
<!-- App.vue -->
|
|
173
|
+
<!-- Plugin provides global defaults -->
|
|
174
|
+
<script setup lang="ts">
|
|
175
|
+
import { MazUiProvider } from 'maz-ui/components'
|
|
176
|
+
import { ocean } from '@maz-ui/themes/presets/ocean'
|
|
177
|
+
import { en } from '@maz-ui/translations'
|
|
178
|
+
</script>
|
|
179
|
+
|
|
180
|
+
<template>
|
|
181
|
+
<div>
|
|
182
|
+
<!-- Uses plugin theme (mazUi preset) -->
|
|
183
|
+
<MazBtn color="primary">Global Theme</MazBtn>
|
|
184
|
+
|
|
185
|
+
<!-- Provider overrides in this subtree -->
|
|
186
|
+
<MazUiProvider
|
|
187
|
+
:theme="{ preset: ocean }"
|
|
188
|
+
:translations="{ locale: 'en', messages: { en } }"
|
|
189
|
+
>
|
|
190
|
+
<!-- Uses ocean preset -->
|
|
191
|
+
<MazBtn color="primary">Ocean Theme</MazBtn>
|
|
192
|
+
</MazUiProvider>
|
|
193
|
+
</div>
|
|
194
|
+
</template>
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
This is possible because both the plugin and the provider use the same Vue `provide` injection keys (`mazThemeState` and `mazTranslations`). Vue's `provide`/`inject` mechanism ensures the nearest ancestor provider wins.
|
|
198
|
+
|
|
199
|
+
## Full Example
|
|
200
|
+
|
|
201
|
+
```vue
|
|
202
|
+
<script setup lang="ts">
|
|
203
|
+
import { MazUiProvider } from 'maz-ui/components'
|
|
204
|
+
import { mazUi } from '@maz-ui/themes/presets/mazUi'
|
|
205
|
+
import { fr } from '@maz-ui/translations'
|
|
206
|
+
import { ref } from 'vue'
|
|
207
|
+
|
|
208
|
+
const locale = ref('fr')
|
|
209
|
+
</script>
|
|
210
|
+
|
|
211
|
+
<template>
|
|
212
|
+
<MazUiProvider
|
|
213
|
+
:theme="{
|
|
214
|
+
preset: mazUi,
|
|
215
|
+
strategy: 'runtime',
|
|
216
|
+
colorMode: 'auto',
|
|
217
|
+
}"
|
|
218
|
+
:translations="{
|
|
219
|
+
locale,
|
|
220
|
+
fallbackLocale: 'en',
|
|
221
|
+
messages: { fr },
|
|
222
|
+
}"
|
|
223
|
+
>
|
|
224
|
+
<div class="bg-surface text-foreground p-4">
|
|
225
|
+
<h1>My Dashboard</h1>
|
|
226
|
+
<MazBtn color="primary">Action</MazBtn>
|
|
227
|
+
<MazInput placeholder="Search..." />
|
|
228
|
+
</div>
|
|
229
|
+
</MazUiProvider>
|
|
230
|
+
</template>
|
|
231
|
+
```
|