@maz-ui/mcp 4.0.0-beta.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +264 -0
- package/bin/maz-ui-mcp.mjs +7 -0
- package/dist/mcp.d.mts +13 -0
- package/dist/mcp.d.ts +13 -0
- package/dist/mcp.mjs +586 -0
- package/docs/generated-docs/maz-accordion.doc.md +21 -0
- package/docs/generated-docs/maz-animated-counter.doc.md +17 -0
- package/docs/generated-docs/maz-animated-element.doc.md +14 -0
- package/docs/generated-docs/maz-animated-text.doc.md +14 -0
- package/docs/generated-docs/maz-avatar.doc.md +44 -0
- package/docs/generated-docs/maz-backdrop.doc.md +61 -0
- package/docs/generated-docs/maz-badge.doc.md +16 -0
- package/docs/generated-docs/maz-bottom-sheet.doc.md +21 -0
- package/docs/generated-docs/maz-btn.doc.md +30 -0
- package/docs/generated-docs/maz-card-spotlight.doc.md +16 -0
- package/docs/generated-docs/maz-card.doc.md +39 -0
- package/docs/generated-docs/maz-carousel.doc.md +16 -0
- package/docs/generated-docs/maz-chart.doc.md +10 -0
- package/docs/generated-docs/maz-checkbox.doc.md +34 -0
- package/docs/generated-docs/maz-checklist.doc.md +30 -0
- package/docs/generated-docs/maz-circular-progress-bar.doc.md +27 -0
- package/docs/generated-docs/maz-date-picker.doc.md +52 -0
- package/docs/generated-docs/maz-dialog-confirm.doc.md +24 -0
- package/docs/generated-docs/maz-dialog.doc.md +22 -0
- package/docs/generated-docs/maz-drawer.doc.md +26 -0
- package/docs/generated-docs/maz-dropdown.doc.md +42 -0
- package/docs/generated-docs/maz-dropzone.doc.md +82 -0
- package/docs/generated-docs/maz-expand-animation.doc.md +12 -0
- package/docs/generated-docs/maz-fullscreen-loader.doc.md +13 -0
- package/docs/generated-docs/maz-gallery.doc.md +17 -0
- package/docs/generated-docs/maz-icon.doc.md +18 -0
- package/docs/generated-docs/maz-input-code.doc.md +25 -0
- package/docs/generated-docs/maz-input-number.doc.md +31 -0
- package/docs/generated-docs/maz-input-phone-number.doc.md +56 -0
- package/docs/generated-docs/maz-input-price.doc.md +26 -0
- package/docs/generated-docs/maz-input-tags.doc.md +24 -0
- package/docs/generated-docs/maz-input.doc.md +54 -0
- package/docs/generated-docs/maz-lazy-img.doc.md +31 -0
- package/docs/generated-docs/maz-link.doc.md +31 -0
- package/docs/generated-docs/maz-loading-bar.doc.md +6 -0
- package/docs/generated-docs/maz-pagination.doc.md +22 -0
- package/docs/generated-docs/maz-popover.doc.md +70 -0
- package/docs/generated-docs/maz-pull-to-refresh.doc.md +31 -0
- package/docs/generated-docs/maz-radio-buttons.doc.md +33 -0
- package/docs/generated-docs/maz-radio.doc.md +33 -0
- package/docs/generated-docs/maz-reading-progress-bar.doc.md +18 -0
- package/docs/generated-docs/maz-select-country.doc.md +44 -0
- package/docs/generated-docs/maz-select.doc.md +65 -0
- package/docs/generated-docs/maz-slider.doc.md +20 -0
- package/docs/generated-docs/maz-spinner.doc.md +6 -0
- package/docs/generated-docs/maz-stepper.doc.md +29 -0
- package/docs/generated-docs/maz-switch.doc.md +31 -0
- package/docs/generated-docs/maz-table-cell.doc.md +5 -0
- package/docs/generated-docs/maz-table-row.doc.md +11 -0
- package/docs/generated-docs/maz-table-title.doc.md +5 -0
- package/docs/generated-docs/maz-table.doc.md +66 -0
- package/docs/generated-docs/maz-tabs-bar.doc.md +18 -0
- package/docs/generated-docs/maz-tabs-content-item.doc.md +11 -0
- package/docs/generated-docs/maz-tabs-content.doc.md +5 -0
- package/docs/generated-docs/maz-tabs.doc.md +17 -0
- package/docs/generated-docs/maz-textarea.doc.md +41 -0
- package/docs/src/components/index.md +8 -0
- package/docs/src/components/maz-accordion.md +80 -0
- package/docs/src/components/maz-animated-counter.md +124 -0
- package/docs/src/components/maz-animated-element.md +36 -0
- package/docs/src/components/maz-animated-text.md +36 -0
- package/docs/src/components/maz-avatar.md +179 -0
- package/docs/src/components/maz-backdrop.md +16 -0
- package/docs/src/components/maz-badge.md +222 -0
- package/docs/src/components/maz-bottom-sheet.md +398 -0
- package/docs/src/components/maz-btn.md +526 -0
- package/docs/src/components/maz-card-spotlight.md +163 -0
- package/docs/src/components/maz-card.md +447 -0
- package/docs/src/components/maz-carousel.md +127 -0
- package/docs/src/components/maz-chart.md +346 -0
- package/docs/src/components/maz-checkbox.md +168 -0
- package/docs/src/components/maz-checklist.md +414 -0
- package/docs/src/components/maz-circular-progress-bar.md +147 -0
- package/docs/src/components/maz-date-picker.md +1078 -0
- package/docs/src/components/maz-dialog-confirm.md +240 -0
- package/docs/src/components/maz-dialog.md +208 -0
- package/docs/src/components/maz-drawer.md +177 -0
- package/docs/src/components/maz-dropdown.md +650 -0
- package/docs/src/components/maz-dropzone.md +442 -0
- package/docs/src/components/maz-expand-animation.md +99 -0
- package/docs/src/components/maz-fullscreen-loader.md +58 -0
- package/docs/src/components/maz-gallery.md +85 -0
- package/docs/src/components/maz-icon.md +85 -0
- package/docs/src/components/maz-input-code.md +61 -0
- package/docs/src/components/maz-input-number.md +81 -0
- package/docs/src/components/maz-input-phone-number.md +867 -0
- package/docs/src/components/maz-input-price.md +58 -0
- package/docs/src/components/maz-input-tags.md +114 -0
- package/docs/src/components/maz-input.md +453 -0
- package/docs/src/components/maz-lazy-img.md +24 -0
- package/docs/src/components/maz-link.md +156 -0
- package/docs/src/components/maz-loading-bar.md +26 -0
- package/docs/src/components/maz-pagination.md +81 -0
- package/docs/src/components/maz-popover.md +1414 -0
- package/docs/src/components/maz-pull-to-refresh.md +49 -0
- package/docs/src/components/maz-radio-buttons.md +456 -0
- package/docs/src/components/maz-radio.md +141 -0
- package/docs/src/components/maz-reading-progress-bar.md +74 -0
- package/docs/src/components/maz-select-country.md +636 -0
- package/docs/src/components/maz-select.md +439 -0
- package/docs/src/components/maz-slider.md +191 -0
- package/docs/src/components/maz-spinner.md +93 -0
- package/docs/src/components/maz-stepper.md +418 -0
- package/docs/src/components/maz-switch.md +92 -0
- package/docs/src/components/maz-table.md +571 -0
- package/docs/src/components/maz-tabs.md +231 -0
- package/docs/src/components/maz-textarea.md +218 -0
- package/docs/src/composables/use-aos.md +34 -0
- package/docs/src/composables/use-breakpoints.md +35 -0
- package/docs/src/composables/use-dialog.md +88 -0
- package/docs/src/composables/use-display-names.md +174 -0
- package/docs/src/composables/use-form-validator.md +1149 -0
- package/docs/src/composables/use-idle-timeout.md +256 -0
- package/docs/src/composables/use-reading-time.md +168 -0
- package/docs/src/composables/use-string-matching.md +63 -0
- package/docs/src/composables/use-swipe.md +223 -0
- package/docs/src/composables/use-timer.md +130 -0
- package/docs/src/composables/use-toast.md +71 -0
- package/docs/src/composables/use-user-visibility.md +169 -0
- package/docs/src/composables/use-wait.md +62 -0
- package/docs/src/composables/use-window-size.md +18 -0
- package/docs/src/demo/DemoAuthPage.vue +178 -0
- package/docs/src/demo/DemoDashboardPage.vue +298 -0
- package/docs/src/demo/DemoProductPage.vue +135 -0
- package/docs/src/directives/click-outside.md +275 -0
- package/docs/src/directives/fullscreen-img.md +101 -0
- package/docs/src/directives/lazy-img.md +184 -0
- package/docs/src/directives/tooltip.md +458 -0
- package/docs/src/directives/zoom-img.md +127 -0
- package/docs/src/guide/cli.md +144 -0
- package/docs/src/guide/getting-started.md +284 -0
- package/docs/src/guide/icon-set.md +60 -0
- package/docs/src/guide/icons.md +481 -0
- package/docs/src/guide/mcp.md +210 -0
- package/docs/src/guide/migration-v4.md +898 -0
- package/docs/src/guide/nuxt.md +411 -0
- package/docs/src/guide/resolvers.md +697 -0
- package/docs/src/guide/themes.md +789 -0
- package/docs/src/guide/translations.md +1173 -0
- package/docs/src/guide/vue.md +243 -0
- package/docs/src/helpers/camel-case.md +14 -0
- package/docs/src/helpers/capitalize.md +51 -0
- package/docs/src/helpers/check-availability.md +14 -0
- package/docs/src/helpers/country-code-to-unicode-flag.md +213 -0
- package/docs/src/helpers/currency.md +67 -0
- package/docs/src/helpers/date.md +67 -0
- package/docs/src/helpers/debounce-callback.md +14 -0
- package/docs/src/helpers/debounce-id.md +14 -0
- package/docs/src/helpers/debounce.md +14 -0
- package/docs/src/helpers/get-country-flag-url.md +156 -0
- package/docs/src/helpers/is-client.md +14 -0
- package/docs/src/helpers/is-equal.md +14 -0
- package/docs/src/helpers/is-standalone-mode.md +14 -0
- package/docs/src/helpers/kebab-case.md +14 -0
- package/docs/src/helpers/normalize-string.md +14 -0
- package/docs/src/helpers/number.md +65 -0
- package/docs/src/helpers/pascal-case.md +14 -0
- package/docs/src/helpers/script-loader.md +14 -0
- package/docs/src/helpers/sleep.md +14 -0
- package/docs/src/helpers/snake-case.md +14 -0
- package/docs/src/helpers/throttle-id.md +14 -0
- package/docs/src/helpers/throttle.md +14 -0
- package/docs/src/index.md +555 -0
- package/docs/src/made-with-maz-ui.md +58 -0
- package/docs/src/plugins/aos.md +347 -0
- package/docs/src/plugins/dialog.md +411 -0
- package/docs/src/plugins/toast.md +349 -0
- package/docs/src/plugins/wait.md +109 -0
- package/package.json +84 -0
|
@@ -0,0 +1,650 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: MazDropdown
|
|
3
|
+
description: MazDropdown is a standalone dropdown menu component and versatile designed for various use cases.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
<!--@include: ./../.vitepress/mixins/getting-started.md-->
|
|
11
|
+
|
|
12
|
+
<!--@include: ./../.vitepress/mixins/translated-component.md-->
|
|
13
|
+
|
|
14
|
+
## Basic usage
|
|
15
|
+
|
|
16
|
+
<MazDropdown
|
|
17
|
+
:items="[
|
|
18
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
19
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank', color: 'secondary' },
|
|
20
|
+
{ label: 'Router Link', to: { name: 'index' }, color: 'destructive' },
|
|
21
|
+
]"
|
|
22
|
+
>
|
|
23
|
+
Dropdown Menu
|
|
24
|
+
</MazDropdown>
|
|
25
|
+
|
|
26
|
+
```vue
|
|
27
|
+
<template>
|
|
28
|
+
<MazDropdown
|
|
29
|
+
:items="[
|
|
30
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
31
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank', color: 'secondary' },
|
|
32
|
+
{ label: 'Router Link', to: { name: 'index' }, color: 'destructive' },
|
|
33
|
+
]"
|
|
34
|
+
>
|
|
35
|
+
Dropdown Menu
|
|
36
|
+
</MazDropdown>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<script lang="ts" setup>
|
|
40
|
+
import { MazDropdown } from 'maz-ui/components'
|
|
41
|
+
</script>
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Open dropdown with adaptive trigger
|
|
45
|
+
|
|
46
|
+
The `adaptive` trigger mode automatically adapts to the user's device:
|
|
47
|
+
- **Desktop**: Uses hover behavior (mouseenter/mouseleave)
|
|
48
|
+
- **Mobile/Touch devices**: Uses click behavior
|
|
49
|
+
|
|
50
|
+
This provides the best user experience across all devices without requiring manual configuration.
|
|
51
|
+
|
|
52
|
+
<MazDropdown
|
|
53
|
+
:items="[
|
|
54
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
55
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank' },
|
|
56
|
+
{ label: 'Router Link', to: { name: 'index' } },
|
|
57
|
+
]"
|
|
58
|
+
trigger="adaptive"
|
|
59
|
+
>
|
|
60
|
+
Adaptive trigger
|
|
61
|
+
</MazDropdown>
|
|
62
|
+
|
|
63
|
+
```html{7}
|
|
64
|
+
<MazDropdown
|
|
65
|
+
:items="[
|
|
66
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
67
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank' },
|
|
68
|
+
{ label: 'Router Link', to: { name: 'index' } },
|
|
69
|
+
]"
|
|
70
|
+
trigger="adaptive"
|
|
71
|
+
>
|
|
72
|
+
Adaptive trigger
|
|
73
|
+
</MazDropdown>
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Open dropdown only on click
|
|
77
|
+
|
|
78
|
+
<MazDropdown
|
|
79
|
+
:items="[
|
|
80
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
81
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank' },
|
|
82
|
+
{ label: 'Router Link', to: { name: 'index' } },
|
|
83
|
+
]"
|
|
84
|
+
trigger="click"
|
|
85
|
+
>
|
|
86
|
+
Click me
|
|
87
|
+
</MazDropdown>
|
|
88
|
+
|
|
89
|
+
```html{7}
|
|
90
|
+
<MazDropdown
|
|
91
|
+
:items="[
|
|
92
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
93
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank' },
|
|
94
|
+
{ label: 'Router Link', to: { name: 'index' } },
|
|
95
|
+
]"
|
|
96
|
+
trigger="click"
|
|
97
|
+
>
|
|
98
|
+
Click me
|
|
99
|
+
</MazDropdown>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Open dropdown only on hover
|
|
103
|
+
|
|
104
|
+
<MazDropdown
|
|
105
|
+
:items="[
|
|
106
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
107
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank' },
|
|
108
|
+
{ label: 'Router Link', to: { name: 'index' } },
|
|
109
|
+
]"
|
|
110
|
+
trigger="hover"
|
|
111
|
+
>
|
|
112
|
+
Hover me
|
|
113
|
+
</MazDropdown>
|
|
114
|
+
|
|
115
|
+
```html{7}
|
|
116
|
+
<MazDropdown
|
|
117
|
+
:items="[
|
|
118
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
119
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank' },
|
|
120
|
+
{ label: 'Router Link', to: { name: 'index' } },
|
|
121
|
+
]"
|
|
122
|
+
trigger="hover"
|
|
123
|
+
>
|
|
124
|
+
Hover me
|
|
125
|
+
</MazDropdown>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Custom dropdown icon
|
|
129
|
+
|
|
130
|
+
You can provide an icon to replace the default chevron icon and disable the animation
|
|
131
|
+
|
|
132
|
+
<MazDropdown
|
|
133
|
+
:items="[
|
|
134
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
135
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank' },
|
|
136
|
+
{ label: 'Router Link', to: { name: 'index' } },
|
|
137
|
+
]"
|
|
138
|
+
trigger="hover"
|
|
139
|
+
:dropdown-icon="MazChevronUpDown"
|
|
140
|
+
>
|
|
141
|
+
Custom icon
|
|
142
|
+
</MazDropdown>
|
|
143
|
+
|
|
144
|
+
<MazDropdown
|
|
145
|
+
:items="[
|
|
146
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
147
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank' },
|
|
148
|
+
{ label: 'Router Link', to: { name: 'index' } },
|
|
149
|
+
]"
|
|
150
|
+
trigger="hover"
|
|
151
|
+
:dropdown-icon="MazChevronUpDown"
|
|
152
|
+
:dropdown-icon-animation="false"
|
|
153
|
+
>
|
|
154
|
+
No icon animation
|
|
155
|
+
</MazDropdown>
|
|
156
|
+
|
|
157
|
+
```vue{7}
|
|
158
|
+
<script lang="ts" setup>
|
|
159
|
+
// Use vite-svg-loader to import SVG as Vue component
|
|
160
|
+
import MazChevronUpDown from '@maz-ui/icons/chevron-up-down.svg?component'
|
|
161
|
+
</script>
|
|
162
|
+
|
|
163
|
+
<template>
|
|
164
|
+
<MazDropdown
|
|
165
|
+
:items="[
|
|
166
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
167
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank' },
|
|
168
|
+
{ label: 'Router Link', to: { name: 'index' } },
|
|
169
|
+
]"
|
|
170
|
+
trigger="hover"
|
|
171
|
+
:dropdown-icon="MazChevronUpDown"
|
|
172
|
+
>
|
|
173
|
+
Hover me
|
|
174
|
+
</MazDropdown>
|
|
175
|
+
|
|
176
|
+
<MazDropdown
|
|
177
|
+
:items="[
|
|
178
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
179
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank' },
|
|
180
|
+
{ label: 'Router Link', to: { name: 'index' } },
|
|
181
|
+
]"
|
|
182
|
+
trigger="hover"
|
|
183
|
+
:dropdown-icon="MazChevronUpDown"
|
|
184
|
+
:dropdown-icon-animation="false"
|
|
185
|
+
>
|
|
186
|
+
No icon animation
|
|
187
|
+
</MazDropdown>
|
|
188
|
+
</template>
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Custom dropdown main button without chevron icon
|
|
192
|
+
|
|
193
|
+
::: tip
|
|
194
|
+
This component uses [MazBtn](./maz-btn.md) has a menu button, so it inherits all its props
|
|
195
|
+
:::
|
|
196
|
+
|
|
197
|
+
<MazDropdown
|
|
198
|
+
color="primary"
|
|
199
|
+
fab
|
|
200
|
+
pastel
|
|
201
|
+
:chevron="false"
|
|
202
|
+
icon="bars-3"
|
|
203
|
+
size="xl"
|
|
204
|
+
:items="[
|
|
205
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
206
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank' },
|
|
207
|
+
{ label: 'Router Link', to: { name: 'index' } },
|
|
208
|
+
]"
|
|
209
|
+
:close-on-click="false"
|
|
210
|
+
/>
|
|
211
|
+
|
|
212
|
+
```html{2-7}
|
|
213
|
+
<MazDropdown
|
|
214
|
+
color="primary"
|
|
215
|
+
fab
|
|
216
|
+
pastel
|
|
217
|
+
:chevron="false"
|
|
218
|
+
icon="bars-3"
|
|
219
|
+
size="xl"
|
|
220
|
+
:items="[
|
|
221
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
222
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank' },
|
|
223
|
+
{ label: 'Router Link', to: { name: 'index' } },
|
|
224
|
+
]"
|
|
225
|
+
:close-on-click="false"
|
|
226
|
+
/>
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
## Custom slots
|
|
230
|
+
|
|
231
|
+
### Custom dropdown panel
|
|
232
|
+
|
|
233
|
+
You can provide a template to replace the default dropdown panel
|
|
234
|
+
|
|
235
|
+
<MazDropdown>
|
|
236
|
+
Customized dropdown
|
|
237
|
+
|
|
238
|
+
<template #dropdown>
|
|
239
|
+
<div class="maz-grid maz-grid-cols-3 maz-gap-2">
|
|
240
|
+
<MazBtn color="transparent"> Item </MazBtn>
|
|
241
|
+
<MazBtn color="transparent"> Item </MazBtn>
|
|
242
|
+
<MazBtn color="transparent"> Item </MazBtn>
|
|
243
|
+
<MazBtn color="transparent"> Item </MazBtn>
|
|
244
|
+
<MazBtn color="transparent"> Item </MazBtn>
|
|
245
|
+
<MazBtn color="transparent"> Item </MazBtn>
|
|
246
|
+
<MazBtn color="transparent"> Item </MazBtn>
|
|
247
|
+
<MazBtn color="transparent"> Item </MazBtn>
|
|
248
|
+
<MazBtn color="transparent"> Item </MazBtn>
|
|
249
|
+
<MazBtn color="transparent"> Item </MazBtn>
|
|
250
|
+
<MazBtn color="transparent"> Item </MazBtn>
|
|
251
|
+
<MazBtn color="transparent"> Item </MazBtn>
|
|
252
|
+
</div>
|
|
253
|
+
</template>
|
|
254
|
+
</MazDropdown>
|
|
255
|
+
|
|
256
|
+
::: details View code
|
|
257
|
+
|
|
258
|
+
```html
|
|
259
|
+
<MazDropdown>
|
|
260
|
+
Customized dropdown panel
|
|
261
|
+
|
|
262
|
+
<template #dropdown>
|
|
263
|
+
<div class="maz-grid maz-grid-cols-3 maz-gap-2">
|
|
264
|
+
<MazBtn color="transparent"> Item </MazBtn>
|
|
265
|
+
<MazBtn color="transparent"> Item </MazBtn>
|
|
266
|
+
<MazBtn color="transparent"> Item </MazBtn>
|
|
267
|
+
<MazBtn color="transparent"> Item </MazBtn>
|
|
268
|
+
<MazBtn color="transparent"> Item </MazBtn>
|
|
269
|
+
<MazBtn color="transparent"> Item </MazBtn>
|
|
270
|
+
<MazBtn color="transparent"> Item </MazBtn>
|
|
271
|
+
<MazBtn color="transparent"> Item </MazBtn>
|
|
272
|
+
<MazBtn color="transparent"> Item </MazBtn>
|
|
273
|
+
<MazBtn color="transparent"> Item </MazBtn>
|
|
274
|
+
<MazBtn color="transparent"> Item </MazBtn>
|
|
275
|
+
<MazBtn color="transparent"> Item </MazBtn>
|
|
276
|
+
</div>
|
|
277
|
+
</template>
|
|
278
|
+
</MazDropdown>
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
:::
|
|
282
|
+
|
|
283
|
+
### Custom menuitem labels
|
|
284
|
+
|
|
285
|
+
You can provide a template to replace menuitem labels to add more elements in each menuitem
|
|
286
|
+
|
|
287
|
+
<MazDropdown
|
|
288
|
+
:items="[
|
|
289
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED'), additionnalData: 'https://loremflickr.com/240/200' },
|
|
290
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank', additionnalData: 'https://loremflickr.com/340/300' },
|
|
291
|
+
{ label: 'Router Link', to: { name: 'index' }, additionnalData: 'https://loremflickr.com/440/400' },
|
|
292
|
+
]"
|
|
293
|
+
>
|
|
294
|
+
<template #default>
|
|
295
|
+
Customized labels
|
|
296
|
+
</template>
|
|
297
|
+
|
|
298
|
+
<template #menuitem-label="{ item }">
|
|
299
|
+
<div class="maz-flex maz-items-center maz-gap-3">
|
|
300
|
+
<MazAvatar :src="item.additionnalData" size="0.8rem" />
|
|
301
|
+
<span>
|
|
302
|
+
{{ item.label }}
|
|
303
|
+
</span>
|
|
304
|
+
</div>
|
|
305
|
+
</template>
|
|
306
|
+
</MazDropdown>
|
|
307
|
+
|
|
308
|
+
::: details View code
|
|
309
|
+
|
|
310
|
+
```html
|
|
311
|
+
<MazDropdown
|
|
312
|
+
:items="[
|
|
313
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED'), additionnalData: 'https://loremflickr.com/240/200' },
|
|
314
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank', additionnalData: 'https://loremflickr.com/340/300' },
|
|
315
|
+
{ label: 'Router Link', to: { name: 'index' }, additionnalData: 'https://loremflickr.com/440/400' },
|
|
316
|
+
]"
|
|
317
|
+
>
|
|
318
|
+
<template #default>
|
|
319
|
+
Customized labels
|
|
320
|
+
</template>
|
|
321
|
+
|
|
322
|
+
<template #menuitem-label="{ item }">
|
|
323
|
+
<div class="maz-flex maz-items-center maz-gap-2">
|
|
324
|
+
<MazAvatar :src="item.additionnalData" />
|
|
325
|
+
<span>
|
|
326
|
+
{{ item.label }}
|
|
327
|
+
</span>
|
|
328
|
+
</div>
|
|
329
|
+
</template>
|
|
330
|
+
</MazDropdown>
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
:::
|
|
334
|
+
|
|
335
|
+
### Custom control triggered element
|
|
336
|
+
|
|
337
|
+
You can provide an HTML element or a component to replace the default button
|
|
338
|
+
|
|
339
|
+
::: warning
|
|
340
|
+
Add `tabindex="-1"` attribute to your element to avoid a double focus with Tab key
|
|
341
|
+
:::
|
|
342
|
+
|
|
343
|
+
<div class="maz-flex maz-gap-4">
|
|
344
|
+
<MazDropdown
|
|
345
|
+
:items="[
|
|
346
|
+
{
|
|
347
|
+
label: 'Action',
|
|
348
|
+
onClick: () => toast.success('CLICKED'),
|
|
349
|
+
additionnalData: 'https://loremflickr.com/240/200',
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
label: 'Link (href)',
|
|
353
|
+
href: 'https://www.google.com',
|
|
354
|
+
target: '_blank',
|
|
355
|
+
additionnalData: 'https://loremflickr.com/340/300',
|
|
356
|
+
},
|
|
357
|
+
{
|
|
358
|
+
label: 'Router Link',
|
|
359
|
+
to: { name: 'index' },
|
|
360
|
+
additionnalData: 'https://loremflickr.com/440/400',
|
|
361
|
+
},
|
|
362
|
+
]"
|
|
363
|
+
>
|
|
364
|
+
<template #trigger>
|
|
365
|
+
<MazAvatar
|
|
366
|
+
clickable
|
|
367
|
+
hide-clickable-icon
|
|
368
|
+
src="https://loremflickr.com/200/200"
|
|
369
|
+
tabindex="-1"
|
|
370
|
+
/>
|
|
371
|
+
</template>
|
|
372
|
+
</MazDropdown>
|
|
373
|
+
|
|
374
|
+
<MazDropdown
|
|
375
|
+
position="top"
|
|
376
|
+
:items="[
|
|
377
|
+
{
|
|
378
|
+
label: 'Action',
|
|
379
|
+
onClick: () => toast.success('CLICKED'),
|
|
380
|
+
additionnalData: 'https://loremflickr.com/240/200',
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
label: 'Link (href)',
|
|
384
|
+
href: 'https://www.google.com',
|
|
385
|
+
target: '_blank',
|
|
386
|
+
additionnalData: 'https://loremflickr.com/340/300',
|
|
387
|
+
},
|
|
388
|
+
{
|
|
389
|
+
label: 'Router Link',
|
|
390
|
+
to: { name: 'index' },
|
|
391
|
+
additionnalData: 'https://loremflickr.com/440/400',
|
|
392
|
+
},
|
|
393
|
+
]"
|
|
394
|
+
>
|
|
395
|
+
<template #element="{ isOpen }">
|
|
396
|
+
<button class="maz-border maz-border-solid maz-border-divider-400 maz-p-2 hover:maz-bg-surface-400" tabindex="-1">
|
|
397
|
+
HTMLButtonElement: isOpen {{ isOpen }}
|
|
398
|
+
</button>
|
|
399
|
+
</template>
|
|
400
|
+
</MazDropdown>
|
|
401
|
+
</div>
|
|
402
|
+
|
|
403
|
+
::: details View code
|
|
404
|
+
|
|
405
|
+
```html
|
|
406
|
+
<MazDropdown
|
|
407
|
+
:items="[
|
|
408
|
+
{
|
|
409
|
+
label: 'Action',
|
|
410
|
+
onClick: () => toast.success('CLICKED'),
|
|
411
|
+
additionnalData: 'https://loremflickr.com/240/200',
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
label: 'Link (href)',
|
|
415
|
+
href: 'https://www.google.com',
|
|
416
|
+
target: '_blank',
|
|
417
|
+
additionnalData: 'https://loremflickr.com/340/300',
|
|
418
|
+
},
|
|
419
|
+
{
|
|
420
|
+
label: 'Router Link',
|
|
421
|
+
to: { name: 'index' },
|
|
422
|
+
additionnalData: 'https://loremflickr.com/440/400',
|
|
423
|
+
},
|
|
424
|
+
]"
|
|
425
|
+
>
|
|
426
|
+
<template #element>
|
|
427
|
+
<MazAvatar
|
|
428
|
+
clickable
|
|
429
|
+
hide-clickable-icon
|
|
430
|
+
src="https://cdn.artphotolimited.com/images/5ff5a529bd40b83c5a537440/1000x1000/gerard-depardieu-1983.jpg"
|
|
431
|
+
tabindex="-1"
|
|
432
|
+
/>
|
|
433
|
+
</template>
|
|
434
|
+
</MazDropdown>
|
|
435
|
+
|
|
436
|
+
<MazDropdown
|
|
437
|
+
position="top"
|
|
438
|
+
:items="[
|
|
439
|
+
{
|
|
440
|
+
label: 'Action',
|
|
441
|
+
onClick: () => toast.success('CLICKED'),
|
|
442
|
+
additionnalData: 'https://loremflickr.com/240/200',
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
label: 'Link (href)',
|
|
446
|
+
href: 'https://www.google.com',
|
|
447
|
+
target: '_blank',
|
|
448
|
+
additionnalData: 'https://loremflickr.com/340/300',
|
|
449
|
+
},
|
|
450
|
+
{
|
|
451
|
+
label: 'Router Link',
|
|
452
|
+
to: { name: 'index' },
|
|
453
|
+
additionnalData: 'https://loremflickr.com/440/400',
|
|
454
|
+
},
|
|
455
|
+
]"
|
|
456
|
+
>
|
|
457
|
+
<template #element="{ isOpen }">
|
|
458
|
+
<button class="maz-border maz-border-solid maz-border-divider-400 maz-p-2 hover:maz-bg-surface-400" tabindex="-1">
|
|
459
|
+
HTMLButtonElement: isOpen {{ isOpen }}
|
|
460
|
+
</button>
|
|
461
|
+
</template>
|
|
462
|
+
</MazDropdown>
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
:::
|
|
466
|
+
|
|
467
|
+
## Open programmatically
|
|
468
|
+
|
|
469
|
+
isOpen: {{ isOpen }}
|
|
470
|
+
|
|
471
|
+
<MazDropdown
|
|
472
|
+
v-model="isOpen"
|
|
473
|
+
:items="[
|
|
474
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
475
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank' },
|
|
476
|
+
{ label: 'Router Link', to: { name: 'index' } },
|
|
477
|
+
]"
|
|
478
|
+
>
|
|
479
|
+
Open
|
|
480
|
+
</MazDropdown>
|
|
481
|
+
|
|
482
|
+
<br />
|
|
483
|
+
<br />
|
|
484
|
+
|
|
485
|
+
<MazBtn @click="openDropdown">
|
|
486
|
+
Open Dropdown
|
|
487
|
+
</MazBtn>
|
|
488
|
+
|
|
489
|
+
```vue
|
|
490
|
+
<template>
|
|
491
|
+
<MazDropdown
|
|
492
|
+
v-model="isOpen"
|
|
493
|
+
:items="[
|
|
494
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
495
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank' },
|
|
496
|
+
{ label: 'Router Link', to: { name: 'index' } },
|
|
497
|
+
]"
|
|
498
|
+
>
|
|
499
|
+
Open
|
|
500
|
+
</MazDropdown>
|
|
501
|
+
|
|
502
|
+
<MazBtn @click="isOpen = !isOpen">
|
|
503
|
+
Open Dropdown
|
|
504
|
+
</MazBtn>
|
|
505
|
+
</template>
|
|
506
|
+
|
|
507
|
+
<script lang="ts" setup>
|
|
508
|
+
import { ref } from 'vue'
|
|
509
|
+
|
|
510
|
+
const isOpen = ref(false)
|
|
511
|
+
</script>
|
|
512
|
+
```
|
|
513
|
+
|
|
514
|
+
## Position
|
|
515
|
+
|
|
516
|
+
<div class="maz-flex maz-gap-3 maz-flex-wrap">
|
|
517
|
+
<MazDropdown
|
|
518
|
+
color="contrast"
|
|
519
|
+
:items="[
|
|
520
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
521
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank' },
|
|
522
|
+
{ label: 'Router Link', to: { name: 'index' } },
|
|
523
|
+
{ label: 'Long Label To Show Large Menu', to: { name: 'index' } },
|
|
524
|
+
]"
|
|
525
|
+
position="top-end"
|
|
526
|
+
>
|
|
527
|
+
top-end
|
|
528
|
+
</MazDropdown>
|
|
529
|
+
<MazDropdown
|
|
530
|
+
color="contrast"
|
|
531
|
+
:items="[
|
|
532
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
533
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank' },
|
|
534
|
+
{ label: 'Router Link', to: { name: 'index' } },
|
|
535
|
+
{ label: 'Long Label To Show Large Menu', to: { name: 'index' } },
|
|
536
|
+
]"
|
|
537
|
+
position="top-start"
|
|
538
|
+
>
|
|
539
|
+
top-start
|
|
540
|
+
</MazDropdown>
|
|
541
|
+
<MazDropdown
|
|
542
|
+
color="contrast"
|
|
543
|
+
:items="[
|
|
544
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
545
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank' },
|
|
546
|
+
{ label: 'Router Link', to: { name: 'index' } },
|
|
547
|
+
{ label: 'Long Label To Show Large Menu', to: { name: 'index' } },
|
|
548
|
+
]"
|
|
549
|
+
position="bottom-start"
|
|
550
|
+
>
|
|
551
|
+
bottom-start
|
|
552
|
+
</MazDropdown>
|
|
553
|
+
<MazDropdown
|
|
554
|
+
color="contrast"
|
|
555
|
+
:items="[
|
|
556
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
557
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank' },
|
|
558
|
+
{ label: 'Router Link', to: { name: 'index' } },
|
|
559
|
+
{ label: 'Long Label To Show Large Menu', to: { name: 'index' } },
|
|
560
|
+
]"
|
|
561
|
+
position="bottom-end"
|
|
562
|
+
>
|
|
563
|
+
bottom-end
|
|
564
|
+
</MazDropdown>
|
|
565
|
+
<MazDropdown
|
|
566
|
+
color="contrast"
|
|
567
|
+
:items="[
|
|
568
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
569
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank' },
|
|
570
|
+
{ label: 'Router Link', to: { name: 'index' } },
|
|
571
|
+
{ label: 'Long Label To Show Large Menu', to: { name: 'index' } },
|
|
572
|
+
]"
|
|
573
|
+
position="right"
|
|
574
|
+
>
|
|
575
|
+
right
|
|
576
|
+
</MazDropdown>
|
|
577
|
+
<MazDropdown
|
|
578
|
+
color="contrast"
|
|
579
|
+
:items="[
|
|
580
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
581
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank' },
|
|
582
|
+
{ label: 'Router Link', to: { name: 'index' } },
|
|
583
|
+
{ label: 'Long Label To Show Large Menu', to: { name: 'index' } },
|
|
584
|
+
]"
|
|
585
|
+
position="left"
|
|
586
|
+
>
|
|
587
|
+
left
|
|
588
|
+
</MazDropdown>
|
|
589
|
+
<MazDropdown
|
|
590
|
+
color="contrast"
|
|
591
|
+
:items="[
|
|
592
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
593
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank' },
|
|
594
|
+
{ label: 'Router Link', to: { name: 'index' } },
|
|
595
|
+
{ label: 'Long Label To Show Large Menu', to: { name: 'index' } },
|
|
596
|
+
]"
|
|
597
|
+
position="top"
|
|
598
|
+
>
|
|
599
|
+
top
|
|
600
|
+
</MazDropdown>
|
|
601
|
+
<MazDropdown
|
|
602
|
+
color="contrast"
|
|
603
|
+
:items="[
|
|
604
|
+
{ label: 'Action', onClick: () => toast.success('CLICKED') },
|
|
605
|
+
{ label: 'Link (href)', href: 'https://www.google.com', target: '_blank' },
|
|
606
|
+
{ label: 'Router Link', to: { name: 'index' } },
|
|
607
|
+
{ label: 'Long Label To Show Large Menu', to: { name: 'index' } },
|
|
608
|
+
]"
|
|
609
|
+
position="bottom"
|
|
610
|
+
>
|
|
611
|
+
bottom
|
|
612
|
+
</MazDropdown>
|
|
613
|
+
</div>
|
|
614
|
+
|
|
615
|
+
## Types
|
|
616
|
+
|
|
617
|
+
### MazDropdownMenuItem
|
|
618
|
+
|
|
619
|
+
```ts
|
|
620
|
+
type MazDropdownMenuItem = {
|
|
621
|
+
label: string
|
|
622
|
+
onClick?: () => unknown
|
|
623
|
+
target?: string
|
|
624
|
+
href?: string
|
|
625
|
+
to?: RouteLocationRaw
|
|
626
|
+
class?: string
|
|
627
|
+
} & Record<string, unknown>
|
|
628
|
+
```
|
|
629
|
+
|
|
630
|
+
<!--@include: ./../../.vitepress/generated-docs/maz-dropdown.doc.md-->
|
|
631
|
+
|
|
632
|
+
<script lang="ts" setup>
|
|
633
|
+
import { ref, onMounted } from 'vue'
|
|
634
|
+
import { useToast } from 'maz-ui/src/composables/useToast'
|
|
635
|
+
import { MazChevronUpDown } from '@maz-ui/icons'
|
|
636
|
+
|
|
637
|
+
const toast = useToast()
|
|
638
|
+
|
|
639
|
+
function openDropdown() {
|
|
640
|
+
setTimeout(() => {
|
|
641
|
+
isOpen.value = !isOpen.value
|
|
642
|
+
}, 100);
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
const menuItems = [
|
|
646
|
+
{ label: 'Menu Item 1', onClick: () => toast.success('Clicked') },
|
|
647
|
+
]
|
|
648
|
+
|
|
649
|
+
const isOpen = ref(false)
|
|
650
|
+
</script>
|