maz-ui 5.0.0 → 5.1.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/dist/assets/{MazDropzone.DJ8au25t.css → MazDropzone.BW2grpTi.css} +1 -1
  2. package/dist/chunks/{MazDrawer.DANxKYxJ.js → MazDrawer.CC8zomfx.js} +2 -2
  3. package/dist/chunks/{MazDropzone.POH3pmfi.js → MazDropzone.Dez5j0WP.js} +2 -2
  4. package/dist/components/MazDrawer.js +1 -1
  5. package/dist/components/MazDropzone.js +1 -1
  6. package/dist/components/MazDropzone.vue.d.ts +2 -2
  7. package/dist/components/MazInputPrice.vue.d.ts +1 -1
  8. package/dist/components/index.js +2 -2
  9. package/docs/README.md +207 -0
  10. package/docs/agents/agents-md.md +52 -0
  11. package/docs/agents/claude-rule.md +52 -0
  12. package/docs/components/maz-accordion.md +76 -0
  13. package/docs/components/maz-alert.md +241 -0
  14. package/docs/components/maz-animated-counter.md +87 -0
  15. package/docs/components/maz-animated-element.md +46 -0
  16. package/docs/components/maz-animated-text.md +53 -0
  17. package/docs/components/maz-avatar.md +193 -0
  18. package/docs/components/maz-backdrop.md +178 -0
  19. package/docs/components/maz-badge.md +167 -0
  20. package/docs/components/maz-bottom-sheet.md +257 -0
  21. package/docs/components/maz-btn-group.md +316 -0
  22. package/docs/components/maz-btn.md +423 -0
  23. package/docs/components/maz-card-spotlight.md +84 -0
  24. package/docs/components/maz-card.md +321 -0
  25. package/docs/components/maz-carousel.md +153 -0
  26. package/docs/components/maz-chart.md +206 -0
  27. package/docs/components/maz-checkbox.md +138 -0
  28. package/docs/components/maz-checklist.md +251 -0
  29. package/docs/components/maz-circular-progress-bar.md +109 -0
  30. package/docs/components/maz-code-highlight.md +155 -0
  31. package/docs/components/maz-container.md +241 -0
  32. package/docs/components/maz-date-picker.md +791 -0
  33. package/docs/components/maz-dialog-confirm.md +215 -0
  34. package/docs/components/maz-dialog.md +143 -0
  35. package/docs/components/maz-drawer.md +106 -0
  36. package/docs/components/maz-dropdown.md +419 -0
  37. package/docs/components/maz-dropzone.md +387 -0
  38. package/docs/components/maz-expand-animation.md +82 -0
  39. package/docs/components/maz-fullscreen-loader.md +58 -0
  40. package/docs/components/maz-gallery.md +79 -0
  41. package/docs/components/maz-icon.md +203 -0
  42. package/docs/components/maz-input-code.md +73 -0
  43. package/docs/components/maz-input-number.md +79 -0
  44. package/docs/components/maz-input-phone-number.md +536 -0
  45. package/docs/components/maz-input-price.md +68 -0
  46. package/docs/components/maz-input-tags.md +112 -0
  47. package/docs/components/maz-input.md +334 -0
  48. package/docs/components/maz-lazy-img.md +113 -0
  49. package/docs/components/maz-link.md +146 -0
  50. package/docs/components/maz-loading-bar.md +38 -0
  51. package/docs/components/maz-markdown-editor.md +320 -0
  52. package/docs/components/maz-pagination.md +82 -0
  53. package/docs/components/maz-popover.md +794 -0
  54. package/docs/components/maz-pull-to-refresh.md +222 -0
  55. package/docs/components/maz-radio-buttons.md +313 -0
  56. package/docs/components/maz-radio.md +119 -0
  57. package/docs/components/maz-read-more.md +209 -0
  58. package/docs/components/maz-reading-progress-bar.md +96 -0
  59. package/docs/components/maz-select-country.md +513 -0
  60. package/docs/components/maz-select.md +318 -0
  61. package/docs/components/maz-sidebar-content.md +25 -0
  62. package/docs/components/maz-sidebar-footer.md +25 -0
  63. package/docs/components/maz-sidebar-group.md +27 -0
  64. package/docs/components/maz-sidebar-header.md +25 -0
  65. package/docs/components/maz-sidebar-menu-button.md +41 -0
  66. package/docs/components/maz-sidebar-menu-item.md +25 -0
  67. package/docs/components/maz-sidebar-menu-sub.md +32 -0
  68. package/docs/components/maz-sidebar-menu.md +25 -0
  69. package/docs/components/maz-sidebar-separator.md +21 -0
  70. package/docs/components/maz-sidebar-trigger.md +25 -0
  71. package/docs/components/maz-sidebar.md +507 -0
  72. package/docs/components/maz-skeleton.md +226 -0
  73. package/docs/components/maz-slider.md +165 -0
  74. package/docs/components/maz-spinner.md +84 -0
  75. package/docs/components/maz-stepper.md +301 -0
  76. package/docs/components/maz-switch.md +86 -0
  77. package/docs/components/maz-table-cell.md +27 -0
  78. package/docs/components/maz-table-row.md +28 -0
  79. package/docs/components/maz-table-title.md +27 -0
  80. package/docs/components/maz-table-virtualizer.md +31 -0
  81. package/docs/components/maz-table.md +426 -0
  82. package/docs/components/maz-tabs-bar.md +43 -0
  83. package/docs/components/maz-tabs-content-item.md +27 -0
  84. package/docs/components/maz-tabs-content.md +27 -0
  85. package/docs/components/maz-tabs.md +308 -0
  86. package/docs/components/maz-textarea.md +255 -0
  87. package/docs/components/maz-ticker.md +427 -0
  88. package/docs/components/maz-timeline.md +304 -0
  89. package/docs/components/maz-ui-provider.md +26 -0
  90. package/docs/components/maz-window-mockup.md +182 -0
  91. package/docs/composables/use-aos.md +41 -0
  92. package/docs/composables/use-breakpoints.md +42 -0
  93. package/docs/composables/use-dialog.md +58 -0
  94. package/docs/composables/use-display-names.md +130 -0
  95. package/docs/composables/use-drag.md +185 -0
  96. package/docs/composables/use-form-validator.md +1123 -0
  97. package/docs/composables/use-idle-timeout.md +172 -0
  98. package/docs/composables/use-pull-to-refresh.md +86 -0
  99. package/docs/composables/use-reading-time.md +132 -0
  100. package/docs/composables/use-string-matching.md +41 -0
  101. package/docs/composables/use-swipe.md +171 -0
  102. package/docs/composables/use-timer.md +104 -0
  103. package/docs/composables/use-toast.md +50 -0
  104. package/docs/composables/use-user-visibility.md +127 -0
  105. package/docs/composables/use-wait.md +50 -0
  106. package/docs/composables/use-window-size.md +25 -0
  107. package/docs/directives/click-outside.md +182 -0
  108. package/docs/directives/fullscreen-img.md +83 -0
  109. package/docs/directives/lazy-img.md +182 -0
  110. package/docs/directives/tooltip.md +298 -0
  111. package/docs/directives/zoom-img.md +100 -0
  112. package/docs/ecosystem/eslint-config.md +289 -0
  113. package/docs/ecosystem/icons/icon-set.md +25 -0
  114. package/docs/ecosystem/icons/index.md +584 -0
  115. package/docs/ecosystem/mcp.md +165 -0
  116. package/docs/ecosystem/node/exec-promise.md +93 -0
  117. package/docs/ecosystem/node/index.md +53 -0
  118. package/docs/ecosystem/node/logger.md +152 -0
  119. package/docs/ecosystem/node/print-banner.md +101 -0
  120. package/docs/ecosystem/node/setup-agents.md +102 -0
  121. package/docs/ecosystem/nuxt.md +551 -0
  122. package/docs/ecosystem/stylelint-config.md +310 -0
  123. package/docs/ecosystem/themes.md +966 -0
  124. package/docs/ecosystem/translations.md +1173 -0
  125. package/docs/ecosystem/utils/camel-case.md +37 -0
  126. package/docs/ecosystem/utils/capitalize.md +37 -0
  127. package/docs/ecosystem/utils/check-availability.md +85 -0
  128. package/docs/ecosystem/utils/cookie.md +86 -0
  129. package/docs/ecosystem/utils/country-code-to-unicode-flag.md +128 -0
  130. package/docs/ecosystem/utils/currency.md +53 -0
  131. package/docs/ecosystem/utils/date.md +53 -0
  132. package/docs/ecosystem/utils/debounce-callback.md +44 -0
  133. package/docs/ecosystem/utils/debounce-id.md +75 -0
  134. package/docs/ecosystem/utils/debounce.md +71 -0
  135. package/docs/ecosystem/utils/fetch-locale-ip.md +39 -0
  136. package/docs/ecosystem/utils/format-json.md +39 -0
  137. package/docs/ecosystem/utils/format-phone-number.md +43 -0
  138. package/docs/ecosystem/utils/get-browser-locale.md +35 -0
  139. package/docs/ecosystem/utils/get-country-flag-url.md +67 -0
  140. package/docs/ecosystem/utils/get-error-message.md +45 -0
  141. package/docs/ecosystem/utils/idle-timeout.md +96 -0
  142. package/docs/ecosystem/utils/index.md +57 -0
  143. package/docs/ecosystem/utils/is-client.md +38 -0
  144. package/docs/ecosystem/utils/is-equal.md +44 -0
  145. package/docs/ecosystem/utils/is-ios.md +43 -0
  146. package/docs/ecosystem/utils/is-server.md +37 -0
  147. package/docs/ecosystem/utils/is-standalone-mode.md +49 -0
  148. package/docs/ecosystem/utils/kebab-case.md +42 -0
  149. package/docs/ecosystem/utils/normalize-string.md +83 -0
  150. package/docs/ecosystem/utils/number.md +51 -0
  151. package/docs/ecosystem/utils/pascal-case.md +41 -0
  152. package/docs/ecosystem/utils/prevent-ios-input-zoom.md +72 -0
  153. package/docs/ecosystem/utils/script-loader.md +85 -0
  154. package/docs/ecosystem/utils/sleep.md +65 -0
  155. package/docs/ecosystem/utils/snake-case.md +42 -0
  156. package/docs/ecosystem/utils/swipe-handler.md +97 -0
  157. package/docs/ecosystem/utils/textarea-autogrow.md +47 -0
  158. package/docs/ecosystem/utils/throttle-id.md +54 -0
  159. package/docs/ecosystem/utils/throttle.md +63 -0
  160. package/docs/ecosystem/utils/truthy-filter.md +37 -0
  161. package/docs/ecosystem/utils/types/deep-key-of.md +54 -0
  162. package/docs/ecosystem/utils/types/deep-partial.md +48 -0
  163. package/docs/ecosystem/utils/types/deep-required.md +45 -0
  164. package/docs/ecosystem/utils/types/flatten-object-keys.md +50 -0
  165. package/docs/ecosystem/utils/types/generic-instance-type.md +48 -0
  166. package/docs/ecosystem/utils/types/infer-maybe-ref.md +41 -0
  167. package/docs/ecosystem/utils/upper-first.md +38 -0
  168. package/docs/ecosystem/utils/user-visibility.md +75 -0
  169. package/docs/guide/ai-agents.md +237 -0
  170. package/docs/guide/browser-support.md +88 -0
  171. package/docs/guide/getting-started.md +191 -0
  172. package/docs/guide/global-defaults.md +103 -0
  173. package/docs/guide/maz-ui-provider.md +231 -0
  174. package/docs/guide/migration-v5.md +871 -0
  175. package/docs/guide/resolvers.md +650 -0
  176. package/docs/guide/tailwind.md +483 -0
  177. package/docs/guide/vue.md +286 -0
  178. package/docs/manifest.json +1 -0
  179. package/docs/plugins/aos.md +312 -0
  180. package/docs/plugins/dialog.md +269 -0
  181. package/docs/plugins/toast.md +221 -0
  182. package/docs/plugins/wait.md +78 -0
  183. package/docs/reference/icons.md +46 -0
  184. package/docs/reference/tailwind-tokens.md +191 -0
  185. package/docs/rules.md +57 -0
  186. package/package.json +31 -4
