@maz-ui/mcp 5.0.0-beta.5 → 5.0.0-beta.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/mcp.d.mts +22 -9
- package/dist/mcp.d.ts +22 -9
- package/dist/mcp.mjs +160 -83
- package/docs/generated-docs/maz-avatar.doc.md +30 -30
- package/docs/generated-docs/maz-bottom-sheet.doc.md +16 -13
- package/docs/generated-docs/maz-btn.doc.md +21 -19
- package/docs/generated-docs/maz-checkbox.doc.md +16 -17
- package/docs/generated-docs/maz-circular-progress-bar.doc.md +1 -1
- package/docs/generated-docs/maz-code-highlight.doc.md +11 -0
- package/docs/generated-docs/maz-container.doc.md +1 -0
- package/docs/generated-docs/maz-date-picker.doc.md +41 -41
- package/docs/generated-docs/maz-drawer.doc.md +7 -8
- package/docs/generated-docs/maz-dropdown.doc.md +3 -0
- package/docs/generated-docs/maz-expand-animation.doc.md +4 -4
- package/docs/generated-docs/maz-fullscreen-loader.doc.md +5 -5
- package/docs/generated-docs/maz-gallery.doc.md +15 -15
- package/docs/generated-docs/maz-input-code.doc.md +16 -16
- package/docs/generated-docs/maz-input-phone-number.doc.md +43 -42
- package/docs/generated-docs/maz-input-price.doc.md +14 -14
- package/docs/generated-docs/maz-input-tags.doc.md +16 -16
- package/docs/generated-docs/maz-input.doc.md +33 -33
- package/docs/generated-docs/maz-lazy-img.doc.md +14 -14
- package/docs/generated-docs/maz-loading-bar.doc.md +4 -4
- package/docs/generated-docs/maz-markdown-editor.doc.md +65 -0
- package/docs/generated-docs/maz-popover.doc.md +1 -1
- package/docs/generated-docs/maz-pull-to-refresh.doc.md +39 -20
- package/docs/generated-docs/maz-radio-buttons.doc.md +17 -17
- package/docs/generated-docs/maz-radio.doc.md +16 -16
- package/docs/generated-docs/maz-reading-progress-bar.doc.md +4 -4
- package/docs/generated-docs/maz-select-country.doc.md +27 -26
- package/docs/generated-docs/maz-sidebar-content.doc.md +5 -0
- package/docs/generated-docs/maz-sidebar-footer.doc.md +5 -0
- package/docs/generated-docs/maz-sidebar-group.doc.md +11 -0
- package/docs/generated-docs/maz-sidebar-header.doc.md +5 -0
- package/docs/generated-docs/maz-sidebar-menu-button.doc.md +27 -0
- package/docs/generated-docs/maz-sidebar-menu-item.doc.md +5 -0
- package/docs/generated-docs/maz-sidebar-menu-sub.doc.md +16 -0
- package/docs/generated-docs/maz-sidebar-menu.doc.md +5 -0
- package/docs/generated-docs/maz-sidebar-separator.doc.md +0 -0
- package/docs/generated-docs/maz-sidebar-trigger.doc.md +5 -0
- package/docs/generated-docs/maz-sidebar.doc.md +36 -0
- package/docs/generated-docs/maz-slider.doc.md +1 -1
- package/docs/generated-docs/maz-spinner.doc.md +4 -4
- package/docs/generated-docs/maz-switch.doc.md +14 -14
- package/docs/generated-docs/maz-table-virtualizer.doc.md +20 -0
- package/docs/generated-docs/maz-table.doc.md +43 -37
- package/docs/generated-docs/maz-tabs-bar.doc.md +20 -9
- package/docs/generated-docs/maz-tabs.doc.md +6 -3
- package/docs/generated-docs/maz-textarea.doc.md +27 -25
- package/docs/generated-docs/maz-ticker.doc.md +1 -1
- package/docs/generated-docs/maz-timeline.doc.md +4 -4
- package/docs/generated-docs/maz-window-mockup.doc.md +23 -0
- package/docs/src/blog/v4.md +1 -1
- package/docs/src/blog/v5.md +5 -7
- package/docs/src/components/maz-avatar.md +52 -4
- package/docs/src/components/maz-bottom-sheet.md +300 -169
- package/docs/src/components/maz-btn.md +1 -1
- package/docs/src/components/maz-checklist.md +10 -10
- package/docs/src/components/maz-code-highlight.md +233 -0
- package/docs/src/components/maz-date-picker.md +55 -1
- package/docs/src/components/maz-dialog.md +46 -0
- package/docs/src/components/maz-dropdown.md +32 -16
- package/docs/src/components/maz-icon.md +16 -5
- package/docs/src/components/maz-input-phone-number.md +30 -0
- package/docs/src/components/maz-lazy-img.md +64 -0
- package/docs/src/components/maz-markdown-editor.md +369 -0
- package/docs/src/components/maz-pull-to-refresh.md +176 -17
- package/docs/src/components/maz-select-country.md +138 -1
- package/docs/src/components/maz-sidebar.md +719 -0
- package/docs/src/components/maz-table.md +156 -1
- package/docs/src/components/maz-tabs.md +110 -3
- package/docs/src/components/maz-textarea.md +58 -0
- package/docs/src/components/maz-timeline.md +60 -0
- package/docs/src/components/maz-window-mockup.md +249 -0
- package/docs/src/composables/use-drag.md +239 -0
- package/docs/src/composables/use-form-validator.md +297 -16
- package/docs/src/composables/use-pull-to-refresh.md +79 -0
- package/docs/src/composables/use-swipe.md +26 -11
- package/docs/src/directives/click-outside.md +8 -15
- package/docs/src/directives/fullscreen-img.md +1 -1
- package/docs/src/directives/lazy-img.md +44 -11
- package/docs/src/directives/tooltip.md +24 -1
- package/docs/src/directives/zoom-img.md +1 -1
- package/docs/src/ecosystem/eslint-config.md +95 -1
- package/docs/src/{guide/icons.md → ecosystem/icons/index.md} +1 -1
- package/docs/src/ecosystem/node/exec-promise.md +87 -0
- package/docs/src/ecosystem/node/index.md +53 -0
- package/docs/src/ecosystem/node/logger.md +146 -0
- package/docs/src/ecosystem/node/print-banner.md +93 -0
- package/docs/src/{guide → ecosystem}/nuxt.md +102 -47
- package/docs/src/{guide → ecosystem}/themes.md +152 -71
- package/docs/src/{guide → ecosystem}/translations.md +1 -1
- package/docs/src/ecosystem/utils/camel-case.md +31 -0
- package/docs/src/{helpers → ecosystem/utils}/capitalize.md +2 -3
- package/docs/src/ecosystem/utils/check-availability.md +79 -0
- package/docs/src/ecosystem/utils/cookie.md +80 -0
- package/docs/src/ecosystem/utils/debounce-callback.md +38 -0
- package/docs/src/ecosystem/utils/debounce-id.md +69 -0
- package/docs/src/ecosystem/utils/debounce.md +65 -0
- package/docs/src/ecosystem/utils/fetch-locale-ip.md +33 -0
- package/docs/src/ecosystem/utils/format-json.md +33 -0
- package/docs/src/ecosystem/utils/format-phone-number.md +37 -0
- package/docs/src/ecosystem/utils/get-browser-locale.md +29 -0
- package/docs/src/ecosystem/utils/get-error-message.md +39 -0
- package/docs/src/ecosystem/utils/idle-timeout.md +90 -0
- package/docs/src/ecosystem/utils/index.md +60 -0
- package/docs/src/ecosystem/utils/is-client.md +32 -0
- package/docs/src/ecosystem/utils/is-equal.md +38 -0
- package/docs/src/ecosystem/utils/is-server.md +31 -0
- package/docs/src/ecosystem/utils/is-standalone-mode.md +43 -0
- package/docs/src/ecosystem/utils/kebab-case.md +36 -0
- package/docs/src/ecosystem/utils/normalize-string.md +77 -0
- package/docs/src/ecosystem/utils/pascal-case.md +35 -0
- package/docs/src/ecosystem/utils/script-loader.md +77 -0
- package/docs/src/ecosystem/utils/sleep.md +59 -0
- package/docs/src/ecosystem/utils/snake-case.md +36 -0
- package/docs/src/ecosystem/utils/swipe-handler.md +91 -0
- package/docs/src/ecosystem/utils/textarea-autogrow.md +41 -0
- package/docs/src/ecosystem/utils/throttle-id.md +48 -0
- package/docs/src/ecosystem/utils/throttle.md +57 -0
- package/docs/src/ecosystem/utils/truthy-filter.md +31 -0
- package/docs/src/ecosystem/utils/types/deep-key-of.md +48 -0
- package/docs/src/ecosystem/utils/types/deep-partial.md +42 -0
- package/docs/src/ecosystem/utils/types/deep-required.md +39 -0
- package/docs/src/ecosystem/utils/types/flatten-object-keys.md +44 -0
- package/docs/src/ecosystem/utils/types/generic-instance-type.md +42 -0
- package/docs/src/ecosystem/utils/types/infer-maybe-ref.md +35 -0
- package/docs/src/ecosystem/utils/upper-first.md +32 -0
- package/docs/src/ecosystem/utils/user-visibility.md +69 -0
- package/docs/src/guide/getting-started.md +15 -13
- package/docs/src/guide/global-defaults.md +102 -0
- package/docs/src/guide/maz-ui-provider.md +6 -3
- package/docs/src/guide/migration-v4.md +13 -9
- package/docs/src/guide/migration-v5.md +211 -15
- package/docs/src/guide/resolvers.md +8 -8
- package/docs/src/guide/tailwind.md +4 -0
- package/docs/src/guide/vue.md +4 -4
- package/docs/src/index.md +13 -13
- package/docs/src/plugins/aos.md +1 -1
- package/package.json +11 -10
- package/docs/src/helpers/camel-case.md +0 -14
- package/docs/src/helpers/check-availability.md +0 -14
- package/docs/src/helpers/debounce-callback.md +0 -14
- package/docs/src/helpers/debounce-id.md +0 -14
- package/docs/src/helpers/debounce.md +0 -14
- package/docs/src/helpers/is-client.md +0 -14
- package/docs/src/helpers/is-equal.md +0 -14
- package/docs/src/helpers/is-standalone-mode.md +0 -14
- package/docs/src/helpers/kebab-case.md +0 -14
- package/docs/src/helpers/normalize-string.md +0 -14
- package/docs/src/helpers/pascal-case.md +0 -14
- package/docs/src/helpers/script-loader.md +0 -14
- package/docs/src/helpers/sleep.md +0 -14
- package/docs/src/helpers/snake-case.md +0 -14
- package/docs/src/helpers/throttle-id.md +0 -14
- package/docs/src/helpers/throttle.md +0 -14
- /package/docs/src/{guide → ecosystem/icons}/icon-set.md +0 -0
- /package/docs/src/{guide → ecosystem}/mcp.md +0 -0
- /package/docs/src/{helpers → ecosystem/utils}/country-code-to-unicode-flag.md +0 -0
- /package/docs/src/{helpers → ecosystem/utils}/currency.md +0 -0
- /package/docs/src/{helpers → ecosystem/utils}/date.md +0 -0
- /package/docs/src/{helpers → ecosystem/utils}/get-country-flag-url.md +0 -0
- /package/docs/src/{helpers → ecosystem/utils}/number.md +0 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: FlattenObjectKeys
|
|
3
|
+
description: Build a union of dot-separated leaf paths for a nested object, with an optional prefix.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
Similar to [`DeepKeyOf`](./deep-key-of) but only yields **leaf** paths (skips intermediate object keys), and accepts a `Prefix` parameter for namespacing.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import type { FlattenObjectKeys } from '@maz-ui/utils'
|
|
16
|
+
|
|
17
|
+
interface Config {
|
|
18
|
+
app: {
|
|
19
|
+
name: string
|
|
20
|
+
version: number
|
|
21
|
+
}
|
|
22
|
+
debug: boolean
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
type Leaves = FlattenObjectKeys<Config>
|
|
26
|
+
// → 'app.name' | 'app.version' | 'debug'
|
|
27
|
+
|
|
28
|
+
type Namespaced = FlattenObjectKeys<Config, 'config.'>
|
|
29
|
+
// → 'config.app.name' | 'config.app.version' | 'config.debug'
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## API
|
|
33
|
+
|
|
34
|
+
```ts
|
|
35
|
+
type FlattenObjectKeys<T extends Record<string, any>, Prefix extends string = ''> = {
|
|
36
|
+
[K in keyof T]: T[K] extends Record<string, any>
|
|
37
|
+
? FlattenObjectKeys<T[K], `${Prefix}${K extends string ? K : ''}.`>
|
|
38
|
+
: `${Prefix}${K extends string ? K : ''}`
|
|
39
|
+
}[keyof T]
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Notes
|
|
43
|
+
|
|
44
|
+
- Unlike `DeepKeyOf`, intermediate object keys (e.g. `'app'` in the example) are not included — only the paths that resolve to non-object leaves.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: GenericInstanceType
|
|
3
|
+
description: Extract the public instance type from a generic Vue component — solves the limitation where `InstanceType<typeof Component>` returns `any` for generic SFCs.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
Vue's `InstanceType<typeof Component>` does not work on **generic** components (`<script setup lang="ts" generic="T">`). `GenericInstanceType` walks the type to recover the exposed methods/refs typing.
|
|
11
|
+
|
|
12
|
+
See the underlying TypeScript / Vue Language Tools issue: [vuejs/language-tools#3206](https://github.com/vuejs/language-tools/issues/3206).
|
|
13
|
+
|
|
14
|
+
## Usage
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
import type { GenericInstanceType } from '@maz-ui/utils'
|
|
18
|
+
import { ref } from 'vue'
|
|
19
|
+
import MyGenericList from './MyGenericList.vue'
|
|
20
|
+
|
|
21
|
+
const listRef = ref<GenericInstanceType<typeof MyGenericList> | null>(null)
|
|
22
|
+
|
|
23
|
+
// listRef.value.focus() is fully typed
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## API
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
type GenericInstanceType<T> = T extends new (...args: any[]) => infer R
|
|
30
|
+
? R
|
|
31
|
+
: T extends (...args: any[]) => infer R
|
|
32
|
+
? R extends { __ctx?: infer K }
|
|
33
|
+
? Exclude<K, void> extends { expose: (...args: infer Y) => void }
|
|
34
|
+
? Y[0] & InstanceType<DefineComponent>
|
|
35
|
+
: any
|
|
36
|
+
: any
|
|
37
|
+
: any
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Notes
|
|
41
|
+
|
|
42
|
+
- Use this only for generic components. For non-generic SFCs, plain `InstanceType<typeof Component>` already works and is clearer.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: InferMaybeRef
|
|
3
|
+
description: Unwrap a Vue `Ref<U>` to its inner `U` — leaves non-ref types unchanged.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
Useful when authoring composables that accept either a plain value or a `Ref`, and you want a unified type for the inner value.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import type { InferMaybeRef } from '@maz-ui/utils'
|
|
16
|
+
import { ref } from 'vue'
|
|
17
|
+
|
|
18
|
+
const a = ref(42)
|
|
19
|
+
const b = 42
|
|
20
|
+
|
|
21
|
+
type A = InferMaybeRef<typeof a> // number
|
|
22
|
+
type B = InferMaybeRef<typeof b> // number
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## API
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import type { Ref } from 'vue'
|
|
29
|
+
|
|
30
|
+
type InferMaybeRef<T> = T extends Ref<infer U> ? U : T
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Notes
|
|
34
|
+
|
|
35
|
+
- Pairs well with Vue's built-in [`unref()`](https://vuejs.org/api/reactivity-utilities.html#unref), which provides the same behaviour at runtime.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: upperFirst
|
|
3
|
+
description: Uppercase the first character of a string and leave the rest unchanged.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
import { upperFirst } from '@maz-ui/utils'
|
|
14
|
+
|
|
15
|
+
upperFirst('hello') // → 'Hello'
|
|
16
|
+
upperFirst('hELLO') // → 'HELLO'
|
|
17
|
+
upperFirst('') // → ''
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## API
|
|
21
|
+
|
|
22
|
+
```ts
|
|
23
|
+
function upperFirst(value: string): string
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
| Parameter | Type | Description |
|
|
27
|
+
| --------- | -------- | --------------------- |
|
|
28
|
+
| `value` | `string` | The string to process |
|
|
29
|
+
|
|
30
|
+
## Notes
|
|
31
|
+
|
|
32
|
+
- Does **not** lowercase the remaining characters — use [`capitalize`](./capitalize) for the same behaviour when you control the input shape.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: UserVisibility
|
|
3
|
+
description: Track whether the user is currently looking at the tab using the Page Visibility API, with an optional grace timeout before declaring them away.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
`UserVisibility` listens to `visibilitychange` events. When the tab becomes hidden, it waits `timeout` ms before invoking the callback with `isVisible: false` — this avoids spurious switches when the user briefly tabs away.
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { UserVisibility } from '@maz-ui/utils'
|
|
16
|
+
|
|
17
|
+
const watcher = new UserVisibility(
|
|
18
|
+
({ isVisible }) => {
|
|
19
|
+
if (isVisible) {
|
|
20
|
+
resumeVideo()
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
pauseVideo()
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
{ timeout: 3000 },
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
// later
|
|
30
|
+
watcher.destroy()
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## API
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
class UserVisibility {
|
|
37
|
+
constructor(callback: UserVisibilyCallback, options?: UserVisibilyOptions)
|
|
38
|
+
|
|
39
|
+
start(): void
|
|
40
|
+
destroy(): void
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
type UserVisibilyCallback = (payload: { isVisible: boolean }) => void
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Options
|
|
47
|
+
|
|
48
|
+
| Option | Type | Default | Description |
|
|
49
|
+
| ----------- | --------- | ------- | --------------------------------------------------------------------------------- |
|
|
50
|
+
| `timeout` | `number` | `5000` | Grace period in ms before a hidden tab fires the `isVisible: false` callback. |
|
|
51
|
+
| `immediate` | `boolean` | `true` | Fire the callback once on construction with the current visibility state. |
|
|
52
|
+
| `once` | `boolean` | `false` | Auto-destroy after the first callback invocation. |
|
|
53
|
+
|
|
54
|
+
## Examples
|
|
55
|
+
|
|
56
|
+
Pause expensive timers when the user tabs away:
|
|
57
|
+
|
|
58
|
+
```ts
|
|
59
|
+
new UserVisibility(
|
|
60
|
+
({ isVisible }) => {
|
|
61
|
+
isVisible ? animations.resume() : animations.pause()
|
|
62
|
+
},
|
|
63
|
+
{ timeout: 0 }, // react immediately
|
|
64
|
+
)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Related
|
|
68
|
+
|
|
69
|
+
- [`IdleTimeout`](./idle-timeout) — track in-page activity instead of tab visibility.
|
|
@@ -55,7 +55,7 @@ Start by choosing your framework:
|
|
|
55
55
|
</template>
|
|
56
56
|
</MazCard>
|
|
57
57
|
<MazCard
|
|
58
|
-
href="/
|
|
58
|
+
href="/ecosystem/nuxt"
|
|
59
59
|
class="maz:flex-1"
|
|
60
60
|
content-title="Nuxt Users Guide"
|
|
61
61
|
:gallery="{
|
|
@@ -70,7 +70,7 @@ Start by choosing your framework:
|
|
|
70
70
|
</h3>
|
|
71
71
|
</template>
|
|
72
72
|
<template #footer>
|
|
73
|
-
<MazBtn color="contrast" href="/
|
|
73
|
+
<MazBtn color="contrast" href="/ecosystem/nuxt">
|
|
74
74
|
Nuxt guide
|
|
75
75
|
</MazBtn>
|
|
76
76
|
</template>
|
|
@@ -93,8 +93,9 @@ npm install @maz-ui/themes
|
|
|
93
93
|
|
|
94
94
|
**Features:**
|
|
95
95
|
|
|
96
|
-
- 🎨
|
|
97
|
-
- 🌓 Smart dark mode
|
|
96
|
+
- 🎨 Native `light-dark()` + `color-scheme` + OKLCh scales via relative color syntax
|
|
97
|
+
- 🌓 Smart dark mode — `class` or `media` strategies, with smooth transitions on toggle
|
|
98
|
+
- ✨ Optional animated theme switch via View Transitions (`setColorMode(..., { animate: true })`)
|
|
98
99
|
- ⚡ `runtime` and `buildtime` rendering strategies
|
|
99
100
|
- 🍪 Active preset persisted across reloads (opt-out)
|
|
100
101
|
- 🛡️ Full TypeScript support
|
|
@@ -163,15 +164,6 @@ npm install @maz-ui/icons
|
|
|
163
164
|
Maz-UI v5 is built with tree-shaking in mind. Import only what you need for optimal bundle sizes:
|
|
164
165
|
|
|
165
166
|
```typescript
|
|
166
|
-
/**
|
|
167
|
-
* Utilities
|
|
168
|
-
*/
|
|
169
|
-
|
|
170
|
-
// ❌ Avoid importing everything
|
|
171
|
-
import { formatCurrency, debounce } from '@maz-ui/utils'
|
|
172
|
-
// ✅ Import from @maz-ui/utils
|
|
173
|
-
import { formatCurrency, debounce } from '@maz-ui/utils'
|
|
174
|
-
|
|
175
167
|
/**
|
|
176
168
|
* Components
|
|
177
169
|
*/
|
|
@@ -215,6 +207,16 @@ import { vClickOutside } from 'maz-ui/directives/vClickOutside'
|
|
|
215
207
|
import { MazUi } from 'maz-ui/plugins'
|
|
216
208
|
// ✅✅ Direct plugin import (most optimized)
|
|
217
209
|
import { MazUi } from 'maz-ui/plugins/maz-ui'
|
|
210
|
+
|
|
211
|
+
/**
|
|
212
|
+
* Utilities
|
|
213
|
+
*/
|
|
214
|
+
|
|
215
|
+
// ❌ Avoid importing everything
|
|
216
|
+
import { formatCurrency, debounce } from '@maz-ui/utils'
|
|
217
|
+
// ✅ Import from @maz-ui/utils
|
|
218
|
+
import { debounce } from '@maz-ui/utils/helpers/debounce'
|
|
219
|
+
import { formatCurrency } from '@maz-ui/utils/helpers/formatCurrency'
|
|
218
220
|
```
|
|
219
221
|
|
|
220
222
|
::: tip Maximum Optimization
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Global component defaults
|
|
3
|
+
description: Set default prop values once for every Maz-UI component through the MazUi plugin or the Nuxt module
|
|
4
|
+
head:
|
|
5
|
+
- - meta
|
|
6
|
+
- name: keywords
|
|
7
|
+
content: maz-ui defaults, global props, default props, rounded size, component configuration, vue, nuxt
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# {{ $frontmatter.title }}
|
|
11
|
+
|
|
12
|
+
{{ $frontmatter.description }}
|
|
13
|
+
|
|
14
|
+
Instead of repeating the same prop on every instance (`<MazBtn rounded-size="lg" />` everywhere), you can set a default once and let every component pick it up.
|
|
15
|
+
|
|
16
|
+
## Priority
|
|
17
|
+
|
|
18
|
+
A resolved prop always follows this order, from highest to lowest priority:
|
|
19
|
+
|
|
20
|
+
1. The prop set on the component instance
|
|
21
|
+
2. `defaults.<ComponentName>` (per-component default)
|
|
22
|
+
3. `defaults.global` (cross-cutting default)
|
|
23
|
+
4. The library's built-in default
|
|
24
|
+
|
|
25
|
+
A global default **never** overrides a prop set on the instance. Without any `defaults` config, every component keeps its built-in default, so this feature is fully opt-in and backward compatible.
|
|
26
|
+
|
|
27
|
+
## Vue
|
|
28
|
+
|
|
29
|
+
Pass `defaults` to the `MazUi` plugin:
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { MazUi } from 'maz-ui/plugins/maz-ui'
|
|
33
|
+
import { mazUi as mazUiPreset } from '@maz-ui/themes/presets/mazUi'
|
|
34
|
+
import 'maz-ui/style.css'
|
|
35
|
+
|
|
36
|
+
app.use(MazUi, {
|
|
37
|
+
theme: { preset: mazUiPreset },
|
|
38
|
+
defaults: {
|
|
39
|
+
global: { roundedSize: 'lg' },
|
|
40
|
+
MazBtn: { roundedSize: 'full' }, // wins over global for MazBtn
|
|
41
|
+
MazCard: { bordered: false, elevation: true },
|
|
42
|
+
MazContainer: { bordered: false },
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Nuxt
|
|
48
|
+
|
|
49
|
+
Set it in `nuxt.config` under the `mazUi` key:
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
export default defineNuxtConfig({
|
|
53
|
+
modules: ['@maz-ui/nuxt'],
|
|
54
|
+
mazUi: {
|
|
55
|
+
defaults: {
|
|
56
|
+
global: { roundedSize: 'lg' },
|
|
57
|
+
MazBtn: { roundedSize: 'full' },
|
|
58
|
+
MazCard: { bordered: false, elevation: true },
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
})
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## `global` vs per-component
|
|
65
|
+
|
|
66
|
+
- `defaults.global` holds **cross-cutting** props shared by many components: `roundedSize`, `size` and `flagSrc`. Set them once and every component that exposes them picks the value up.
|
|
67
|
+
- `defaults.<ComponentName>` holds **per-component** props (including booleans such as `bordered`, `elevation`, `padding`). A per-component entry always wins over `global`.
|
|
68
|
+
|
|
69
|
+
```ts
|
|
70
|
+
defaults: {
|
|
71
|
+
global: { roundedSize: 'lg', size: 'sm' },
|
|
72
|
+
MazBtn: { roundedSize: 'full' }, // MazBtn is 'full', everything else 'lg'
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Type safety
|
|
77
|
+
|
|
78
|
+
`defaults` is fully typed. Each component entry is typed as `Partial<ComponentNameProps>`, so you get autocompletion and a TypeScript error on an unknown or mistyped prop:
|
|
79
|
+
|
|
80
|
+
```ts
|
|
81
|
+
defaults: {
|
|
82
|
+
MazBtn: { roundedSiz: 'lg' }, // ❌ TS error: 'roundedSiz' does not exist
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Globalizable props
|
|
87
|
+
|
|
88
|
+
| Prop | Type | Components |
|
|
89
|
+
| --- | --- | --- |
|
|
90
|
+
| `roundedSize` | `MazRoundedSize` (`'none' \| 'sm' \| 'md' \| 'lg' \| 'xl' \| 'full'`) | `MazBtn`, `MazBtnGroup`, `MazContainer`, `MazInput`, `MazTextarea`, `MazTable`, `MazBadge`, `MazAlert`, `MazAvatar`, `MazSkeleton`, `MazTimeline` |
|
|
91
|
+
| `flagSrc` | `MazCountryFlagSrc` (URL template or function, e.g. `loadCountryFlag` from `maz-ui/country-flags`) | `MazSelectCountry`, `MazInputPhoneNumber` (see [flags source](../components/maz-select-country.md#flags-source)) |
|
|
92
|
+
| `size` | `MazSize` (`'mini' \| 'xs' \| 'sm' \| 'md' \| 'lg' \| 'xl'`) | `MazBtn`, `MazBtnGroup`, `MazBadge`, `MazInput`, `MazSelect`, `MazSelectCountry`, `MazInputNumber`, `MazInputTags`, `MazInputPhoneNumber`, `MazCheckbox`, `MazRadio`, `MazRadioButtons`, `MazDropdown`, `MazPagination`, `MazTable`, `MazTimeline` |
|
|
93
|
+
| `bordered`, `elevation`, `padding`, `transparent`, `overflowHidden` | `boolean` | `MazContainer` |
|
|
94
|
+
| `bordered`, `elevation`, `padding`, `radius`, `scale`, `overflowHidden` | `boolean` | `MazCard` |
|
|
95
|
+
|
|
96
|
+
::: tip Note
|
|
97
|
+
Components whose `size` is a free CSS length (`MazSizeUnit`, e.g. `MazSpinner`, `MazAvatar`, `MazDrawer`, `MazSlider`, `MazCircularProgressBar`, `MazFullscreenLoader`) do not take the global `size` token - the value would not be valid for them. `MazAlert` and `MazTimeline` keep their own wider `roundedSize` scale; a `defaults.global.roundedSize` value still applies to them, and their extra steps (`2xl`, `3xl`) are reachable through their per-component entry.
|
|
98
|
+
:::
|
|
99
|
+
|
|
100
|
+
## Relation to the theme system
|
|
101
|
+
|
|
102
|
+
This is **not** a duplicate of [`@maz-ui/themes`](/ecosystem/themes). The theme system controls *what a token looks like* (the CSS value of `rounded-md`, `shadow-elevation`, colors…). Global defaults control *which prop value a component selects by default* (whether `MazBtn` defaults to `roundedSize="lg"`). Both work together: the theme defines what `lg` renders as, the defaults decide which step a component uses.
|
|
@@ -97,12 +97,15 @@ The entire Maz-UI setup is now code-split into the Dashboard chunk.
|
|
|
97
97
|
|
|
98
98
|
```typescript
|
|
99
99
|
interface ThemeOptions {
|
|
100
|
-
preset: ThemePreset
|
|
101
|
-
overrides?: ThemePresetOverrides
|
|
102
|
-
strategy?: 'runtime' | 'buildtime'
|
|
100
|
+
preset: ThemePreset // Required - Theme preset (mazUi, ocean, pristine, obsidian, nova, or custom)
|
|
101
|
+
overrides?: ThemePresetOverrides // Partial overrides for colors, foundation, etc.
|
|
102
|
+
strategy?: 'runtime' | 'buildtime' // CSS generation strategy (default: 'runtime')
|
|
103
103
|
darkModeStrategy?: 'class' | 'media' // Dark mode handling (default: 'class')
|
|
104
104
|
colorMode?: 'light' | 'dark' | 'auto' // Initial color mode (default: 'auto')
|
|
105
105
|
mode?: 'light' | 'dark' | 'both' // Supported color modes (default: 'both')
|
|
106
|
+
darkClass?: string // Class on <html> when colorMode === 'dark' (default: 'dark')
|
|
107
|
+
lightClass?: string // Class on <html> when colorMode === 'light' (default: 'light')
|
|
108
|
+
persistPreset?: boolean // Persist active preset in cookie (default: true)
|
|
106
109
|
}
|
|
107
110
|
```
|
|
108
111
|
|
|
@@ -13,7 +13,7 @@ Performance has also been significantly improved thanks to optimal tree-shaking,
|
|
|
13
13
|
|
|
14
14
|
::: tip Connected to Maz-UI MCP
|
|
15
15
|
|
|
16
|
-
Follow the [MCP](/
|
|
16
|
+
Follow the [MCP](/ecosystem/mcp) guide to connect your AI assistant to Maz-UI's documentation for a smooth migration process.
|
|
17
17
|
|
|
18
18
|
:::
|
|
19
19
|
|
|
@@ -41,6 +41,10 @@ v4.0.0 isn't just an update, it's a **complete rebuild** that transforms Maz-UI
|
|
|
41
41
|
- **Dynamic CSS Variables**: Automatic CSS variable generation
|
|
42
42
|
- **Intelligent dark mode**: Configurable strategies for dark mode based on system preferences and user choice stored in cookies
|
|
43
43
|
|
|
44
|
+
::: tip Theming further evolved in v5
|
|
45
|
+
The theme system has been rewritten on top of native `light-dark()` + `color-scheme` + `color-mix(in oklch)` in v5. If you are upgrading past v4, see the dedicated [v5 migration guide](./migration-v5.md#theming-native-css-rewrite-new-non-breaking-by-default) for the full theming changes (new `lightClass`, `Promise<void>` returns, removed JS helpers).
|
|
46
|
+
:::
|
|
47
|
+
|
|
44
48
|
#### Complete Internationalization
|
|
45
49
|
|
|
46
50
|
- **9 supported languages by default**: EN, FR, DE, ES, IT, PT, JA, ZH-CN
|
|
@@ -688,12 +692,12 @@ app.use(MazUi, {
|
|
|
688
692
|
<script setup>
|
|
689
693
|
import { useTheme } from 'maz-ui/composables'
|
|
690
694
|
|
|
691
|
-
const { isDark, toggleDarkMode,
|
|
695
|
+
const { isDark, toggleDarkMode, updateTheme } = useTheme()
|
|
692
696
|
|
|
693
697
|
// Change theme
|
|
694
|
-
|
|
698
|
+
updateTheme('ocean')
|
|
695
699
|
|
|
696
|
-
// Toggle dark mode
|
|
700
|
+
// Toggle dark mode (v5: returns Promise<void>, optional { animate } param)
|
|
697
701
|
toggleDarkMode()
|
|
698
702
|
</script>
|
|
699
703
|
|
|
@@ -704,7 +708,7 @@ toggleDarkMode()
|
|
|
704
708
|
</template>
|
|
705
709
|
```
|
|
706
710
|
|
|
707
|
-
**📖 Complete documentation:** [Theme Guide](/
|
|
711
|
+
**📖 Complete documentation:** [Theme Guide](/ecosystem/themes)
|
|
708
712
|
|
|
709
713
|
## Translation System
|
|
710
714
|
|
|
@@ -744,7 +748,7 @@ setLocale('fr')
|
|
|
744
748
|
</template>
|
|
745
749
|
```
|
|
746
750
|
|
|
747
|
-
**📖 Complete documentation:** [Translation Guide](/
|
|
751
|
+
**📖 Complete documentation:** [Translation Guide](/ecosystem/translations)
|
|
748
752
|
|
|
749
753
|
## Common Errors and Solutions
|
|
750
754
|
|
|
@@ -901,10 +905,10 @@ app.use(MazUi)
|
|
|
901
905
|
## Additional Resources
|
|
902
906
|
|
|
903
907
|
- **[Official v4 Documentation](https://maz-ui.com)** - Complete documentation
|
|
904
|
-
- **[Theme Guide](/
|
|
905
|
-
- **[Translation Guide](/
|
|
908
|
+
- **[Theme Guide](/ecosystem/themes)** - Advanced theme system
|
|
909
|
+
- **[Translation Guide](/ecosystem/translations)** - Internationalization
|
|
906
910
|
- **[Vue Installation Guide](/guide/vue)** - Vue setup
|
|
907
|
-
- **[Nuxt Installation Guide](/
|
|
911
|
+
- **[Nuxt Installation Guide](/ecosystem/nuxt)** - Nuxt setup
|
|
908
912
|
- **[Resolvers Guide](/guide/resolvers)** - Smart auto-imports
|
|
909
913
|
- **[Complete Changelog](https://github.com/LouisMazel/maz-ui/blob/master/CHANGELOG.md)** - All changes
|
|
910
914
|
|