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.
- package/dist/assets/{MazDropzone.DJ8au25t.css → MazDropzone.BW2grpTi.css} +1 -1
- package/dist/chunks/{MazDrawer.DANxKYxJ.js → MazDrawer.CC8zomfx.js} +2 -2
- package/dist/chunks/{MazDropzone.POH3pmfi.js → MazDropzone.Dez5j0WP.js} +2 -2
- package/dist/components/MazDrawer.js +1 -1
- package/dist/components/MazDropzone.js +1 -1
- package/dist/components/MazDropzone.vue.d.ts +2 -2
- package/dist/components/MazInputPrice.vue.d.ts +1 -1
- package/dist/components/index.js +2 -2
- package/docs/README.md +207 -0
- package/docs/agents/agents-md.md +52 -0
- package/docs/agents/claude-rule.md +52 -0
- package/docs/components/maz-accordion.md +76 -0
- package/docs/components/maz-alert.md +241 -0
- package/docs/components/maz-animated-counter.md +87 -0
- package/docs/components/maz-animated-element.md +46 -0
- package/docs/components/maz-animated-text.md +53 -0
- package/docs/components/maz-avatar.md +193 -0
- package/docs/components/maz-backdrop.md +178 -0
- package/docs/components/maz-badge.md +167 -0
- package/docs/components/maz-bottom-sheet.md +257 -0
- package/docs/components/maz-btn-group.md +316 -0
- package/docs/components/maz-btn.md +423 -0
- package/docs/components/maz-card-spotlight.md +84 -0
- package/docs/components/maz-card.md +321 -0
- package/docs/components/maz-carousel.md +153 -0
- package/docs/components/maz-chart.md +206 -0
- package/docs/components/maz-checkbox.md +138 -0
- package/docs/components/maz-checklist.md +251 -0
- package/docs/components/maz-circular-progress-bar.md +109 -0
- package/docs/components/maz-code-highlight.md +155 -0
- package/docs/components/maz-container.md +241 -0
- package/docs/components/maz-date-picker.md +791 -0
- package/docs/components/maz-dialog-confirm.md +215 -0
- package/docs/components/maz-dialog.md +143 -0
- package/docs/components/maz-drawer.md +106 -0
- package/docs/components/maz-dropdown.md +419 -0
- package/docs/components/maz-dropzone.md +387 -0
- package/docs/components/maz-expand-animation.md +82 -0
- package/docs/components/maz-fullscreen-loader.md +58 -0
- package/docs/components/maz-gallery.md +79 -0
- package/docs/components/maz-icon.md +203 -0
- package/docs/components/maz-input-code.md +73 -0
- package/docs/components/maz-input-number.md +79 -0
- package/docs/components/maz-input-phone-number.md +536 -0
- package/docs/components/maz-input-price.md +68 -0
- package/docs/components/maz-input-tags.md +112 -0
- package/docs/components/maz-input.md +334 -0
- package/docs/components/maz-lazy-img.md +113 -0
- package/docs/components/maz-link.md +146 -0
- package/docs/components/maz-loading-bar.md +38 -0
- package/docs/components/maz-markdown-editor.md +320 -0
- package/docs/components/maz-pagination.md +82 -0
- package/docs/components/maz-popover.md +794 -0
- package/docs/components/maz-pull-to-refresh.md +222 -0
- package/docs/components/maz-radio-buttons.md +313 -0
- package/docs/components/maz-radio.md +119 -0
- package/docs/components/maz-read-more.md +209 -0
- package/docs/components/maz-reading-progress-bar.md +96 -0
- package/docs/components/maz-select-country.md +513 -0
- package/docs/components/maz-select.md +318 -0
- package/docs/components/maz-sidebar-content.md +25 -0
- package/docs/components/maz-sidebar-footer.md +25 -0
- package/docs/components/maz-sidebar-group.md +27 -0
- package/docs/components/maz-sidebar-header.md +25 -0
- package/docs/components/maz-sidebar-menu-button.md +41 -0
- package/docs/components/maz-sidebar-menu-item.md +25 -0
- package/docs/components/maz-sidebar-menu-sub.md +32 -0
- package/docs/components/maz-sidebar-menu.md +25 -0
- package/docs/components/maz-sidebar-separator.md +21 -0
- package/docs/components/maz-sidebar-trigger.md +25 -0
- package/docs/components/maz-sidebar.md +507 -0
- package/docs/components/maz-skeleton.md +226 -0
- package/docs/components/maz-slider.md +165 -0
- package/docs/components/maz-spinner.md +84 -0
- package/docs/components/maz-stepper.md +301 -0
- package/docs/components/maz-switch.md +86 -0
- package/docs/components/maz-table-cell.md +27 -0
- package/docs/components/maz-table-row.md +28 -0
- package/docs/components/maz-table-title.md +27 -0
- package/docs/components/maz-table-virtualizer.md +31 -0
- package/docs/components/maz-table.md +426 -0
- package/docs/components/maz-tabs-bar.md +43 -0
- package/docs/components/maz-tabs-content-item.md +27 -0
- package/docs/components/maz-tabs-content.md +27 -0
- package/docs/components/maz-tabs.md +308 -0
- package/docs/components/maz-textarea.md +255 -0
- package/docs/components/maz-ticker.md +427 -0
- package/docs/components/maz-timeline.md +304 -0
- package/docs/components/maz-ui-provider.md +26 -0
- package/docs/components/maz-window-mockup.md +182 -0
- package/docs/composables/use-aos.md +41 -0
- package/docs/composables/use-breakpoints.md +42 -0
- package/docs/composables/use-dialog.md +58 -0
- package/docs/composables/use-display-names.md +130 -0
- package/docs/composables/use-drag.md +185 -0
- package/docs/composables/use-form-validator.md +1123 -0
- package/docs/composables/use-idle-timeout.md +172 -0
- package/docs/composables/use-pull-to-refresh.md +86 -0
- package/docs/composables/use-reading-time.md +132 -0
- package/docs/composables/use-string-matching.md +41 -0
- package/docs/composables/use-swipe.md +171 -0
- package/docs/composables/use-timer.md +104 -0
- package/docs/composables/use-toast.md +50 -0
- package/docs/composables/use-user-visibility.md +127 -0
- package/docs/composables/use-wait.md +50 -0
- package/docs/composables/use-window-size.md +25 -0
- package/docs/directives/click-outside.md +182 -0
- package/docs/directives/fullscreen-img.md +83 -0
- package/docs/directives/lazy-img.md +182 -0
- package/docs/directives/tooltip.md +298 -0
- package/docs/directives/zoom-img.md +100 -0
- package/docs/ecosystem/eslint-config.md +289 -0
- package/docs/ecosystem/icons/icon-set.md +25 -0
- package/docs/ecosystem/icons/index.md +584 -0
- package/docs/ecosystem/mcp.md +165 -0
- package/docs/ecosystem/node/exec-promise.md +93 -0
- package/docs/ecosystem/node/index.md +53 -0
- package/docs/ecosystem/node/logger.md +152 -0
- package/docs/ecosystem/node/print-banner.md +101 -0
- package/docs/ecosystem/node/setup-agents.md +102 -0
- package/docs/ecosystem/nuxt.md +551 -0
- package/docs/ecosystem/stylelint-config.md +310 -0
- package/docs/ecosystem/themes.md +966 -0
- package/docs/ecosystem/translations.md +1173 -0
- package/docs/ecosystem/utils/camel-case.md +37 -0
- package/docs/ecosystem/utils/capitalize.md +37 -0
- package/docs/ecosystem/utils/check-availability.md +85 -0
- package/docs/ecosystem/utils/cookie.md +86 -0
- package/docs/ecosystem/utils/country-code-to-unicode-flag.md +128 -0
- package/docs/ecosystem/utils/currency.md +53 -0
- package/docs/ecosystem/utils/date.md +53 -0
- package/docs/ecosystem/utils/debounce-callback.md +44 -0
- package/docs/ecosystem/utils/debounce-id.md +75 -0
- package/docs/ecosystem/utils/debounce.md +71 -0
- package/docs/ecosystem/utils/fetch-locale-ip.md +39 -0
- package/docs/ecosystem/utils/format-json.md +39 -0
- package/docs/ecosystem/utils/format-phone-number.md +43 -0
- package/docs/ecosystem/utils/get-browser-locale.md +35 -0
- package/docs/ecosystem/utils/get-country-flag-url.md +67 -0
- package/docs/ecosystem/utils/get-error-message.md +45 -0
- package/docs/ecosystem/utils/idle-timeout.md +96 -0
- package/docs/ecosystem/utils/index.md +57 -0
- package/docs/ecosystem/utils/is-client.md +38 -0
- package/docs/ecosystem/utils/is-equal.md +44 -0
- package/docs/ecosystem/utils/is-ios.md +43 -0
- package/docs/ecosystem/utils/is-server.md +37 -0
- package/docs/ecosystem/utils/is-standalone-mode.md +49 -0
- package/docs/ecosystem/utils/kebab-case.md +42 -0
- package/docs/ecosystem/utils/normalize-string.md +83 -0
- package/docs/ecosystem/utils/number.md +51 -0
- package/docs/ecosystem/utils/pascal-case.md +41 -0
- package/docs/ecosystem/utils/prevent-ios-input-zoom.md +72 -0
- package/docs/ecosystem/utils/script-loader.md +85 -0
- package/docs/ecosystem/utils/sleep.md +65 -0
- package/docs/ecosystem/utils/snake-case.md +42 -0
- package/docs/ecosystem/utils/swipe-handler.md +97 -0
- package/docs/ecosystem/utils/textarea-autogrow.md +47 -0
- package/docs/ecosystem/utils/throttle-id.md +54 -0
- package/docs/ecosystem/utils/throttle.md +63 -0
- package/docs/ecosystem/utils/truthy-filter.md +37 -0
- package/docs/ecosystem/utils/types/deep-key-of.md +54 -0
- package/docs/ecosystem/utils/types/deep-partial.md +48 -0
- package/docs/ecosystem/utils/types/deep-required.md +45 -0
- package/docs/ecosystem/utils/types/flatten-object-keys.md +50 -0
- package/docs/ecosystem/utils/types/generic-instance-type.md +48 -0
- package/docs/ecosystem/utils/types/infer-maybe-ref.md +41 -0
- package/docs/ecosystem/utils/upper-first.md +38 -0
- package/docs/ecosystem/utils/user-visibility.md +75 -0
- package/docs/guide/ai-agents.md +237 -0
- package/docs/guide/browser-support.md +88 -0
- package/docs/guide/getting-started.md +191 -0
- package/docs/guide/global-defaults.md +103 -0
- package/docs/guide/maz-ui-provider.md +231 -0
- package/docs/guide/migration-v5.md +871 -0
- package/docs/guide/resolvers.md +650 -0
- package/docs/guide/tailwind.md +483 -0
- package/docs/guide/vue.md +286 -0
- package/docs/manifest.json +1 -0
- package/docs/plugins/aos.md +312 -0
- package/docs/plugins/dialog.md +269 -0
- package/docs/plugins/toast.md +221 -0
- package/docs/plugins/wait.md +78 -0
- package/docs/reference/icons.md +46 -0
- package/docs/reference/tailwind-tokens.md +191 -0
- package/docs/rules.md +57 -0
- package/package.json +31 -4
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "MazDropzone"
|
|
3
|
+
description: "MazDropzone is a powerful and flexible file upload component with drag & drop support, progress tracking, and customizable UI. Perfect for handling single or multiple file uploads in your Vue applications."
|
|
4
|
+
package: "maz-ui"
|
|
5
|
+
url: "https://maz-ui.com/components/maz-dropzone"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# MazDropzone
|
|
9
|
+
|
|
10
|
+
> MazDropzone is a powerful and flexible file upload component with drag & drop support, progress tracking, and customizable UI. Perfect for handling single or multiple file uploads in your Vue applications.
|
|
11
|
+
|
|
12
|
+
- Package: `maz-ui`
|
|
13
|
+
- Import: `import MazDropzone from 'maz-ui/components/MazDropzone'`
|
|
14
|
+
- Nuxt: auto-imported by `@maz-ui/nuxt`, no import needed in a Nuxt app
|
|
15
|
+
- Web: https://maz-ui.com/components/maz-dropzone
|
|
16
|
+
|
|
17
|
+
> Before use it, you should install the MazUi plugin in your project, follow instructions in [Getting Started](../guide/getting-started.md)
|
|
18
|
+
|
|
19
|
+
**Tip:**
|
|
20
|
+
|
|
21
|
+
This component can be translated globally using the [MazUi](../ecosystem/translations.md) plugin.
|
|
22
|
+
|
|
23
|
+
## Key Features
|
|
24
|
+
|
|
25
|
+
- 🎯 Drag & drop support
|
|
26
|
+
- 📁 Single or multiple file uploads
|
|
27
|
+
- 🖼️ Image preview thumbnails
|
|
28
|
+
- 🚀 Auto upload support
|
|
29
|
+
- ⚡ Async file processing
|
|
30
|
+
- 🎨 Fully customizable UI
|
|
31
|
+
- 🌐 Support for various file types
|
|
32
|
+
- ⚙️ Extensive configuration options
|
|
33
|
+
- 🔒 File validation (size, type, count)
|
|
34
|
+
- 🌍 Internationalization support
|
|
35
|
+
|
|
36
|
+
## Error codes
|
|
37
|
+
|
|
38
|
+
| Error Code | Description | Trigger |
|
|
39
|
+
| ---------------------------- | ---------------------------------------- | ---------------------------------------------------------------------------------------- |
|
|
40
|
+
| `FILE_SIZE_EXCEEDED` | File size exceeds the allowed limit | When a file is larger than `maxFileSize` (in MB) |
|
|
41
|
+
| `FILE_SIZE_TOO_SMALL` | File size is below the minimum limit | When a file is smaller than `minFileSize` (in MB) |
|
|
42
|
+
| `MAX_FILES_EXCEEDED` | Maximum number of allowed files exceeded | When trying to add more files than `maxFiles` or more than 1 file if `multiple=false` |
|
|
43
|
+
| `FILE_TYPE_NOT_ALLOWED` | File type is not allowed | When the file's MIME type doesn't match the specified `dataTypes` |
|
|
44
|
+
| `FILE_DUPLICATED` | An identical file already exists | When `allowDuplicates=false` and a file with the same name, size and type already exists |
|
|
45
|
+
| `NO_FILES_TO_UPLOAD` | No files to upload | When starting upload but there are no files in the dropzone |
|
|
46
|
+
| `FILE_UPLOAD_ERROR` | Error during individual file upload | When uploading a specific file fails (`single` mode) |
|
|
47
|
+
| `FILE_UPLOAD_ERROR_MULTIPLE` | Error during batch upload | When uploading multiple files fails (`multiple` mode) |
|
|
48
|
+
| `NO_URL` | No upload URL configured | When attempting auto-upload without defining the `url` prop |
|
|
49
|
+
|
|
50
|
+
### Error handling example
|
|
51
|
+
|
|
52
|
+
**Details: View code**
|
|
53
|
+
|
|
54
|
+
```vue
|
|
55
|
+
<script setup>
|
|
56
|
+
function handleError({ code, files }) {
|
|
57
|
+
switch (code) {
|
|
58
|
+
case 'FILE_SIZE_EXCEEDED':
|
|
59
|
+
console.log('File too large:', files[0].name)
|
|
60
|
+
break
|
|
61
|
+
case 'FILE_TYPE_NOT_ALLOWED':
|
|
62
|
+
console.log('File type not allowed:', files[0].type)
|
|
63
|
+
break
|
|
64
|
+
case 'MAX_FILES_EXCEEDED':
|
|
65
|
+
console.log('Too many files selected')
|
|
66
|
+
break
|
|
67
|
+
// ...
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<template>
|
|
73
|
+
<MazDropzone
|
|
74
|
+
:max-file-size="5"
|
|
75
|
+
:max-files="3"
|
|
76
|
+
:data-types="['image/*', 'application/pdf']"
|
|
77
|
+
:allow-duplicates="false"
|
|
78
|
+
@error="handleError"
|
|
79
|
+
/>
|
|
80
|
+
</template>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Basic Usage
|
|
84
|
+
|
|
85
|
+
```vue
|
|
86
|
+
<script setup lang="ts">
|
|
87
|
+
import { useToast } from 'maz-ui/composables'
|
|
88
|
+
import { ref } from 'vue'
|
|
89
|
+
|
|
90
|
+
const toast = useToast()
|
|
91
|
+
|
|
92
|
+
const files = ref<File[]>([])
|
|
93
|
+
const dropzone = ref<InstanceType<typeof MazDropzone>>()
|
|
94
|
+
|
|
95
|
+
function onUploadSuccess({ file, response }) {
|
|
96
|
+
console.log('Upload success:', file, response)
|
|
97
|
+
toast.success(`File ${file.name} uploaded successfully`)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function onUploadError({ file, code, error }) {
|
|
101
|
+
console.error('Upload failed:', file, code, error)
|
|
102
|
+
toast.error(`File ${file.name} upload failed: ${code} - ${error}`)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function onError({ files, event, code }) {
|
|
106
|
+
console.error('Error:', files, event, code)
|
|
107
|
+
toast.error(`${files?.length} files upload failed: ${code} - ${files?.map(file => file.name).join(', ')}`)
|
|
108
|
+
}
|
|
109
|
+
</script>
|
|
110
|
+
|
|
111
|
+
<template>
|
|
112
|
+
<MazDropzone
|
|
113
|
+
v-model="files"
|
|
114
|
+
:data-types="['image/*', '.zip', '.strings', '.json', '.stringsdict']"
|
|
115
|
+
:max-file-size="3"
|
|
116
|
+
:max-files="5"
|
|
117
|
+
:max-concurrent-uploads="5"
|
|
118
|
+
url="https://httpbin.org/post"
|
|
119
|
+
:request-options="{
|
|
120
|
+
headers: { 'My-Awesome-Header': 'header value' },
|
|
121
|
+
}"
|
|
122
|
+
@upload-success="onUploadSuccess"
|
|
123
|
+
@upload-error="onUploadError"
|
|
124
|
+
@error="onError"
|
|
125
|
+
/>
|
|
126
|
+
|
|
127
|
+
<MazBtn :loading="dropzone?.isUploading" @click="dropzone?.uploadFiles()">
|
|
128
|
+
Upload Files
|
|
129
|
+
</MazBtn>
|
|
130
|
+
</template>
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## File Type Restrictions
|
|
134
|
+
|
|
135
|
+
You can restrict allowed file types using the `data-types` prop:
|
|
136
|
+
|
|
137
|
+
```vue
|
|
138
|
+
<script lang="ts" setup>
|
|
139
|
+
const acceptedFormats = [
|
|
140
|
+
'.strings',
|
|
141
|
+
'.stringsdict',
|
|
142
|
+
'.plist',
|
|
143
|
+
'.xliff',
|
|
144
|
+
'.xlf',
|
|
145
|
+
'.xml',
|
|
146
|
+
'.json',
|
|
147
|
+
'.yaml',
|
|
148
|
+
'.yml',
|
|
149
|
+
'.po',
|
|
150
|
+
'.pot',
|
|
151
|
+
'.mo',
|
|
152
|
+
'.properties',
|
|
153
|
+
'.arb',
|
|
154
|
+
'.csv',
|
|
155
|
+
'.tsv',
|
|
156
|
+
'.txt',
|
|
157
|
+
'text/*',
|
|
158
|
+
'application/json',
|
|
159
|
+
'text/xml',
|
|
160
|
+
'application/xml',
|
|
161
|
+
'text/yaml',
|
|
162
|
+
'text/html',
|
|
163
|
+
'image/svg+xml',
|
|
164
|
+
'video/mp4',
|
|
165
|
+
'video/quicktime',
|
|
166
|
+
'video/mpeg',
|
|
167
|
+
'video/ogg',
|
|
168
|
+
'video/webm',
|
|
169
|
+
'audio/*',
|
|
170
|
+
]
|
|
171
|
+
</script>
|
|
172
|
+
|
|
173
|
+
<template>
|
|
174
|
+
<MazDropzone
|
|
175
|
+
v-model="files"
|
|
176
|
+
:data-types="acceptedFormats"
|
|
177
|
+
:max-file-size="5"
|
|
178
|
+
:max-files="5"
|
|
179
|
+
@error="onError"
|
|
180
|
+
/>
|
|
181
|
+
</template>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Auto Upload
|
|
185
|
+
|
|
186
|
+
Enable automatic file upload using the `auto-upload` prop. Files can be uploaded individually (`single`) in separate requests or all at once (`multiple`) in a single request:
|
|
187
|
+
|
|
188
|
+
```html
|
|
189
|
+
<MazDropzone
|
|
190
|
+
v-model="files"
|
|
191
|
+
auto-upload="single"
|
|
192
|
+
url="https://your-upload-endpoint.com/upload"
|
|
193
|
+
@upload-success="onUploadSuccess"
|
|
194
|
+
@upload-error="onUploadError"
|
|
195
|
+
@error="onError"
|
|
196
|
+
/>
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
You can also upload all files at once using `multiple`:
|
|
200
|
+
|
|
201
|
+
**Tip:**
|
|
202
|
+
|
|
203
|
+
Multiple upload is allowed:
|
|
204
|
+
|
|
205
|
+
- when `max-files` is greater than 1
|
|
206
|
+
- when `auto-upload` is set to `multiple`
|
|
207
|
+
- when `multiple` prop is set to `true`
|
|
208
|
+
|
|
209
|
+
[Link to the source code](https://github.com/maz-ui/maz-ui/blob/main/components/MazDropzone.vue#L219)
|
|
210
|
+
|
|
211
|
+
```html
|
|
212
|
+
<template>
|
|
213
|
+
<MazDropzone
|
|
214
|
+
v-model="files"
|
|
215
|
+
auto-upload="multiple"
|
|
216
|
+
url="https://your-upload-endpoint.com/upload"
|
|
217
|
+
@upload-success-multiple="onUploadSuccessMultiple"
|
|
218
|
+
@upload-error-multiple="onUploadErrorMultiple"
|
|
219
|
+
@error="onError"
|
|
220
|
+
/>
|
|
221
|
+
</template>
|
|
222
|
+
|
|
223
|
+
<script setup lang="ts">
|
|
224
|
+
import { ref } from 'vue'
|
|
225
|
+
import { useToast } from 'maz-ui/composables'
|
|
226
|
+
|
|
227
|
+
const files = ref<File[]>([])
|
|
228
|
+
|
|
229
|
+
const toast = useToast()
|
|
230
|
+
|
|
231
|
+
const onUploadSuccessMultiple = ({ files, response }) => {
|
|
232
|
+
console.log('Upload multiple success:', files, response)
|
|
233
|
+
toast.success(`${files.length} files uploaded successfully`)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const onUploadErrorMultiple = ({ files, code, error }) => {
|
|
237
|
+
console.error('Upload mulitple failed:', files, code, error)
|
|
238
|
+
toast.error(`${files.length} files upload failed: ${code} - ${error}`)
|
|
239
|
+
}
|
|
240
|
+
</script>
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Custom Upload Area
|
|
244
|
+
|
|
245
|
+
Customize the upload area using slots:
|
|
246
|
+
|
|
247
|
+
```html
|
|
248
|
+
<MazDropzone v-model="files" @error="onError">
|
|
249
|
+
<template #no-files-area="{ handleFileInputClick }">
|
|
250
|
+
<div class="flex flex-col items-center gap-4">
|
|
251
|
+
<MazIcon icon="/arrow-up-on-square.svg" class="text-4xl" />
|
|
252
|
+
<p>Drop your files here or click to browse</p>
|
|
253
|
+
<MazBtn @click="handleFileInputClick"> Select Files </MazBtn>
|
|
254
|
+
</div>
|
|
255
|
+
</template>
|
|
256
|
+
</MazDropzone>
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## Custom Translations
|
|
260
|
+
|
|
261
|
+
### Using `translations` prop
|
|
262
|
+
|
|
263
|
+
Customize text messages using the `translations` prop:
|
|
264
|
+
|
|
265
|
+
```html
|
|
266
|
+
<MazDropzone
|
|
267
|
+
v-model="files"
|
|
268
|
+
:translations="{
|
|
269
|
+
dragAndDrop: 'Drag files here',
|
|
270
|
+
selectFile: 'browse files',
|
|
271
|
+
fileInfos: 'Accepted files: Images up to 5MB'
|
|
272
|
+
}"
|
|
273
|
+
@error="onError"
|
|
274
|
+
/>
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### Using `MazUi` plugin
|
|
278
|
+
|
|
279
|
+
You can also use the `MazUi` plugin to customize the translations:
|
|
280
|
+
|
|
281
|
+
**Details: View code**
|
|
282
|
+
|
|
283
|
+
```ts
|
|
284
|
+
import { MazUi } from 'maz-ui/plugins/maz-ui'
|
|
285
|
+
|
|
286
|
+
app.use(MazUi, {
|
|
287
|
+
translations: {
|
|
288
|
+
locale: 'en',
|
|
289
|
+
messages: {
|
|
290
|
+
en: {
|
|
291
|
+
dropzone: {
|
|
292
|
+
dragAndDrop: 'Drag files here',
|
|
293
|
+
selectFile: 'select files',
|
|
294
|
+
divider: 'or',
|
|
295
|
+
fileMaxCount: 'Maximum {count} files',
|
|
296
|
+
fileMaxSize: 'Maximum {size} MB',
|
|
297
|
+
fileTypes: 'Allowed file types: {types}',
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
})
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## Custom Upload Request
|
|
306
|
+
|
|
307
|
+
Customize the upload request using `uploadUrl`, `requestOptions` and `transformBody`:
|
|
308
|
+
|
|
309
|
+
```html
|
|
310
|
+
<MazDropzone
|
|
311
|
+
v-model="files"
|
|
312
|
+
url="/api/upload"
|
|
313
|
+
:request-options="{
|
|
314
|
+
method: 'POST',
|
|
315
|
+
headers: {
|
|
316
|
+
'Authorization': 'Bearer token123'
|
|
317
|
+
},
|
|
318
|
+
}"
|
|
319
|
+
:transform-body="(formData, files) => {
|
|
320
|
+
// Add additional data to FormData
|
|
321
|
+
formData.append('userId', '123')
|
|
322
|
+
formData.append('fileCount', files.length.toString())
|
|
323
|
+
return formData
|
|
324
|
+
}"
|
|
325
|
+
@error="onError"
|
|
326
|
+
/>
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
## MazDropzone API
|
|
330
|
+
|
|
331
|
+
`import MazDropzone from 'maz-ui/components/MazDropzone'`
|
|
332
|
+
|
|
333
|
+
### Props
|
|
334
|
+
|
|
335
|
+
- `id` (`string`): The id of the dropzone.
|
|
336
|
+
- `multiple` (`boolean`, default: `false`): Allow multiple files to be uploaded.
|
|
337
|
+
- `data-types` (`string[]`, default: `['*\/*']`): Allowed data types/MIME types for files (e.g. ['application/json']).
|
|
338
|
+
- `prevent-default-for-unhandled` (`boolean`, default: `true`): Prevent default behavior for unhandled drag & drop events.
|
|
339
|
+
- `max-file-size` (`number`): Maximum file size in MB.
|
|
340
|
+
- `max-files` (`number`): Maximum number of files allowed.
|
|
341
|
+
- `disabled` (`boolean`, default: `false`): Disable the dropzone.
|
|
342
|
+
- `preview` (`boolean`, default: `true`): Show file preview.
|
|
343
|
+
- `min-file-size` (`number`): Minimum file size in MB.
|
|
344
|
+
- `allow-duplicates` (`boolean`, default: `false`): Allow duplicates.
|
|
345
|
+
- `translations` (`{ dragAndDrop?: string | undefined; selectFile?: string | undefined; divider?: string | undefined; fileMaxCount?: string | undefined; fileMaxSize?: string | undefined; fileTypes?: string | undefined; types?: { image?: string | undefined;...`): Translations - Custom translations for the component.
|
|
346
|
+
- `color` (`"primary" | "secondary" | "accent" | "info" | "success" | "warning" | "destructive" | "contrast" | "transparent"`, default: `"primary"`): Main color of the component.
|
|
347
|
+
- `remove-file-btn-props` (`MazBtnProps`, default: `{}`): MazBtn props [MazBtn props](./maz-btn.md#props).
|
|
348
|
+
- `spinner-props` (`MazSpinnerProps`, default: `{}`): MazSpinner props [MazSpinner props](./maz-spinner.md#props).
|
|
349
|
+
- `auto-upload` (`false | "multiple" | "single"`, default: `false`): Auto upload files - If set to `multiple`, all files will be uploaded at once in a single request. If set to `single`, files will be uploaded one by one in separate requests. If set to `false`, no upload will be done automatically.
|
|
350
|
+
- `url` (`string`): Upload URL - If set, files will be uploaded to the given URL.
|
|
351
|
+
- `request-options` (`RequestInit`): Request options - Request options to be used for the upload (using fetch) [Request options](https://developer.mozilla.org/en-US/docs/Web/API/fetch#options).
|
|
352
|
+
- `transform-body` (`((formData: FormData) => BodyInit | null | undefined)`): Transform the body of the request.
|
|
353
|
+
- `max-concurrent-uploads` (`number`, default: `5`): Maximum number of concurrent uploads - Limit the number of files uploaded simultaneously to avoid overwhelming the server.
|
|
354
|
+
- `model-value` (`MazDropzoneFileData[]`, default: `[]`, `v-model`): The files data.
|
|
355
|
+
|
|
356
|
+
### Events
|
|
357
|
+
|
|
358
|
+
- `@add` (payload: `value: File`): Event emitted when a file is added to the dropzone
|
|
359
|
+
- `@error` (payload: `values: { files: File[] | null; event: DragEvent | null; code: MazDropzoneErrorCode; }`): Event emitted when an error occurs
|
|
360
|
+
- `@drop` (payload: `values: { files: File[] | null; event: DragEvent; }`): Event emitted when files are dropped in the dropzone
|
|
361
|
+
- `@update:modelValue` (payload: `value: MazDropzoneFileData[]`)
|
|
362
|
+
- `@enter` (payload: `values: { files: File[] | null; event: DragEvent; }`): Event emitted when dragged files enter the dropzone
|
|
363
|
+
- `@leave` (payload: `values: { files: File[] | null; event: DragEvent; }`): Event emitted when dragged files leave the dropzone
|
|
364
|
+
- `@over` (payload: `values: { files: File[] | null; event: DragEvent; }`): Event emitted when dragged files are over the dropzone
|
|
365
|
+
- `@remove` (payload: `value: File`): Event emitted when a file is removed from the dropzone
|
|
366
|
+
- `@upload-error` (payload: `values: { file: File; code: MazDropzoneErrorCode; error: unknown; }`): Event emitted when an error occurs during file upload
|
|
367
|
+
- `@upload-error-multiple` (payload: `values: { files: File[]; code: MazDropzoneErrorCode; error: unknown; }`): Event emitted when an error occurs during multiple files upload
|
|
368
|
+
- `@upload-success` (payload: `values: { file: File; response?: Response | undefined; }`): Event emitted when a file is successfully uploaded
|
|
369
|
+
- `@upload-success-multiple` (payload: `values: { files: File[]; response?: Response | undefined; }`): Event emitted when multiple files are successfully uploaded
|
|
370
|
+
|
|
371
|
+
### Slots
|
|
372
|
+
|
|
373
|
+
- `#files-area`: Slot to customize the files area Bindings: `filesData: MazDropzoneFileData[]` (The files data).
|
|
374
|
+
- `#file-item`: Slot to customize the file item Bindings: `file: MazDropzoneFileData` (The drop file data).
|
|
375
|
+
- `#no-files-area`: Slot to customize the no files area Bindings: `selectFile: () => void` (The function to select the file).
|
|
376
|
+
- `#upload-icon`: Slot to customize the upload icon
|
|
377
|
+
|
|
378
|
+
### Exposed (template ref)
|
|
379
|
+
|
|
380
|
+
- `uploadFiles`: Upload files
|
|
381
|
+
- `uploadFilesMultiple`: Upload multiple files
|
|
382
|
+
- `getFormData`: Get form data
|
|
383
|
+
- `getFormDataMultiple`: Get form data multiple
|
|
384
|
+
- `reset`: Reset the files
|
|
385
|
+
- `isUploading`: Check if the files are uploading
|
|
386
|
+
- `addFile`: Add a file to the dropzone
|
|
387
|
+
- `removeFile`: Remove a file from the dropzone
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "MazExpandAnimation"
|
|
3
|
+
description: "MazExpandAnimation is a standalone component that allows you to animate the height of a block element"
|
|
4
|
+
package: "maz-ui"
|
|
5
|
+
url: "https://maz-ui.com/components/maz-expand-animation"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# MazExpandAnimation
|
|
9
|
+
|
|
10
|
+
> MazExpandAnimation is a standalone component that allows you to animate the height of a block element
|
|
11
|
+
|
|
12
|
+
- Package: `maz-ui`
|
|
13
|
+
- Import: `import MazExpandAnimation from 'maz-ui/components/MazExpandAnimation'`
|
|
14
|
+
- Nuxt: auto-imported by `@maz-ui/nuxt`, no import needed in a Nuxt app
|
|
15
|
+
- Web: https://maz-ui.com/components/maz-expand-animation
|
|
16
|
+
|
|
17
|
+
> Before use it, you should install the MazUi plugin in your project, follow instructions in [Getting Started](../guide/getting-started.md)
|
|
18
|
+
|
|
19
|
+
## Basic usage
|
|
20
|
+
|
|
21
|
+
```vue
|
|
22
|
+
<script lang="ts" setup>
|
|
23
|
+
import MazExpandAnimation from 'maz-ui/components/MazExpandAnimation'
|
|
24
|
+
import { ref } from 'vue'
|
|
25
|
+
|
|
26
|
+
const visible = ref(false)
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<template>
|
|
30
|
+
<MazBtn @click="visible = !visible">
|
|
31
|
+
Exec animation
|
|
32
|
+
</MazBtn>
|
|
33
|
+
|
|
34
|
+
<MazExpandAnimation v-model="visible">
|
|
35
|
+
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.
|
|
36
|
+
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.
|
|
37
|
+
</MazExpandAnimation>
|
|
38
|
+
</template>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Options
|
|
42
|
+
|
|
43
|
+
- **duration**: `String` - default: `300ms` - Duration of the animation in ms
|
|
44
|
+
- **timing-function**: `String` - default: `ease-in-out` - Timing function of the animation
|
|
45
|
+
|
|
46
|
+
```vue
|
|
47
|
+
<script lang="ts" setup>
|
|
48
|
+
import MazExpandAnimation from 'maz-ui/components/MazExpandAnimation'
|
|
49
|
+
import { ref } from 'vue'
|
|
50
|
+
|
|
51
|
+
const visible = ref(false)
|
|
52
|
+
</script>
|
|
53
|
+
|
|
54
|
+
<template>
|
|
55
|
+
<MazBtn @click="visible = !visible">
|
|
56
|
+
Exec animation
|
|
57
|
+
</MazBtn>
|
|
58
|
+
|
|
59
|
+
<MazExpandAnimation v-model="visible" duration="1000ms" timing-function="linear">
|
|
60
|
+
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.
|
|
61
|
+
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.
|
|
62
|
+
</MazExpandAnimation>
|
|
63
|
+
</template>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## MazExpandAnimation API
|
|
67
|
+
|
|
68
|
+
`import MazExpandAnimation from 'maz-ui/components/MazExpandAnimation'`
|
|
69
|
+
|
|
70
|
+
### Props
|
|
71
|
+
|
|
72
|
+
- `duration` (`string`, default: `"300ms"`): Duration of the animation in milliseconds.
|
|
73
|
+
- `timing-function` (`string`, default: `"ease-in-out"`): Timing function of the animation.
|
|
74
|
+
- `model-value` (`boolean`, `v-model`)
|
|
75
|
+
|
|
76
|
+
### Events
|
|
77
|
+
|
|
78
|
+
- `@update:modelValue` (payload: `value: boolean | undefined`)
|
|
79
|
+
|
|
80
|
+
### Slots
|
|
81
|
+
|
|
82
|
+
- `#default`: Default Slot - Display content
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "MazFullscreenLoader"
|
|
3
|
+
description: "MazFullscreenLoader is a standalone component"
|
|
4
|
+
package: "maz-ui"
|
|
5
|
+
url: "https://maz-ui.com/components/maz-fullscreen-loader"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# MazFullscreenLoader
|
|
9
|
+
|
|
10
|
+
> MazFullscreenLoader is a standalone component
|
|
11
|
+
|
|
12
|
+
- Package: `maz-ui`
|
|
13
|
+
- Import: `import MazFullscreenLoader from 'maz-ui/components/MazFullscreenLoader'`
|
|
14
|
+
- Nuxt: auto-imported by `@maz-ui/nuxt`, no import needed in a Nuxt app
|
|
15
|
+
- Web: https://maz-ui.com/components/maz-fullscreen-loader
|
|
16
|
+
|
|
17
|
+
> Before use it, you should install the MazUi plugin in your project, follow instructions in [Getting Started](../guide/getting-started.md)
|
|
18
|
+
|
|
19
|
+
## Basic usage
|
|
20
|
+
|
|
21
|
+
```vue
|
|
22
|
+
<script lang="ts" setup>
|
|
23
|
+
import { MazBtn, MazFullscreenLoader } from 'maz-ui/components'
|
|
24
|
+
|
|
25
|
+
import { ref } from 'vue'
|
|
26
|
+
|
|
27
|
+
const showLoader = ref(false)
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<template>
|
|
31
|
+
<MazFullscreenLoader v-if="showLoader" @click="showLoader = false">
|
|
32
|
+
<p>
|
|
33
|
+
Loading...
|
|
34
|
+
</p>
|
|
35
|
+
<p>
|
|
36
|
+
(click to hide loader)
|
|
37
|
+
</p>
|
|
38
|
+
</MazFullscreenLoader>
|
|
39
|
+
|
|
40
|
+
<MazBtn @click="showLoader = true">
|
|
41
|
+
Show loader
|
|
42
|
+
</MazBtn>
|
|
43
|
+
</template>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## MazFullscreenLoader API
|
|
47
|
+
|
|
48
|
+
`import MazFullscreenLoader from 'maz-ui/components/MazFullscreenLoader'`
|
|
49
|
+
|
|
50
|
+
### Props
|
|
51
|
+
|
|
52
|
+
- `color` (`"primary" | "secondary" | "accent" | "info" | "success" | "warning" | "destructive" | "contrast" | "transparent"`, default: `"primary"`): The color of the spinner.
|
|
53
|
+
- `size` (`` `${number}rem` | `${number}px` | `${number}em` | `${number}vw` | `${number}vh` | `${number}vmin` | `${number}vmax` | `${number}%` | `${number}ch` | `${number}cm` | `${number}mm` | `${number}in` | `${number}ex` | `${number}pc` | `${number... ``, default: `"3em"`): The size of the spinner.
|
|
54
|
+
- `teleport-selector` (`string`, default: `"body"`): The selector to teleport the loader.
|
|
55
|
+
|
|
56
|
+
### Slots
|
|
57
|
+
|
|
58
|
+
- `#default`
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "MazGallery"
|
|
3
|
+
description: "MazGallery is a standalone component used to display images in a container and has many options and actions"
|
|
4
|
+
package: "maz-ui"
|
|
5
|
+
url: "https://maz-ui.com/components/maz-gallery"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# MazGallery
|
|
9
|
+
|
|
10
|
+
> MazGallery is a standalone component used to display images in a container and has many options and actions
|
|
11
|
+
|
|
12
|
+
- Package: `maz-ui`
|
|
13
|
+
- Import: `import MazGallery from 'maz-ui/components/MazGallery'`
|
|
14
|
+
- Nuxt: auto-imported by `@maz-ui/nuxt`, no import needed in a Nuxt app
|
|
15
|
+
- Web: https://maz-ui.com/components/maz-gallery
|
|
16
|
+
|
|
17
|
+
> Before use it, you should install the MazUi plugin in your project, follow instructions in [Getting Started](../guide/getting-started.md)
|
|
18
|
+
|
|
19
|
+
## Basic usage
|
|
20
|
+
|
|
21
|
+
```vue
|
|
22
|
+
<script lang="ts" setup>
|
|
23
|
+
import { MazGallery, type MazGalleryImage } from 'maz-ui/components'
|
|
24
|
+
|
|
25
|
+
const images: MazGalleryImage[] = [
|
|
26
|
+
'https://placedog.net/640/400',
|
|
27
|
+
{ src: 'https://placedog.net/640/600', thumbnail: 'https://placedog.net/100/100', alt: 'image description' },
|
|
28
|
+
{ src: 'https://placedog.net/640/700', alt: 'image description' },
|
|
29
|
+
'https://placedog.net/640/800',
|
|
30
|
+
'https://placedog.net/640/1000',
|
|
31
|
+
'https://placedog.net/800/800'
|
|
32
|
+
]
|
|
33
|
+
</script>
|
|
34
|
+
|
|
35
|
+
<template>
|
|
36
|
+
<MazGallery
|
|
37
|
+
:images
|
|
38
|
+
:height="320"
|
|
39
|
+
/>
|
|
40
|
+
</template>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Set height by CSS
|
|
44
|
+
|
|
45
|
+
```html
|
|
46
|
+
<MazGallery :images="images" class="h-48 md:h-60 lg:h-80" :height="false" />
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Types
|
|
50
|
+
|
|
51
|
+
```ts
|
|
52
|
+
type MazGalleryImage
|
|
53
|
+
= | {
|
|
54
|
+
thumbnail?: string
|
|
55
|
+
src: string
|
|
56
|
+
alt?: string
|
|
57
|
+
}
|
|
58
|
+
| string
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## MazGallery API
|
|
62
|
+
|
|
63
|
+
`import MazGallery from 'maz-ui/components/MazGallery'`
|
|
64
|
+
|
|
65
|
+
### Props
|
|
66
|
+
|
|
67
|
+
- `images` (`MazGalleryImage[]`, default: `[]`): Array of string or object: `['https://via.placeholder.com/500', 'https://via.placeholder.com/600']` or `[{ slug: 'https://via.placeholder.com/500', alt: 'image descripton' }, { slug: 'https://via.placeholder.com/600', alt: 'image descripton' }]`.
|
|
68
|
+
- `displayed-count` (`number`, default: `5`): Images count shown (max: 5).
|
|
69
|
+
- `remaining` (`boolean`, default: `true`): Remove transparent layer with the remain count (ex: +2).
|
|
70
|
+
- `height` (`string | number | false`, default: `"100%"`): Height of gallery - set to `false` to remove default height.
|
|
71
|
+
- `width` (`string | number | false`, default: `"100%"`): Width of gallery - set to `false` to remove default width.
|
|
72
|
+
- `radius` (`boolean`, default: `true`): Disable the border radius of the gallery.
|
|
73
|
+
- `zoom` (`boolean`, default: `true`): Disable full size display when clicking on image.
|
|
74
|
+
- `has-empty-layer` (`boolean`, default: `true`): Layer with photography icon when no images is provided.
|
|
75
|
+
- `lazy` (`boolean`, default: `true`): Lazy load image - if false, images are directly loaded.
|
|
76
|
+
- `blur` (`boolean`, default: `true`): Disable blur effect on image hover.
|
|
77
|
+
- `scale` (`boolean`, default: `true`): Disable scale animation effect on image hover.
|
|
78
|
+
- `separator-color` (`string`, default: `"transparent"`): Choose color of borders between images - Should be a CSS color or CSS variable - Ex: `#000`.
|
|
79
|
+
- `background-color` (`string`): Choose background color of the gallery - Should be a CSS color or CSS variable - Ex: `#000`.
|