@@ -0,0 +1,312 @@
1
+ ---
2
+ title: "aos (animation on scroll)"
3
+ description: "Plugin to animate elements on your page as you scroll."
4
+ package: "maz-ui"
5
+ url: "https://maz-ui.com/plugins/aos"
6
+ ---
7
+
8
+ # aos (animation on scroll)
9
+
10
+ > Plugin to animate elements on your page as you scroll.
11
+
12
+ - Package: `maz-ui`
13
+ - Import: `import { AosPlugin } from 'maz-ui/plugins/aos'`
14
+ - Web: https://maz-ui.com/plugins/aos
15
+
16
+ **Tip:**
17
+
18
+ This plugin has a composable for easier use, after installing it, you can use [useAos](../composables/use-aos.md)
19
+
20
+ ## Installation
21
+
22
+ All options are listed in the Global Options section.
23
+
24
+ ```ts [Vue]
25
+ import { createApp } from 'vue'
26
+ import router from './router'
27
+ import { AosPlugin, AosOptions } from 'maz-ui/plugins/aos'
28
+
29
+ // ⚠️ import necessary CSS file ⚠️
30
+ import 'maz-ui/aos.css'
31
+
32
+ const app = createApp(App)
33
+
34
+ app.use(router)
35
+
36
+ const aosOptions: AosOptions = {
37
+ animation: {
38
+ duration: 1000,
39
+ once: false,
40
+ delay: 0,
41
+ },
42
+ delay: 100,
43
+ router,
44
+ }
45
+
46
+ app.use(AosPlugin, aosOptions)
47
+
48
+ app.mount('#app')
49
+ ```
50
+
51
+ ```ts [Nuxt]
52
+ export default defineNuxtConfig({
53
+ modules: ['@maz-ui/nuxt'],
54
+ mazUi: {
55
+ composables: {
56
+ useAos: {
57
+ animation: {
58
+ duration: 1000,
59
+ once: false,
60
+ delay: 0,
61
+ },
62
+ delay: 100,
63
+ },
64
+ },
65
+ },
66
+ })
67
+ ```
68
+
69
+ ## Basic usage
70
+
71
+ ```html{1,13}
72
+ <MazCard overflow-hidden data-maz-aos="scale-out" id="parentCard">
73
+ <div class="flex" style="display: flex; align-items: start; gap: 1rem; margin-bottom: 1rem;">
74
+ <MazAvatar
75
+ data-maz-aos-delay="300"
76
+ data-maz-aos="scale-in"
77
+ size="2rem"
78
+ src="https://api.dicebear.com/7.x/big-smile/svg?backgroundColor=1d90ff&scale=80&seed=maz-ui"
79
+ />
80
+ <div>
81
+ <h1
82
+ data-maz-aos="fade-down"
83
+ data-maz-aos-delay="600"
84
+ data-maz-aos-anchor="#parentCard"
85
+ style="margin: 0;"
86
+ >
87
+ Maz-UI
88
+ </h1>
89
+ <p
90
+ data-maz-aos="zoom-in-left"
91
+ data-maz-aos-delay="900"
92
+ style="margin: 0"
93
+ class="text-muted"
94
+ >
95
+ Library
96
+ </p>
97
+ </div>
98
+ </div>
99
+ <p
100
+ data-maz-aos="flip-up"
101
+ data-maz-aos-delay="1200"
102
+ data-maz-aos-duration="1000"
103
+ style="margin: 0"
104
+ >
105
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
106
+ </p>
107
+ </MazCard>
108
+ ```
109
+
110
+ ## Atributes
111
+
112
+ | Attribute | Description | Example value | Default value |
113
+ | --------------------- | --------------------------------------------------------------------------------------------------------------------------- | ---------------------------- | ------------- |
114
+ | data-maz-aos | animation name | fade-up | - |
115
+ | data-maz-aos-duration | \*Duration of animation (ms) | 50 to 3000 (with step of 50) | 300 |
116
+ | data-maz-aos-easing | Choose timing function to ease elements in different ways | ease-in-sine | linear |
117
+ | data-maz-aos-delay | Delay animation (ms) | 50 to 3000 (with step of 50) | 0 |
118
+ | data-maz-aos-anchor | Anchor element, whose offset will be counted to trigger animation instead of actual elements offset. ONLY with ID attribute | #selector | undefined |
119
+ | data-maz-aos-once | Choose wheter animation should fire once, or every time you scroll up/down to element | true | false |
120
+
121
+ ## Animations
122
+
123
+ ### Fade
124
+
125
+ - fade-up
126
+ - fade-down
127
+ - fade-right
128
+ - fade-left
129
+ - fade-up-right
130
+ - fade-up-left
131
+ - fade-down-right
132
+ - fade-down-left
133
+
134
+ ### Zoom
135
+
136
+ - zoom-in
137
+ - zoom-in-up
138
+ - zoom-in-down
139
+ - zoom-in-right
140
+ - zoom-in-left
141
+ - zoom-out
142
+ - zoom-out-up
143
+ - zoom-out-down
144
+ - zoom-out-right
145
+ - zoom-out-left
146
+
147
+ ### Slide
148
+
149
+ - slide-up
150
+ - slide-down
151
+ - slide-right
152
+ - slide-left
153
+
154
+ ### Flip
155
+
156
+ - flip-left
157
+ - flip-right
158
+ - flip-up
159
+ - flip-down
160
+
161
+ ### Rotate
162
+
163
+ - rotate-left
164
+ - rotate-right
165
+
166
+ ### Scale
167
+
168
+ - scale-in
169
+ - scale-out
170
+
171
+ ## Easing
172
+
173
+ You can choose one of these timing function to animate elements nicely:
174
+
175
+ - linear
176
+ - ease
177
+ - ease-in
178
+ - ease-out
179
+ - ease-in-out
180
+ - ease-in-back
181
+ - ease-out-back
182
+ - ease-in-out-back
183
+ - ease-in-sine
184
+ - ease-out-sine
185
+ - ease-in-out-sine
186
+ - ease-in-quad
187
+ - ease-out-quad
188
+ - ease-in-out-quad
189
+ - ease-in-cubic
190
+ - ease-out-cubic
191
+ - ease-in-out-cubic
192
+ - ease-in-quart
193
+ - ease-out-quart
194
+ - ease-in-out-quart
195
+
196
+ ## Nuxt
197
+
198
+ **Tip:**
199
+
200
+ For **NuxtJS v3** and higher, use the dedicated Nuxt module to take advantage of auto-imports of components, plugins, composables and css files: [Nuxt Module Documentation](../ecosystem/nuxt.md)
201
+
202
+ Should be executed on client side
203
+
204
+ `nuxt.config.(ts|js)`
205
+
206
+ ```ts
207
+ export default defineNuxtConfig({
208
+ css: ['maz-ui/aos.css'],
209
+ })
210
+ ```
211
+
212
+ `plugins/maz-aos.client.ts`
213
+
214
+ ```ts
215
+ import { AosOptions, installAos } from 'maz-ui/plugins'
216
+
217
+ export default ({ vueApp, $router: router }) => {
218
+ const options: AosOptions = {
219
+ router,
220
+ animation: {
221
+ duration: 1000,
222
+ delay: 0,
223
+ once: false,
224
+ },
225
+ }
226
+
227
+ vueApp.use(installAos, options)
228
+ }
229
+ ```
230
+
231
+ ## Run animations programatically
232
+
233
+ You can run animations programatically with the useAos composable.
234
+ This is useful if you want to run animations after the page is loaded or if no router is provided.
235
+
236
+ ```vue
237
+ <script lang="ts" setup>
238
+ import { useAos } from 'maz-ui/composables'
239
+ import { onMounted } from 'vue'
240
+
241
+ const aos = useAos()
242
+
243
+ onMounted(() => {
244
+ // should be run on client side
245
+ aos.runAnimations()
246
+ })
247
+ </script>
248
+
249
+ <template>
250
+ <div id="parentCard" data-maz-aos="scale-out">
251
+ <p
252
+ data-maz-aos-delay="300"
253
+ data-maz-aos="scale-in"
254
+ size="2rem"
255
+ src="https://api.dicebear.com/7.x/big-smile/svg?backgroundColor=1d90ff&scale=80&seed=maz-ui"
256
+ >
257
+ In the heart of Hollywood's narrow alleyways, there existed an actor like no other - a charismatic feline named Whiskers. With his sleek black fur and piercing eyes, he stole the spotlight in every appearance. Whiskers, known for his versatility and natural talent, seamlessly slipped into dramatic, comedic, or action-packed roles.
258
+ </p>
259
+ </div>
260
+ </template>
261
+ ```
262
+
263
+ ## Global Options
264
+
265
+ ```ts
266
+ export interface AosOptions {
267
+ /**
268
+ * provide your router to launch animation after each navigation
269
+ * @default undefined
270
+ */
271
+ router?: Router
272
+ /**
273
+ * duration in ms before start animations (useful when the HTML rendering is slow)
274
+ * @default 100
275
+ */
276
+ delay?: number
277
+ observer?: {
278
+ /**
279
+ * Scope animation to specific parent HTMLElement
280
+ * @default undefined
281
+ */
282
+ root?: Element | Document | null
283
+ /**
284
+ * margin around elements to trigger the animations - Ex: "100px"
285
+ * @default undefined
286
+ */
287
+ rootMargin?: string
288
+ /**
289
+ * Ratio concerponding to the element size
290
+ * @default 0.2
291
+ */
292
+ threshold?: number | number[]
293
+ }
294
+ animation?: {
295
+ /**
296
+ * if `false` the animation is played each times when the element is visible
297
+ * @default true
298
+ */
299
+ once?: boolean
300
+ /**
301
+ * Default animation duration in ms
302
+ * @default 300
303
+ */
304
+ duration?: number
305
+ /**
306
+ * Default animation delay in ms
307
+ * @default 0
308
+ */
309
+ delay?: number
310
+ }
311
+ }
312
+ ```
@@ -0,0 +1,269 @@
1
+ ---
2
+ title: "dialog"
3
+ description: "Displays messages to your users in flexible and promised dialogs"
4
+ package: "maz-ui"
5
+ url: "https://maz-ui.com/plugins/dialog"
6
+ ---
7
+
8
+ # dialog
9
+
10
+ > Displays messages to your users in flexible and promised dialogs
11
+
12
+ - Package: `maz-ui`
13
+ - Import: `import { DialogPlugin } from 'maz-ui/plugins/dialog'`
14
+ - Web: https://maz-ui.com/plugins/dialog
15
+
16
+ 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.
17
+
18
+ **Tip:**
19
+
20
+ This plugin has a composable for easier use, after installing it you can use [useDialog](../composables/use-dialog.md)
21
+
22
+ ## Installation
23
+
24
+ ```ts [Vue]
25
+ import { createApp } from 'vue'
26
+ import { DialogPlugin, DialogOptions } from 'maz-ui/plugins/dialog'
27
+
28
+ const app = createApp(App)
29
+
30
+ const dialogOptions: DialogOptions = {
31
+ // ...
32
+ }
33
+
34
+ app.use(DialogPlugin, dialogOptions)
35
+
36
+ app.mount('#app')
37
+ ```
38
+
39
+ ```ts [Nuxt]
40
+ export default defineNuxtConfig({
41
+ modules: ['@maz-ui/nuxt'],
42
+ mazUi: {
43
+ composables: {
44
+ useDialog: true,
45
+ },
46
+ },
47
+ })
48
+ ```
49
+
50
+ ## Basic usage
51
+
52
+ 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.
53
+
54
+ ```vue
55
+ <script lang="ts" setup>
56
+ import { useDialog, useToast } from 'maz-ui/composables'
57
+
58
+ const dialog = useDialog()
59
+ const toast = useToast()
60
+
61
+ async function openDialog() {
62
+ dialog.open({
63
+ title: 'Dialog title',
64
+ message: 'Dialog message',
65
+ acceptText: 'Accept',
66
+ rejectText: 'Reject',
67
+ onAccept: (response) => {
68
+ toast.success(`Dialog accepted`, {
69
+ position: 'bottom',
70
+ })
71
+ },
72
+ onReject: (response) => {
73
+ toast.error(`Dialog rejected`, {
74
+ position: 'bottom',
75
+ })
76
+ },
77
+ })
78
+ }
79
+ </script>
80
+
81
+ <template>
82
+ <MazBtn color="contrast" @click="openDialog">
83
+ Show dialog
84
+ </MazBtn>
85
+ </template>
86
+ ```
87
+
88
+ ## Custom buttons with on click actions
89
+
90
+ 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.
91
+
92
+ ```vue
93
+ <script lang="ts" setup>
94
+ import { useDialog, useToast } from 'maz-ui/composables'
95
+
96
+ const dialog = useDialog()
97
+ const toast = useToast()
98
+
99
+ function openDialogActions() {
100
+ dialog.open({
101
+ title: 'Dialog title',
102
+ message: 'Dialog message',
103
+ buttons: [
104
+ {
105
+ text: 'Cancel 😱',
106
+ color: 'contrast',
107
+ outlined: true,
108
+ onClick: () => {
109
+ toast.info('Cancel button clicked', {
110
+ position: 'bottom',
111
+ })
112
+ },
113
+ },
114
+ {
115
+ text: 'Confirm 🚀',
116
+ color: 'contrast',
117
+ onClick: () => {
118
+ toast.success('Confirm button clicked', {
119
+ position: 'bottom',
120
+ })
121
+ },
122
+ }
123
+ ],
124
+ onClose: () => {
125
+ toast.info('Dialog closed', {
126
+ position: 'bottom',
127
+ })
128
+ },
129
+ })
130
+ }
131
+ </script>
132
+
133
+ <template>
134
+ <MazBtn color="contrast" @click="openDialogActions">
135
+ Show dialog with custom buttons
136
+ </MazBtn>
137
+ </template>
138
+ ```
139
+
140
+ ## Custom response
141
+
142
+ 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.
143
+
144
+ ```vue
145
+ <script lang="ts" setup>
146
+ import { useDialog, useToast } from 'maz-ui/composables'
147
+
148
+ const dialog = useDialog()
149
+ const toast = useToast()
150
+
151
+ async function openDialogResponse() {
152
+ const { promise } = dialog.open({
153
+ title: 'Dialog title',
154
+ message: 'Dialog message',
155
+ buttons: [
156
+ {
157
+ text: 'Reject',
158
+ type: 'reject',
159
+ response: 'Rejected Response',
160
+ color: 'destructive',
161
+ },
162
+ {
163
+ text: 'Accept',
164
+ type: 'resolve',
165
+ response: 'Accepted Response',
166
+ color: 'secondary',
167
+ }
168
+ ],
169
+ onAccept: (response) => {
170
+ toast.success(`Dialog accepted with: ${response}`, {
171
+ position: 'bottom',
172
+ })
173
+ },
174
+ onReject: (response) => {
175
+ toast.error(`Dialog rejected with: ${response}`, {
176
+ position: 'bottom',
177
+ })
178
+ },
179
+ })
180
+ }
181
+ </script>
182
+
183
+ <template>
184
+ <MazBtn color="contrast" @click="openDialogResponse">
185
+ Show dialog with custom response
186
+ </MazBtn>
187
+ </template>
188
+ ```
189
+
190
+ ## Close dialog
191
+
192
+ You can close the dialog programmatically by calling the close method returned by the open method.
193
+
194
+ ```vue
195
+ <script lang="ts" setup>
196
+ import { useDialog, useToast } from 'maz-ui/composables'
197
+
198
+ const dialog = useDialog()
199
+
200
+ function openAndCloseDialog() {
201
+ const { close } = dialog.open({
202
+ title: 'Dialog title',
203
+ message: 'Wait 5 seconds to close the dialog',
204
+ buttons: [],
205
+ persistent: true,
206
+ })
207
+
208
+ setTimeout(() => {
209
+ close()
210
+ }, 5000)
211
+ }
212
+ </script>
213
+
214
+ <template>
215
+ <MazBtn color="contrast" @click="openAndCloseDialog">
216
+ Open and close dialog
217
+ </MazBtn>
218
+ </template>
219
+ ```
220
+
221
+ ## Options
222
+
223
+ ### Usage
224
+
225
+ ```ts
226
+ import { useDialog } from 'maz-ui/composables/useDialog'
227
+
228
+ const dialog = useDialog()
229
+
230
+ const options: DialogOptions = {
231
+ title: 'Dialog title',
232
+ message: 'Dialog message',
233
+ }
234
+
235
+ dialog.open(options)
236
+ ```
237
+
238
+ ### Type
239
+
240
+ ```ts
241
+ import type { MazBtnProps } from 'maz-ui/components/MazBtn'
242
+
243
+ type DialogOptions = Partial<Omit<MazDialogConfirmProps, 'modelValue'>> & {
244
+ /**
245
+ * Dialog identifier - identifier to manage multiple dialogs
246
+ * @default 'main-dialog'
247
+ */
248
+ identifier?: string
249
+ /**
250
+ * Custom buttons to display in the dialog and replace the default confirm and cancel buttons
251
+ * @default [{ text: 'Confirm', color: 'success', type: 'accept' }, { text: 'Cancel', color: 'destructive', type: 'reject' }]
252
+ */
253
+ buttons?: MazDialogConfirmButton[]
254
+ /**
255
+ * Function to execute when the dialog is accepted (when the user click on the confirm button)
256
+ * Only available if the button type is 'accept'
257
+ */
258
+ onAccept?: () => unknown
259
+ /**
260
+ * Function to execute when the dialog is rejected (when the user click on the cancel button)
261
+ * Only available if the button type is 'reject'
262
+ */
263
+ onReject?: () => unknown
264
+ /**
265
+ * Function to execute when the dialog is closed
266
+ */
267
+ onClose?: () => unknown
268
+ }
269
+ ```