@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,411 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: dialog
|
|
3
|
+
description: Displays messages to your users in flexible and promised dialogs
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
It is a simple and easy-to-use plugin that allows you to display messages to your users in flexible and promised dialogs. The plugin will mount the `MazDialogConfirm` component to the root of your application and provide you with a handler to open the dialog, close it and return a promise.
|
|
11
|
+
|
|
12
|
+
::: tip
|
|
13
|
+
This plugin has a composable for easier use, after installing it you can use [useDialog](./../composables/use-dialog.md)
|
|
14
|
+
:::
|
|
15
|
+
|
|
16
|
+
## Installation
|
|
17
|
+
|
|
18
|
+
::: code-group
|
|
19
|
+
|
|
20
|
+
```ts [Vue]
|
|
21
|
+
import { createApp } from 'vue'
|
|
22
|
+
import { DialogPlugin, DialogOptions } from 'maz-ui/plugins/dialog'
|
|
23
|
+
|
|
24
|
+
const app = createApp(App)
|
|
25
|
+
|
|
26
|
+
const dialogOptions: DialogOptions = {
|
|
27
|
+
// ...
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
app.use(DialogPlugin, dialogOptions)
|
|
31
|
+
|
|
32
|
+
app.mount('#app')
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```ts [Nuxt]
|
|
36
|
+
export default defineNuxtConfig({
|
|
37
|
+
modules: ['@maz-ui/nuxt'],
|
|
38
|
+
mazUi: {
|
|
39
|
+
composables: {
|
|
40
|
+
useDialog: true,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
:::
|
|
47
|
+
|
|
48
|
+
## Basic usage
|
|
49
|
+
|
|
50
|
+
You can display a simple dialog with a title and a message. The dialog will have a confirm and a cancel button. The confirm button will resolve the promise and the cancel button will reject it.
|
|
51
|
+
|
|
52
|
+
<ComponentDemo>
|
|
53
|
+
<MazBtn color="contrast" @click="openDialog">
|
|
54
|
+
Show dialog
|
|
55
|
+
</MazBtn>
|
|
56
|
+
|
|
57
|
+
<template #code>
|
|
58
|
+
|
|
59
|
+
```vue
|
|
60
|
+
<script lang="ts" setup>
|
|
61
|
+
import { useDialog, useToast } from 'maz-ui/composables'
|
|
62
|
+
|
|
63
|
+
const dialog = useDialog()
|
|
64
|
+
const toast = useToast()
|
|
65
|
+
|
|
66
|
+
async function openDialog() {
|
|
67
|
+
dialog.open({
|
|
68
|
+
title: 'Dialog title',
|
|
69
|
+
message: 'Dialog message',
|
|
70
|
+
acceptText: 'Accept',
|
|
71
|
+
rejectText: 'Reject',
|
|
72
|
+
onAccept: (response) => {
|
|
73
|
+
toast.success(`Dialog accepted`, {
|
|
74
|
+
position: 'bottom',
|
|
75
|
+
})
|
|
76
|
+
},
|
|
77
|
+
onReject: (response) => {
|
|
78
|
+
toast.error(`Dialog rejected`, {
|
|
79
|
+
position: 'bottom',
|
|
80
|
+
})
|
|
81
|
+
},
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
</script>
|
|
85
|
+
|
|
86
|
+
<template>
|
|
87
|
+
<MazBtn color="contrast" @click="openDialog">
|
|
88
|
+
Show dialog
|
|
89
|
+
</MazBtn>
|
|
90
|
+
</template>
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
</template>
|
|
94
|
+
</ComponentDemo>
|
|
95
|
+
|
|
96
|
+
## Custom buttons with on click actions
|
|
97
|
+
|
|
98
|
+
The buttons property allows you to display custom buttons in the dialog and replace the default confirm and cancel buttons. You can use all props of [`MazBtn`](./../components/maz-btn.md#props) component. Each button can have a custom action to execute when clicked.
|
|
99
|
+
|
|
100
|
+
<ComponentDemo>
|
|
101
|
+
<div class="maz-flex maz-flex-wrap maz-gap-2">
|
|
102
|
+
<MazBtn color="contrast" @click="openDialogActions">
|
|
103
|
+
Show dialog with custom buttons
|
|
104
|
+
</MazBtn>
|
|
105
|
+
</div>
|
|
106
|
+
|
|
107
|
+
<template #code>
|
|
108
|
+
|
|
109
|
+
```vue
|
|
110
|
+
<script lang="ts" setup>
|
|
111
|
+
import { useDialog, useToast } from 'maz-ui/composables'
|
|
112
|
+
|
|
113
|
+
const dialog = useDialog()
|
|
114
|
+
const toast = useToast()
|
|
115
|
+
|
|
116
|
+
function openDialogActions() {
|
|
117
|
+
dialog.open({
|
|
118
|
+
title: 'Dialog title',
|
|
119
|
+
message: 'Dialog message',
|
|
120
|
+
buttons: [
|
|
121
|
+
{
|
|
122
|
+
text: 'Cancel 😱',
|
|
123
|
+
color: 'contrast',
|
|
124
|
+
outlined: true,
|
|
125
|
+
onClick: () => {
|
|
126
|
+
toast.info('Cancel button clicked', {
|
|
127
|
+
position: 'bottom',
|
|
128
|
+
})
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
text: 'Confirm 🚀',
|
|
133
|
+
color: 'contrast',
|
|
134
|
+
onClick: () => {
|
|
135
|
+
toast.success('Confirm button clicked', {
|
|
136
|
+
position: 'bottom',
|
|
137
|
+
})
|
|
138
|
+
},
|
|
139
|
+
}
|
|
140
|
+
],
|
|
141
|
+
})
|
|
142
|
+
}
|
|
143
|
+
</script>
|
|
144
|
+
|
|
145
|
+
<template>
|
|
146
|
+
<MazBtn color="contrast" @click="openDialogActions">
|
|
147
|
+
Show dialog with custom buttons
|
|
148
|
+
</MazBtn>
|
|
149
|
+
</template>
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
</template>
|
|
153
|
+
</ComponentDemo>
|
|
154
|
+
|
|
155
|
+
## Custom response
|
|
156
|
+
|
|
157
|
+
The buttons property allows you to display custom buttons in the dialog and replace the default confirm and cancel buttons. Each button can have a custom response to return when clicked. The type property allows you to define the type of the button. The response property allows you to define the response of the promise when the button is clicked.
|
|
158
|
+
|
|
159
|
+
<ComponentDemo>
|
|
160
|
+
<div class="maz-flex maz-flex-wrap maz-gap-2">
|
|
161
|
+
<MazBtn color="contrast" @click="openDialogResponse">
|
|
162
|
+
Show dialog with custom response
|
|
163
|
+
</MazBtn>
|
|
164
|
+
</div>
|
|
165
|
+
|
|
166
|
+
<template #code>
|
|
167
|
+
|
|
168
|
+
```vue
|
|
169
|
+
<script lang="ts" setup>
|
|
170
|
+
import { useDialog, useToast } from 'maz-ui/composables'
|
|
171
|
+
|
|
172
|
+
const dialog = useDialog()
|
|
173
|
+
const toast = useToast()
|
|
174
|
+
|
|
175
|
+
async function openDialogResponse() {
|
|
176
|
+
const { promise } = dialog.open({
|
|
177
|
+
title: 'Dialog title',
|
|
178
|
+
message: 'Dialog message',
|
|
179
|
+
buttons: [
|
|
180
|
+
{
|
|
181
|
+
text: 'Reject',
|
|
182
|
+
type: 'reject',
|
|
183
|
+
response: 'Rejected Response',
|
|
184
|
+
color: 'destructive',
|
|
185
|
+
},
|
|
186
|
+
{
|
|
187
|
+
text: 'Accept',
|
|
188
|
+
type: 'resolve',
|
|
189
|
+
response: 'Accepted Response',
|
|
190
|
+
color: 'secondary',
|
|
191
|
+
}
|
|
192
|
+
],
|
|
193
|
+
onAccept: (response) => {
|
|
194
|
+
toast.success(`Dialog accepted with: ${response}`, {
|
|
195
|
+
position: 'bottom',
|
|
196
|
+
})
|
|
197
|
+
},
|
|
198
|
+
onReject: (response) => {
|
|
199
|
+
toast.error(`Dialog rejected with: ${response}`, {
|
|
200
|
+
position: 'bottom',
|
|
201
|
+
})
|
|
202
|
+
},
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
</script>
|
|
206
|
+
|
|
207
|
+
<template>
|
|
208
|
+
<MazBtn color="contrast" @click="openDialogResponse">
|
|
209
|
+
Show dialog with custom response
|
|
210
|
+
</MazBtn>
|
|
211
|
+
</template>
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
</template>
|
|
215
|
+
</ComponentDemo>
|
|
216
|
+
|
|
217
|
+
## Close dialog
|
|
218
|
+
|
|
219
|
+
You can close the dialog programmatically by calling the close method returned by the open method.
|
|
220
|
+
|
|
221
|
+
<ComponentDemo>
|
|
222
|
+
<div class="maz-flex maz-flex-wrap maz-gap-2">
|
|
223
|
+
<MazBtn color="contrast" @click="openAndCloseDialog">
|
|
224
|
+
Open and close dialog
|
|
225
|
+
</MazBtn>
|
|
226
|
+
</div>
|
|
227
|
+
|
|
228
|
+
<template #code>
|
|
229
|
+
|
|
230
|
+
```vue
|
|
231
|
+
<script lang="ts" setup>
|
|
232
|
+
import { useDialog, useToast } from 'maz-ui/composables'
|
|
233
|
+
|
|
234
|
+
const dialog = useDialog()
|
|
235
|
+
|
|
236
|
+
function openAndCloseDialog() {
|
|
237
|
+
const { close } = dialog.open({
|
|
238
|
+
title: 'Dialog title',
|
|
239
|
+
message: 'Wait 5 seconds to close the dialog',
|
|
240
|
+
buttons: [],
|
|
241
|
+
persistent: true,
|
|
242
|
+
})
|
|
243
|
+
|
|
244
|
+
setTimeout(() => {
|
|
245
|
+
close()
|
|
246
|
+
}, 5000)
|
|
247
|
+
}
|
|
248
|
+
</script>
|
|
249
|
+
|
|
250
|
+
<template>
|
|
251
|
+
<MazBtn color="contrast" @click="openAndCloseDialog">
|
|
252
|
+
Open and close dialog
|
|
253
|
+
</MazBtn>
|
|
254
|
+
</template>
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
</template>
|
|
258
|
+
</ComponentDemo>
|
|
259
|
+
|
|
260
|
+
## Options
|
|
261
|
+
|
|
262
|
+
### Usage
|
|
263
|
+
|
|
264
|
+
```ts
|
|
265
|
+
import { useDialog } from 'maz-ui/composables/useDialog'
|
|
266
|
+
|
|
267
|
+
const dialog = useDialog()
|
|
268
|
+
|
|
269
|
+
const options: DialogOptions = {
|
|
270
|
+
title: 'Dialog title',
|
|
271
|
+
message: 'Dialog message',
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
dialog.open(options)
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Type
|
|
278
|
+
|
|
279
|
+
```ts
|
|
280
|
+
import type { MazBtnProps } from 'maz-ui/components/MazBtn'
|
|
281
|
+
|
|
282
|
+
type DialogOptions = Partial<Omit<MazDialogConfirmProps, 'modelValue'>> & {
|
|
283
|
+
/**
|
|
284
|
+
* Dialog identifier - identifier to manage multiple dialogs
|
|
285
|
+
* @default 'main-dialog'
|
|
286
|
+
*/
|
|
287
|
+
identifier?: string
|
|
288
|
+
/**
|
|
289
|
+
* Custom buttons to display in the dialog and replace the default confirm and cancel buttons
|
|
290
|
+
* @default [{ text: 'Confirm', color: 'success', type: 'accept' }, { text: 'Cancel', color: 'destructive', type: 'reject' }]
|
|
291
|
+
*/
|
|
292
|
+
buttons?: MazDialogConfirmButton[]
|
|
293
|
+
/**
|
|
294
|
+
* Function to execute when the dialog is accepted (when the user click on the confirm button)
|
|
295
|
+
* Only available if the button type is 'accept'
|
|
296
|
+
*/
|
|
297
|
+
onAccept?: () => unknown
|
|
298
|
+
/**
|
|
299
|
+
* Function to execute when the dialog is rejected (when the user click on the cancel button)
|
|
300
|
+
* Only available if the button type is 'reject'
|
|
301
|
+
*/
|
|
302
|
+
onReject?: () => unknown
|
|
303
|
+
/**
|
|
304
|
+
* Function to execute when the dialog is closed
|
|
305
|
+
*/
|
|
306
|
+
onClose?: () => unknown
|
|
307
|
+
}
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
<script lang="ts" setup>
|
|
311
|
+
import { useDialog, useToast } from 'maz-ui/src/composables/index'
|
|
312
|
+
|
|
313
|
+
const dialog = useDialog()
|
|
314
|
+
const toast = useToast()
|
|
315
|
+
|
|
316
|
+
async function openDialog() {
|
|
317
|
+
dialog.open({
|
|
318
|
+
title: 'Dialog title',
|
|
319
|
+
message: 'Dialog message',
|
|
320
|
+
acceptText: 'Accept',
|
|
321
|
+
rejectText: 'Reject',
|
|
322
|
+
onAccept: (response) => {
|
|
323
|
+
toast.success(`Dialog accepted`, {
|
|
324
|
+
position: 'bottom',
|
|
325
|
+
})
|
|
326
|
+
},
|
|
327
|
+
onReject: (response) => {
|
|
328
|
+
toast.error(`Dialog rejected`, {
|
|
329
|
+
position: 'bottom',
|
|
330
|
+
})
|
|
331
|
+
},
|
|
332
|
+
})
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
async function openDialogActions() {
|
|
336
|
+
dialog.open({
|
|
337
|
+
title: 'Dialog title',
|
|
338
|
+
message: 'Dialog message',
|
|
339
|
+
buttons: [
|
|
340
|
+
{
|
|
341
|
+
text: 'Cancel 😱',
|
|
342
|
+
color: 'destructive',
|
|
343
|
+
outlined: true,
|
|
344
|
+
onClick: () => {
|
|
345
|
+
toast.error('Cancel button clicked', {
|
|
346
|
+
position: 'bottom',
|
|
347
|
+
})
|
|
348
|
+
},
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
text: 'Confirm 🚀',
|
|
352
|
+
color: 'primary',
|
|
353
|
+
onClick: () => {
|
|
354
|
+
toast.success('Confirm button clicked', {
|
|
355
|
+
position: 'bottom',
|
|
356
|
+
})
|
|
357
|
+
},
|
|
358
|
+
}
|
|
359
|
+
],
|
|
360
|
+
onClose: () => {
|
|
361
|
+
toast.info('Dialog closed', {
|
|
362
|
+
position: 'bottom',
|
|
363
|
+
})
|
|
364
|
+
},
|
|
365
|
+
})
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
async function openDialogResponse() {
|
|
369
|
+
const { promise } = dialog.open({
|
|
370
|
+
title: 'Dialog title',
|
|
371
|
+
message: 'Dialog message',
|
|
372
|
+
buttons: [
|
|
373
|
+
{
|
|
374
|
+
text: 'Reject',
|
|
375
|
+
type: 'reject',
|
|
376
|
+
response: 'Rejected Response',
|
|
377
|
+
color: 'destructive',
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
text: 'Accept',
|
|
381
|
+
type: 'resolve',
|
|
382
|
+
response: 'Accepted Response',
|
|
383
|
+
color: 'secondary',
|
|
384
|
+
}
|
|
385
|
+
],
|
|
386
|
+
onAccept: (response) => {
|
|
387
|
+
toast.success(`Dialog accepted with: ${response}`, {
|
|
388
|
+
position: 'bottom',
|
|
389
|
+
})
|
|
390
|
+
},
|
|
391
|
+
onReject: (response) => {
|
|
392
|
+
toast.error(`Dialog rejected with: ${response}`, {
|
|
393
|
+
position: 'bottom',
|
|
394
|
+
})
|
|
395
|
+
},
|
|
396
|
+
})
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
async function openAndCloseDialog() {
|
|
400
|
+
const { close } = dialog.open({
|
|
401
|
+
title: 'Dialog title',
|
|
402
|
+
message: 'Wait 5 seconds to close the dialog',
|
|
403
|
+
buttons: [],
|
|
404
|
+
persistent: true,
|
|
405
|
+
})
|
|
406
|
+
|
|
407
|
+
setTimeout(() => {
|
|
408
|
+
close()
|
|
409
|
+
}, 5000);
|
|
410
|
+
}
|
|
411
|
+
</script>
|