@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,233 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: MazCodeHighlight
|
|
3
|
+
description: MazCodeHighlight displays source code with syntax highlighting powered by shiki. It auto-detects dark/light mode, ships with a copy-to-clipboard button, a language badge, and supports lazy loading.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
<!--@include: ./../../.vitepress/mixins/getting-started.md-->
|
|
11
|
+
|
|
12
|
+
## Installation requirement
|
|
13
|
+
|
|
14
|
+
Install [`shiki`](https://shiki.style) in your project to enable highlighting:
|
|
15
|
+
|
|
16
|
+
::: code-group
|
|
17
|
+
|
|
18
|
+
```bash [pnpm]
|
|
19
|
+
pnpm add shiki
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```bash [npm]
|
|
23
|
+
npm install shiki
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```bash [yarn]
|
|
27
|
+
yarn add shiki
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
:::
|
|
31
|
+
|
|
32
|
+
If `shiki` is not installed, the component falls back to a plain `<pre><code>` block.
|
|
33
|
+
|
|
34
|
+
## Basic usage
|
|
35
|
+
|
|
36
|
+
<ComponentDemo>
|
|
37
|
+
<MazCodeHighlight code="const greeting = 'Hello, maz-ui!'" language="ts" />
|
|
38
|
+
|
|
39
|
+
<template #code>
|
|
40
|
+
|
|
41
|
+
```vue
|
|
42
|
+
<template>
|
|
43
|
+
<MazCodeHighlight code="const greeting = 'Hello, maz-ui!'" language="ts" />
|
|
44
|
+
</template>
|
|
45
|
+
|
|
46
|
+
<script lang="ts" setup>
|
|
47
|
+
import MazCodeHighlight from 'maz-ui/components/MazCodeHighlight'
|
|
48
|
+
</script>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
</template>
|
|
52
|
+
</ComponentDemo>
|
|
53
|
+
|
|
54
|
+
## With slot
|
|
55
|
+
|
|
56
|
+
The default slot text is used as source code when the `code` prop is not provided. This is useful for plain text blocks.
|
|
57
|
+
|
|
58
|
+
<ComponentDemo>
|
|
59
|
+
<MazCodeHighlight language="bash">npm install maz-ui</MazCodeHighlight>
|
|
60
|
+
|
|
61
|
+
<template #code>
|
|
62
|
+
|
|
63
|
+
```vue
|
|
64
|
+
<template>
|
|
65
|
+
<MazCodeHighlight language="bash">npm install maz-ui</MazCodeHighlight>
|
|
66
|
+
</template>
|
|
67
|
+
|
|
68
|
+
<script lang="ts" setup>
|
|
69
|
+
import MazCodeHighlight from 'maz-ui/components/MazCodeHighlight'
|
|
70
|
+
</script>
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
</template>
|
|
74
|
+
</ComponentDemo>
|
|
75
|
+
|
|
76
|
+
## Languages
|
|
77
|
+
|
|
78
|
+
Pass any valid [shiki language identifier](https://shiki.style/languages) to the `language` prop. The chosen language is also displayed as a small badge in the top-right corner (the badge fades out on hover when the copy button appears).
|
|
79
|
+
|
|
80
|
+
<ComponentDemo>
|
|
81
|
+
<MazCodeHighlight language="vue" :code="vueExample" />
|
|
82
|
+
|
|
83
|
+
<template #code>
|
|
84
|
+
|
|
85
|
+
```vue
|
|
86
|
+
<template>
|
|
87
|
+
<MazCodeHighlight language="vue" :code="vueExample" />
|
|
88
|
+
</template>
|
|
89
|
+
|
|
90
|
+
<script lang="ts" setup>
|
|
91
|
+
import MazCodeHighlight from 'maz-ui/components/MazCodeHighlight'
|
|
92
|
+
|
|
93
|
+
const vueExample = `<script lang="ts" setup>
|
|
94
|
+
import { ref } from 'vue'
|
|
95
|
+
const count = ref(0)
|
|
96
|
+
<\/script>
|
|
97
|
+
|
|
98
|
+
<template>
|
|
99
|
+
<button @click="count++">Count: {{ count }}</button>
|
|
100
|
+
</template>`
|
|
101
|
+
</script>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
</template>
|
|
105
|
+
</ComponentDemo>
|
|
106
|
+
|
|
107
|
+
## Custom theme
|
|
108
|
+
|
|
109
|
+
Override the auto-detected theme with any [shiki built-in theme](https://shiki.style/themes).
|
|
110
|
+
|
|
111
|
+
<ComponentDemo>
|
|
112
|
+
<MazCodeHighlight code="console.log('dracula theme')" language="js" theme="dracula" />
|
|
113
|
+
|
|
114
|
+
<template #code>
|
|
115
|
+
|
|
116
|
+
```vue
|
|
117
|
+
<template>
|
|
118
|
+
<MazCodeHighlight code="console.log('dracula theme')" language="js" theme="dracula" />
|
|
119
|
+
</template>
|
|
120
|
+
|
|
121
|
+
<script lang="ts" setup>
|
|
122
|
+
import MazCodeHighlight from 'maz-ui/components/MazCodeHighlight'
|
|
123
|
+
</script>
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
</template>
|
|
127
|
+
</ComponentDemo>
|
|
128
|
+
|
|
129
|
+
## Copy to clipboard
|
|
130
|
+
|
|
131
|
+
A copy button is displayed in the top-right corner on hover (or when focused via keyboard). Clicking it writes the resolved code to the clipboard and shows a check icon for ~1.5s.
|
|
132
|
+
|
|
133
|
+
### Disable the copy button
|
|
134
|
+
|
|
135
|
+
Set `:copyable="false"` to hide the button entirely.
|
|
136
|
+
|
|
137
|
+
<ComponentDemo>
|
|
138
|
+
<MazCodeHighlight code="const noCopyButton = true" language="ts" :copyable="false" />
|
|
139
|
+
|
|
140
|
+
<template #code>
|
|
141
|
+
|
|
142
|
+
```vue
|
|
143
|
+
<template>
|
|
144
|
+
<MazCodeHighlight code="const noCopyButton = true" language="ts" :copyable="false" />
|
|
145
|
+
</template>
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
</template>
|
|
149
|
+
</ComponentDemo>
|
|
150
|
+
|
|
151
|
+
### Copy a different value than the displayed code
|
|
152
|
+
|
|
153
|
+
Use `copyValue` when the displayed source differs from what should be copied — for example to strip a leading `$` prompt when rendering a shell command. This is the mechanism `MazWindowMockup` uses internally to keep the terminal prompt out of the clipboard.
|
|
154
|
+
|
|
155
|
+
<ComponentDemo>
|
|
156
|
+
<MazCodeHighlight code="$ pnpm add maz-ui" copy-value="pnpm add maz-ui" language="bash" />
|
|
157
|
+
|
|
158
|
+
<template #code>
|
|
159
|
+
|
|
160
|
+
```vue
|
|
161
|
+
<template>
|
|
162
|
+
<MazCodeHighlight
|
|
163
|
+
code="$ pnpm add maz-ui"
|
|
164
|
+
copy-value="pnpm add maz-ui"
|
|
165
|
+
language="bash"
|
|
166
|
+
/>
|
|
167
|
+
</template>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
</template>
|
|
171
|
+
</ComponentDemo>
|
|
172
|
+
|
|
173
|
+
## Disable rounded corners
|
|
174
|
+
|
|
175
|
+
Set `:rounded="false"` to render the highlighted block with squared corners — useful when embedding inside another container that already has its own border-radius (e.g. inside `MazWindowMockup`).
|
|
176
|
+
|
|
177
|
+
<ComponentDemo>
|
|
178
|
+
<MazCodeHighlight code="// squared corners" language="ts" :rounded="false" />
|
|
179
|
+
|
|
180
|
+
<template #code>
|
|
181
|
+
|
|
182
|
+
```vue
|
|
183
|
+
<template>
|
|
184
|
+
<MazCodeHighlight code="// squared corners" language="ts" :rounded="false" />
|
|
185
|
+
</template>
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
</template>
|
|
189
|
+
</ComponentDemo>
|
|
190
|
+
|
|
191
|
+
## Custom translations
|
|
192
|
+
|
|
193
|
+
The copy button's aria-label and tooltip come from the `@maz-ui/translations` package (`codeHighlight.copyToClipboard` / `codeHighlight.copiedToClipboard`). You can override either key per-instance with the `translations` prop without touching the global locale:
|
|
194
|
+
|
|
195
|
+
<ComponentDemo>
|
|
196
|
+
<MazCodeHighlight
|
|
197
|
+
code="const hello = 'world'"
|
|
198
|
+
language="ts"
|
|
199
|
+
:translations="{ copyToClipboard: 'Copier le code', copiedToClipboard: 'Copié !' }"
|
|
200
|
+
/>
|
|
201
|
+
|
|
202
|
+
<template #code>
|
|
203
|
+
|
|
204
|
+
```vue
|
|
205
|
+
<template>
|
|
206
|
+
<MazCodeHighlight
|
|
207
|
+
code="const hello = 'world'"
|
|
208
|
+
language="ts"
|
|
209
|
+
:translations="{
|
|
210
|
+
copyToClipboard: 'Copier le code',
|
|
211
|
+
copiedToClipboard: 'Copié !',
|
|
212
|
+
}"
|
|
213
|
+
/>
|
|
214
|
+
</template>
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
</template>
|
|
218
|
+
</ComponentDemo>
|
|
219
|
+
|
|
220
|
+
For app-wide translations, set up the [maz-ui translations plugin](/translations) and the component will pick up your locale automatically.
|
|
221
|
+
|
|
222
|
+
<script lang="ts" setup>
|
|
223
|
+
const vueExample = `<script lang="ts" setup>
|
|
224
|
+
import { ref } from 'vue'
|
|
225
|
+
const count = ref(0)
|
|
226
|
+
<\/script>
|
|
227
|
+
|
|
228
|
+
<template>
|
|
229
|
+
<button @click="count++">Count: {{ count }}</button>
|
|
230
|
+
</template>`
|
|
231
|
+
</script>
|
|
232
|
+
|
|
233
|
+
<!--@include: ./../../.vitepress/generated-docs/maz-code-highlight.doc.md-->
|
|
@@ -16,6 +16,7 @@ description: A powerful and flexible date picker component with support for sing
|
|
|
16
16
|
- [Basic Usage](#basic-usage)
|
|
17
17
|
- [Date Formats](#date-formats)
|
|
18
18
|
- [Date Selection](#date-selection)
|
|
19
|
+
- [Custom Trigger](#custom-trigger)
|
|
19
20
|
- [Time Selection](#time-selection)
|
|
20
21
|
- [Range Selection](#range-selection)
|
|
21
22
|
- [Internationalization](#internationalization)
|
|
@@ -273,6 +274,58 @@ const date = ref()
|
|
|
273
274
|
</template>
|
|
274
275
|
</ComponentDemo>
|
|
275
276
|
|
|
277
|
+
## Custom Trigger
|
|
278
|
+
|
|
279
|
+
By default MazDatePicker renders a readonly `MazInput` as the field that opens the calendar. Use the `#trigger` slot to replace it with your own element - a button, a custom input, an icon... Clicking the slotted element opens the calendar automatically (no `@click` needed), and the slot exposes the current open state plus functions for programmatic control.
|
|
280
|
+
|
|
281
|
+
### Slot bindings
|
|
282
|
+
|
|
283
|
+
| Binding | Type | Description |
|
|
284
|
+
| --- | --- | --- |
|
|
285
|
+
| `is-open` | `boolean` | Whether the calendar is currently open |
|
|
286
|
+
| `open` | `() => void` | Open the calendar programmatically |
|
|
287
|
+
| `close` | `() => void` | Close the calendar programmatically |
|
|
288
|
+
| `toggle` | `() => void` | Toggle the calendar programmatically |
|
|
289
|
+
|
|
290
|
+
<ComponentDemo>
|
|
291
|
+
<MazDatePicker v-model="triggerDate" auto-close hide-header>
|
|
292
|
+
<template #trigger="{ isOpen }">
|
|
293
|
+
<MazBtn color="secondary" :class="{ 'maz:ring-2 maz:ring-offset-2 maz:ring-secondary': isOpen }">
|
|
294
|
+
{{ triggerDate || 'Pick a date' }}
|
|
295
|
+
</MazBtn>
|
|
296
|
+
</template>
|
|
297
|
+
</MazDatePicker>
|
|
298
|
+
|
|
299
|
+
<template #code>
|
|
300
|
+
|
|
301
|
+
```vue
|
|
302
|
+
<template>
|
|
303
|
+
<MazDatePicker v-model="date" auto-close>
|
|
304
|
+
<!-- Clicking the button opens the picker automatically. -->
|
|
305
|
+
<template #trigger="{ isOpen }">
|
|
306
|
+
<MazBtn color="secondary" :class="{ 'maz:ring-2 maz:ring-secondary': isOpen }">
|
|
307
|
+
{{ date || 'Pick a date' }}
|
|
308
|
+
</MazBtn>
|
|
309
|
+
</template>
|
|
310
|
+
</MazDatePicker>
|
|
311
|
+
</template>
|
|
312
|
+
|
|
313
|
+
<script setup>
|
|
314
|
+
import { ref } from 'vue'
|
|
315
|
+
|
|
316
|
+
const date = ref()
|
|
317
|
+
</script>
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
</template>
|
|
321
|
+
</ComponentDemo>
|
|
322
|
+
|
|
323
|
+
::: tip
|
|
324
|
+
The model value is not passed through the slot - use your own `v-model` ref (here `date`) to display the selected value in your custom trigger. The exposed `open` / `close` / `toggle` functions are only needed when you want to drive the picker from your own logic.
|
|
325
|
+
:::
|
|
326
|
+
|
|
327
|
+
> In `inline` mode the calendar is always visible, so the `trigger` slot is not rendered. To open the picker from an element rendered outside the component, use the `custom-element-selector` prop instead.
|
|
328
|
+
|
|
276
329
|
## Time Selection
|
|
277
330
|
|
|
278
331
|
### Date + Time (24h format)
|
|
@@ -896,7 +949,7 @@ const disabledHours = [0, 1, 2, 11, 22, 23]
|
|
|
896
949
|
|
|
897
950
|
## Internationalization
|
|
898
951
|
|
|
899
|
-
MazDatePicker supports full internationalization. **By default, it uses the locale from the [MazUiTranslations](../
|
|
952
|
+
MazDatePicker supports full internationalization. **By default, it uses the locale from the [MazUiTranslations](../ecosystem/translations.md) plugin**, but you can override it:
|
|
900
953
|
|
|
901
954
|
<ComponentDemo>
|
|
902
955
|
<div class="maz:grid maz:grid-cols-1 maz:mob-l:grid-cols-2 maz:gap-4">
|
|
@@ -1021,6 +1074,7 @@ const formatExample2 = ref('03/15/2024')
|
|
|
1021
1074
|
const formatExample3 = ref('15-03-2024')
|
|
1022
1075
|
const transformedDate = ref()
|
|
1023
1076
|
const newDateValue = ref()
|
|
1077
|
+
const triggerDate = ref()
|
|
1024
1078
|
// Date selection
|
|
1025
1079
|
const dateSelection = ref()
|
|
1026
1080
|
const inlineDate = ref()
|
|
@@ -103,10 +103,56 @@ For long content, you can enable scrolling in content part (Header and footer sl
|
|
|
103
103
|
</template>
|
|
104
104
|
</ComponentDemo>
|
|
105
105
|
|
|
106
|
+
## Width
|
|
107
|
+
|
|
108
|
+
On tablet and up, the dialog is sized by two CSS variables coming from the active theme preset (`components.dialog`):
|
|
109
|
+
|
|
110
|
+
- `--maz-dialog-max-width` (default `38rem`)
|
|
111
|
+
- `--maz-dialog-min-width` (default `32rem`)
|
|
112
|
+
|
|
113
|
+
You can set these defaults globally per preset — see [the theme `components.dialog` documentation](./../ecosystem/themes.md#dialog-sizing). To change the width of a single dialog, pass the `max-width` / `min-width` props — they always override the preset:
|
|
114
|
+
|
|
115
|
+
<ComponentDemo>
|
|
116
|
+
<MazBtn @click="widthOpened = true">Open Wide Dialog</MazBtn>
|
|
117
|
+
|
|
118
|
+
<MazDialog v-model="widthOpened" title="Custom width" max-width="50rem" min-width="40rem">
|
|
119
|
+
<p>
|
|
120
|
+
This dialog overrides the preset width through props.
|
|
121
|
+
</p>
|
|
122
|
+
<template #footer="{ close }">
|
|
123
|
+
<MazBtn @click="close">
|
|
124
|
+
Confirm
|
|
125
|
+
</MazBtn>
|
|
126
|
+
</template>
|
|
127
|
+
</MazDialog>
|
|
128
|
+
|
|
129
|
+
<template #code>
|
|
130
|
+
|
|
131
|
+
```vue
|
|
132
|
+
<template>
|
|
133
|
+
<MazDialog
|
|
134
|
+
v-model="isOpen"
|
|
135
|
+
title="Custom width"
|
|
136
|
+
max-width="50rem"
|
|
137
|
+
min-width="40rem"
|
|
138
|
+
>
|
|
139
|
+
<p>This dialog overrides the preset width through props.</p>
|
|
140
|
+
</MazDialog>
|
|
141
|
+
</template>
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
</template>
|
|
145
|
+
</ComponentDemo>
|
|
146
|
+
|
|
147
|
+
::: tip
|
|
148
|
+
The default widths are expressed in `rem`, so they scale with the preset's `base-font-size`. Presets with a larger base size (e.g. `ocean` at `16px`) ship rem values adjusted to keep the rendered pixel width consistent across presets.
|
|
149
|
+
:::
|
|
150
|
+
|
|
106
151
|
<!--@include: ./../../.vitepress/generated-docs/maz-dialog.doc.md-->
|
|
107
152
|
|
|
108
153
|
<script setup>
|
|
109
154
|
import { ref } from 'vue'
|
|
110
155
|
const isOpen = ref(false)
|
|
111
156
|
const scollableOpened = ref(false)
|
|
157
|
+
const widthOpened = ref(false)
|
|
112
158
|
</script>
|
|
@@ -16,10 +16,12 @@ description: MazDropdown is a standalone dropdown menu component and versatile d
|
|
|
16
16
|
<ComponentDemo>
|
|
17
17
|
<MazDropdown
|
|
18
18
|
:items="[
|
|
19
|
+
{ label: 'Louis Mazel', textColor: 'muted' },
|
|
19
20
|
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
20
21
|
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank', color: 'secondary' },
|
|
21
22
|
{ label: 'Router Link', to: { name: 'index' }, color: 'destructive' },
|
|
22
23
|
]"
|
|
24
|
+
items-size="sm"
|
|
23
25
|
>
|
|
24
26
|
Dropdown Menu
|
|
25
27
|
</MazDropdown>
|
|
@@ -82,6 +84,7 @@ This provides the best user experience across all devices without requiring manu
|
|
|
82
84
|
## Open dropdown only on click
|
|
83
85
|
|
|
84
86
|
<MazDropdown
|
|
87
|
+
:model-value="true"
|
|
85
88
|
:items="[
|
|
86
89
|
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
87
90
|
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank' },
|
|
@@ -220,8 +223,9 @@ You can provide an icon to replace the default chevron icon and disable the anim
|
|
|
220
223
|
fab
|
|
221
224
|
pastel
|
|
222
225
|
:chevron="false"
|
|
223
|
-
icon="
|
|
226
|
+
:icon="MazBars3"
|
|
224
227
|
size="xl"
|
|
228
|
+
items-size="sm"
|
|
225
229
|
:items="[
|
|
226
230
|
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
227
231
|
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank' },
|
|
@@ -230,23 +234,34 @@ You can provide an icon to replace the default chevron icon and disable the anim
|
|
|
230
234
|
:close-on-click="false"
|
|
231
235
|
/>
|
|
232
236
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
237
|
+
::: details View code
|
|
238
|
+
|
|
239
|
+
```vue{7-13}
|
|
240
|
+
<script lang="ts" setup>
|
|
241
|
+
import { MazBars3 } from '@maz-ui/icons/raw/MazBars3'
|
|
242
|
+
</script>
|
|
243
|
+
|
|
244
|
+
<template>
|
|
245
|
+
<MazDropdown
|
|
246
|
+
color="primary"
|
|
247
|
+
fab
|
|
248
|
+
pastel
|
|
249
|
+
:chevron="false"
|
|
250
|
+
:icon="MazBars3"
|
|
251
|
+
items-size="sm"
|
|
252
|
+
size="xl"
|
|
253
|
+
:items="[
|
|
254
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
255
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank' },
|
|
256
|
+
{ label: 'Router Link', to: { name: 'index' } },
|
|
257
|
+
]"
|
|
258
|
+
:close-on-click="false"
|
|
259
|
+
/>
|
|
260
|
+
</template>
|
|
248
261
|
```
|
|
249
262
|
|
|
263
|
+
:::
|
|
264
|
+
|
|
250
265
|
## Custom slots
|
|
251
266
|
|
|
252
267
|
### Custom dropdown panel
|
|
@@ -654,6 +669,7 @@ type MazDropdownMenuItem = {
|
|
|
654
669
|
import { ref, onMounted } from 'vue'
|
|
655
670
|
import { useToast } from 'maz-ui/composables/useToast'
|
|
656
671
|
import { MazChevronUpDown } from '@maz-ui/icons/raw/MazChevronUpDown'
|
|
672
|
+
import { MazBars3 } from '@maz-ui/icons/raw/MazBars3'
|
|
657
673
|
|
|
658
674
|
const toast = useToast()
|
|
659
675
|
|
|
@@ -8,7 +8,7 @@ description: A flexible icon component that accepts Vue components, raw SVG stri
|
|
|
8
8
|
{{ $frontmatter.description }}
|
|
9
9
|
|
|
10
10
|
::: tip
|
|
11
|
-
Download the bundled [icons pack](#all-bundled-icons) or use [`@maz-ui/icons`](../
|
|
11
|
+
Download the bundled [icons pack](#all-bundled-icons) or use [`@maz-ui/icons`](../ecosystem/icons/.md) for the full set.
|
|
12
12
|
:::
|
|
13
13
|
|
|
14
14
|
## How it works
|
|
@@ -177,15 +177,26 @@ Inject extra attributes onto the rendered `<svg>` (or onto the inlined raw SVG)
|
|
|
177
177
|
<MazIcon :icon="MazStar" :svg-attributes="{ 'data-testid': 'star', fill: 'currentColor' }" />
|
|
178
178
|
```
|
|
179
179
|
|
|
180
|
-
## SSR
|
|
180
|
+
## SSR
|
|
181
181
|
|
|
182
|
-
|
|
182
|
+
Components, raw SVG strings and SVG `data:` URIs (e.g. a small `?url` import inlined by Vite) are always part of the server HTML, without any request.
|
|
183
|
+
|
|
184
|
+
The server never waits for the network to render a URL icon:
|
|
185
|
+
|
|
186
|
+
- once the server has the SVG in its cache, it inlines it;
|
|
187
|
+
- otherwise, it renders an empty placeholder reserving the icon box and fetches the SVG in the background for the next renders. The client loads the icon in the placeholder.
|
|
188
|
+
|
|
189
|
+
A relative URL (`/icons/star.svg`, from your `public/` directory) can only be fetched by the server with an absolute base URL, see below.
|
|
190
|
+
|
|
191
|
+
## Base URL for relative URLs
|
|
192
|
+
|
|
193
|
+
Prefix every relative URL icon by providing a base URL via Vue's `provide`. An absolute base also lets the server fetch them:
|
|
183
194
|
|
|
184
195
|
```ts
|
|
185
196
|
import { createApp } from 'vue'
|
|
186
197
|
|
|
187
198
|
const app = createApp(App)
|
|
188
|
-
app.provide('mazIconPath', 'https://your-app.com')
|
|
199
|
+
app.provide('mazIconPath', 'https://cdn.your-app.com')
|
|
189
200
|
```
|
|
190
201
|
|
|
191
202
|
In Nuxt, set `mazUi.general.defaultMazIconPath` in `nuxt.config` and `@maz-ui/nuxt` wires the provide for you.
|
|
@@ -220,7 +231,7 @@ This pack is the Heroicons set plus a few additions specific to maz-ui.
|
|
|
220
231
|
Download pack
|
|
221
232
|
</MazBtn>
|
|
222
233
|
|
|
223
|
-
Source: [Heroicons](https://heroicons.com/) — see also the [icon set page](./../
|
|
234
|
+
Source: [Heroicons](https://heroicons.com/) — see also the [icon set page](./../ecosystem/icons/icon-set.md).
|
|
224
235
|
|
|
225
236
|
<div class="flex items-start flex-wrap gap-05">
|
|
226
237
|
<div v-for="({ component, name }, i) in iconsList" :key="i" class="flex flex-col flex-center maz:p-2 maz:rounded-md maz:border">
|
|
@@ -204,6 +204,11 @@ Customize what information is shown to users.
|
|
|
204
204
|
assistive-text="Text-only country selection"
|
|
205
205
|
hide-flags
|
|
206
206
|
/>
|
|
207
|
+
<MazInputPhoneNumber
|
|
208
|
+
top-label="Flags of maz-ui"
|
|
209
|
+
assistive-text="No request to flagcdn.com, works offline"
|
|
210
|
+
:flag-src="loadCountryFlag"
|
|
211
|
+
/>
|
|
207
212
|
</div>
|
|
208
213
|
|
|
209
214
|
<template #code>
|
|
@@ -224,12 +229,36 @@ Customize what information is shown to users.
|
|
|
224
229
|
|
|
225
230
|
<!-- Hide country flags -->
|
|
226
231
|
<MazInputPhoneNumber hide-flags />
|
|
232
|
+
|
|
233
|
+
<!-- Flags of maz-ui, no request to flagcdn.com: import { loadCountryFlag } from 'maz-ui/country-flags' -->
|
|
234
|
+
<MazInputPhoneNumber :flag-src="loadCountryFlag" />
|
|
235
|
+
|
|
236
|
+
<!-- Your own files: public/flags/fr.svg... -->
|
|
237
|
+
<MazInputPhoneNumber flag-src="/flags/{code}.svg" />
|
|
227
238
|
</template>
|
|
228
239
|
```
|
|
229
240
|
|
|
230
241
|
</template>
|
|
231
242
|
</ComponentDemo>
|
|
232
243
|
|
|
244
|
+
### Flags source
|
|
245
|
+
|
|
246
|
+
By default, the flags come from the [flagcdn.com](https://flagcdn.com) CDN. The `flag-src` prop, passed to the country selector, takes:
|
|
247
|
+
|
|
248
|
+
- `loadCountryFlag` from `maz-ui/country-flags`: the flags of `@maz-ui/icons`, without any request to a third party, offline (hybrid apps with Capacitor or Cordova, PWAs);
|
|
249
|
+
- a URL template of your own files: `'/flags/{code}.svg'` (`{CODE}` for uppercase codes);
|
|
250
|
+
- your own function: `(code) => string | undefined | Promise<string | undefined>`.
|
|
251
|
+
|
|
252
|
+
Each flag is loaded only when visible, and a code without flag displays a badge. Set it once for the whole app with `defaults.global.flagSrc` of the MazUi plugin, or `mazUi.flags` of the Nuxt module (`'local'` or a URL template):
|
|
253
|
+
|
|
254
|
+
```ts
|
|
255
|
+
import { loadCountryFlag } from 'maz-ui/country-flags'
|
|
256
|
+
|
|
257
|
+
app.use(MazUi, { theme: { preset: mazUi }, defaults: { global: { flagSrc: loadCountryFlag } } })
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
See [MazSelectCountry](./maz-select-country.md#flags-source) for the details (bundle, Content Security Policy, PWA precache).
|
|
261
|
+
|
|
233
262
|
## Smart Country Detection
|
|
234
263
|
|
|
235
264
|
Let the component automatically detect the user's country.
|
|
@@ -886,6 +915,7 @@ interface MazInputPhoneNumberData {
|
|
|
886
915
|
<!--@include: ./../../.vitepress/generated-docs/maz-input-phone-number.doc.md-->
|
|
887
916
|
|
|
888
917
|
<script setup lang="ts">
|
|
918
|
+
import { loadCountryFlag } from 'maz-ui/country-flags'
|
|
889
919
|
import { ref } from 'vue'
|
|
890
920
|
|
|
891
921
|
// Basic usage
|
|
@@ -21,4 +21,68 @@ import MazLazyImg from 'maz-ui/components/MazLazyImg'
|
|
|
21
21
|
</template>
|
|
22
22
|
```
|
|
23
23
|
|
|
24
|
+
::: tip Performance
|
|
25
|
+
`MazLazyImg` relies on the [`vLazyImg`](./../directives/lazy-img.md) directive, whose `IntersectionObserver`s are pooled and shared across every instance - rendering many images (galleries, lists, avatars) stays cheap.
|
|
26
|
+
:::
|
|
27
|
+
|
|
28
|
+
## Responsive sources
|
|
29
|
+
|
|
30
|
+
Pass an object with `sources` to serve different images depending on the media query (like a native `<picture>`).
|
|
31
|
+
|
|
32
|
+
```vue
|
|
33
|
+
<template>
|
|
34
|
+
<MazLazyImg
|
|
35
|
+
:src="{
|
|
36
|
+
sources: [
|
|
37
|
+
{ srcset: 'https://placedog.net/600/400', media: '(max-width: 600px)' },
|
|
38
|
+
{ srcset: 'https://placedog.net/1500/1000', media: '(min-width: 601px)' },
|
|
39
|
+
],
|
|
40
|
+
}"
|
|
41
|
+
block
|
|
42
|
+
/>
|
|
43
|
+
</template>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Image height full
|
|
47
|
+
|
|
48
|
+
By default the image is displayed with `width: 100%`. Enable `image-height-full` to fill the **height** instead: the image keeps its aspect ratio, fills 100% of the height and overflows/crops horizontally. Handy for wide images or SVGs inside a fixed-height container.
|
|
49
|
+
|
|
50
|
+
```vue
|
|
51
|
+
<template>
|
|
52
|
+
<div style="height: 200px;">
|
|
53
|
+
<MazLazyImg image-height-full src="https://placedog.net/1500/1000" />
|
|
54
|
+
</div>
|
|
55
|
+
</template>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Fallback on error
|
|
59
|
+
|
|
60
|
+
Provide `fallback-src` to swap the image when it fails to load.
|
|
61
|
+
|
|
62
|
+
<MazLazyImg
|
|
63
|
+
block
|
|
64
|
+
src="https://broken-link-image-src.example"
|
|
65
|
+
fallback-src="https://placedog.net/500/500?id=42"
|
|
66
|
+
/>
|
|
67
|
+
|
|
68
|
+
```vue
|
|
69
|
+
<template>
|
|
70
|
+
<MazLazyImg
|
|
71
|
+
src="https://broken-link-image-src.example"
|
|
72
|
+
fallback-src="https://placedog.net/500/500"
|
|
73
|
+
block
|
|
74
|
+
/>
|
|
75
|
+
</template>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Without loader
|
|
79
|
+
|
|
80
|
+
Hide the spinner shown while the image is loading with `hide-loader`.
|
|
81
|
+
|
|
82
|
+
```vue
|
|
83
|
+
<template>
|
|
84
|
+
<MazLazyImg src="https://placedog.net/1000/1000" hide-loader block />
|
|
85
|
+
</template>
|
|
86
|
+
```
|
|
87
|
+
|
|
24
88
|
<!--@include: ./../../.vitepress/generated-docs/maz-lazy-img.doc.md-->
|