@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,275 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: vClickOutside
|
|
3
|
+
description: vClickOutside is a Vue 3 directive to trigger a function when the user clicks outside an element
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
## Basic usage
|
|
11
|
+
|
|
12
|
+
<ComponentDemo>
|
|
13
|
+
<div
|
|
14
|
+
style="padding: 50px; background-color: hsl(var(--maz-background-300));"
|
|
15
|
+
class="maz-flex maz-flex-center maz-rounded"
|
|
16
|
+
>
|
|
17
|
+
<MazCard v-click-outside="clikedOutside">
|
|
18
|
+
Click outside me
|
|
19
|
+
</MazCard>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<div
|
|
23
|
+
v-if="hasClikedOutside"
|
|
24
|
+
style="padding: 16px; margin-top: 16px; background-color: hsl(var(--maz-success)); color: black;"
|
|
25
|
+
class="maz-flex maz-flex-center maz-rounded"
|
|
26
|
+
>
|
|
27
|
+
You clicked outside
|
|
28
|
+
</div>
|
|
29
|
+
|
|
30
|
+
<template #code>
|
|
31
|
+
|
|
32
|
+
```vue
|
|
33
|
+
<script lang="ts" setup>
|
|
34
|
+
import { vClickOutside } from 'maz-ui/directives'
|
|
35
|
+
import { ref } from 'vue'
|
|
36
|
+
|
|
37
|
+
const hasClikedOutside = ref(false)
|
|
38
|
+
|
|
39
|
+
function clikedOutside() {
|
|
40
|
+
hasClikedOutside.value = true
|
|
41
|
+
setTimeout(() => hasClikedOutside.value = false, 2000)
|
|
42
|
+
}
|
|
43
|
+
</script>
|
|
44
|
+
|
|
45
|
+
<template>
|
|
46
|
+
<div
|
|
47
|
+
style="padding: 50px; background-color: hsl(var(--maz-background-300));"
|
|
48
|
+
class="flex flex-center rounded"
|
|
49
|
+
>
|
|
50
|
+
<MazCard v-click-outside="clikedOutside">
|
|
51
|
+
Click outside me
|
|
52
|
+
</MazCard>
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<div
|
|
56
|
+
v-if="hasClikedOutside"
|
|
57
|
+
style="padding: 16px; margin-top: 16px; background-color: hsl(var(--maz-success)); color: black;"
|
|
58
|
+
class="flex flex-center rounded"
|
|
59
|
+
>
|
|
60
|
+
You clicked outside
|
|
61
|
+
</div>
|
|
62
|
+
</template>
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
</template>
|
|
66
|
+
</ComponentDemo>
|
|
67
|
+
|
|
68
|
+
## Advanced usage with options
|
|
69
|
+
|
|
70
|
+
The directive can accept an options object to customize its behavior:
|
|
71
|
+
|
|
72
|
+
<ComponentDemo>
|
|
73
|
+
<div
|
|
74
|
+
style="padding: 50px; background-color: hsl(var(--maz-background-300));"
|
|
75
|
+
class="maz-flex maz-flex-center maz-rounded"
|
|
76
|
+
>
|
|
77
|
+
<MazCard v-click-outside="{ callback: clickedOutsideWithIgnore, ignore: ['.ignore-me'] }">
|
|
78
|
+
<div class="maz-p-4">
|
|
79
|
+
<p>Click outside me (but not on the button below)</p>
|
|
80
|
+
<MazBtn class="ignore-me maz-mt-2" color="secondary">
|
|
81
|
+
This button is ignored
|
|
82
|
+
</MazBtn>
|
|
83
|
+
</div>
|
|
84
|
+
</MazCard>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<div
|
|
88
|
+
v-if="hasClickedOutsideWithIgnore"
|
|
89
|
+
style="padding: 16px; margin-top: 16px; background-color: hsl(var(--maz-warning)); color: black;"
|
|
90
|
+
class="maz-flex maz-flex-center maz-rounded"
|
|
91
|
+
>
|
|
92
|
+
You clicked outside (button clicks are ignored)
|
|
93
|
+
</div>
|
|
94
|
+
|
|
95
|
+
<template #code>
|
|
96
|
+
|
|
97
|
+
```vue
|
|
98
|
+
<script lang="ts" setup>
|
|
99
|
+
import { vClickOutside } from 'maz-ui/directives'
|
|
100
|
+
import { ref } from 'vue'
|
|
101
|
+
|
|
102
|
+
const hasClickedOutsideWithIgnore = ref(false)
|
|
103
|
+
|
|
104
|
+
function clickedOutsideWithIgnore() {
|
|
105
|
+
hasClickedOutsideWithIgnore.value = true
|
|
106
|
+
setTimeout(() => hasClickedOutsideWithIgnore.value = false, 2000)
|
|
107
|
+
}
|
|
108
|
+
</script>
|
|
109
|
+
|
|
110
|
+
<template>
|
|
111
|
+
<MazCard v-click-outside="{ callback: clickedOutsideWithIgnore, ignore: ['.ignore-me'] }">
|
|
112
|
+
<div class="p-4">
|
|
113
|
+
<p>Click outside me (but not on the button below)</p>
|
|
114
|
+
<MazBtn class="ignore-me mt-2" color="secondary">
|
|
115
|
+
This button is ignored
|
|
116
|
+
</MazBtn>
|
|
117
|
+
</div>
|
|
118
|
+
</MazCard>
|
|
119
|
+
</template>
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
</template>
|
|
123
|
+
</ComponentDemo>
|
|
124
|
+
|
|
125
|
+
## Using the `once` option
|
|
126
|
+
|
|
127
|
+
The directive can be configured to trigger only once:
|
|
128
|
+
|
|
129
|
+
<ComponentDemo>
|
|
130
|
+
<div
|
|
131
|
+
style="padding: 50px; background-color: hsl(var(--maz-background-300));"
|
|
132
|
+
class="maz-flex maz-flex-center maz-rounded"
|
|
133
|
+
>
|
|
134
|
+
<MazCard v-click-outside="{ callback: clickedOnce, once: true }">
|
|
135
|
+
Click outside me (works only once)
|
|
136
|
+
</MazCard>
|
|
137
|
+
</div>
|
|
138
|
+
|
|
139
|
+
<div
|
|
140
|
+
v-if="hasClickedOnce"
|
|
141
|
+
style="padding: 16px; margin-top: 16px; background-color: hsl(var(--maz-info)); color: white;"
|
|
142
|
+
class="maz-flex maz-flex-center maz-rounded"
|
|
143
|
+
>
|
|
144
|
+
This will only show once!
|
|
145
|
+
</div>
|
|
146
|
+
|
|
147
|
+
<template #code>
|
|
148
|
+
|
|
149
|
+
```vue
|
|
150
|
+
<script lang="ts" setup>
|
|
151
|
+
import { vClickOutside } from 'maz-ui/directives'
|
|
152
|
+
import { ref } from 'vue'
|
|
153
|
+
|
|
154
|
+
const hasClickedOnce = ref(false)
|
|
155
|
+
|
|
156
|
+
function clickedOnce() {
|
|
157
|
+
hasClickedOnce.value = true
|
|
158
|
+
// This callback will only be triggered once
|
|
159
|
+
}
|
|
160
|
+
</script>
|
|
161
|
+
|
|
162
|
+
<template>
|
|
163
|
+
<MazCard v-click-outside="{ callback: clickedOnce, once: true }">
|
|
164
|
+
Click outside me (works only once)
|
|
165
|
+
</MazCard>
|
|
166
|
+
</template>
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
</template>
|
|
170
|
+
</ComponentDemo>
|
|
171
|
+
|
|
172
|
+
## All options combined
|
|
173
|
+
|
|
174
|
+
Here's an example using all available options:
|
|
175
|
+
|
|
176
|
+
```vue
|
|
177
|
+
<script lang="ts" setup>
|
|
178
|
+
import { vClickOutside, type VClickOutsideOptions } from 'maz-ui/directives'
|
|
179
|
+
|
|
180
|
+
const options: VClickOutsideOptions = {
|
|
181
|
+
callback: handleClickOutside,
|
|
182
|
+
ignore: ['.modal', '.tooltip', '.dropdown-menu'],
|
|
183
|
+
capture: true,
|
|
184
|
+
once: false
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function handleClickOutside(event: Event) {
|
|
188
|
+
console.log('Clicked outside!', event)
|
|
189
|
+
}
|
|
190
|
+
</script>
|
|
191
|
+
|
|
192
|
+
<template>
|
|
193
|
+
<div v-click-outside="options">
|
|
194
|
+
<!-- Your content -->
|
|
195
|
+
</div>
|
|
196
|
+
</template>
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## API Reference
|
|
200
|
+
|
|
201
|
+
### Usage Patterns
|
|
202
|
+
|
|
203
|
+
```vue
|
|
204
|
+
<!-- Simple function -->
|
|
205
|
+
<div v-click-outside="myCallback">...</div>
|
|
206
|
+
|
|
207
|
+
<!-- With options object -->
|
|
208
|
+
<div v-click-outside="{ callback: myCallback, ignore: ['.ignore'] }">...</div>
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Options
|
|
212
|
+
|
|
213
|
+
| Option | Type | Default | Description |
|
|
214
|
+
|--------|------|---------|-------------|
|
|
215
|
+
| `callback` | `Function` | `undefined` | **Required.** Function to call when clicking outside |
|
|
216
|
+
| `ignore` | `string[]` | `[]` | Array of CSS selectors to ignore when detecting clicks |
|
|
217
|
+
| `capture` | `boolean` | `false` | Whether to use capture phase for event listening |
|
|
218
|
+
| `once` | `boolean` | `false` | Whether to trigger the callback only once |
|
|
219
|
+
|
|
220
|
+
### Type Definitions
|
|
221
|
+
|
|
222
|
+
```typescript
|
|
223
|
+
interface VClickOutsideOptions {
|
|
224
|
+
callback: (...args: any[]) => any
|
|
225
|
+
ignore?: string[]
|
|
226
|
+
capture?: boolean
|
|
227
|
+
once?: boolean
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
type vClickOutsideBindingValue =
|
|
231
|
+
| ((...args: any[]) => any)
|
|
232
|
+
| VClickOutsideOptions
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## Global install
|
|
236
|
+
|
|
237
|
+
### Vue
|
|
238
|
+
|
|
239
|
+
```typescript
|
|
240
|
+
import { vClickOutsideInstall } from 'maz-ui/directives'
|
|
241
|
+
import { createApp } from 'vue'
|
|
242
|
+
|
|
243
|
+
const app = createApp(App)
|
|
244
|
+
|
|
245
|
+
app.use(vClickOutsideInstall)
|
|
246
|
+
|
|
247
|
+
app.mount('#app')
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Nuxt
|
|
251
|
+
|
|
252
|
+
Please refer to the [Nuxt module documentation](./../guide/nuxt.md) for more information.
|
|
253
|
+
|
|
254
|
+
<script lang="ts" setup>
|
|
255
|
+
import { ref } from 'vue'
|
|
256
|
+
import { vClickOutside } from 'maz-ui/src/directives/vClickOutside'
|
|
257
|
+
|
|
258
|
+
const hasClikedOutside = ref(false)
|
|
259
|
+
const hasClickedOutsideWithIgnore = ref(false)
|
|
260
|
+
const hasClickedOnce = ref(false)
|
|
261
|
+
|
|
262
|
+
const clikedOutside = () => {
|
|
263
|
+
hasClikedOutside.value = true
|
|
264
|
+
setTimeout(() => hasClikedOutside.value = false, 2000)
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const clickedOutsideWithIgnore = () => {
|
|
268
|
+
hasClickedOutsideWithIgnore.value = true
|
|
269
|
+
setTimeout(() => hasClickedOutsideWithIgnore.value = false, 2000)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const clickedOnce = () => {
|
|
273
|
+
hasClickedOnce.value = true
|
|
274
|
+
}
|
|
275
|
+
</script>
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: v-fullscreen-img
|
|
3
|
+
description: Displays images fullscreen on click
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# {{ $frontmatter.title }}
|
|
8
|
+
|
|
9
|
+
{{ $frontmatter.description }}
|
|
10
|
+
|
|
11
|
+
## Basic usage
|
|
12
|
+
|
|
13
|
+
<img
|
|
14
|
+
v-fullscreen-img
|
|
15
|
+
src="https://loremflickr.com/1000/500"
|
|
16
|
+
/>
|
|
17
|
+
|
|
18
|
+
```vue
|
|
19
|
+
<template>
|
|
20
|
+
<img
|
|
21
|
+
v-fullscreen-img
|
|
22
|
+
src="https://loremflickr.com/1000/500"
|
|
23
|
+
/>
|
|
24
|
+
</template>
|
|
25
|
+
|
|
26
|
+
<script setup lang="ts">
|
|
27
|
+
import { vFullscreenImg } from 'maz-ui/directives/vFullscreenImg'
|
|
28
|
+
</script>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## With animate options
|
|
32
|
+
|
|
33
|
+
<img
|
|
34
|
+
v-fullscreen-img="{
|
|
35
|
+
scaleOnHover: true,
|
|
36
|
+
blurOnHover: true,
|
|
37
|
+
}"
|
|
38
|
+
src="https://loremflickr.com/1000/600"
|
|
39
|
+
/>
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<img
|
|
43
|
+
v-fullscreen-img="{
|
|
44
|
+
scaleOnHover: true,
|
|
45
|
+
blurOnHover: true,
|
|
46
|
+
}"
|
|
47
|
+
src="https://loremflickr.com/1000/600"
|
|
48
|
+
/>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## On custom element
|
|
52
|
+
|
|
53
|
+
<MazBtn
|
|
54
|
+
v-fullscreen-img="'https://loremflickr.com/1000/700'"
|
|
55
|
+
>
|
|
56
|
+
Click me to show image
|
|
57
|
+
</MazBtn>
|
|
58
|
+
|
|
59
|
+
```html
|
|
60
|
+
<MazBtn
|
|
61
|
+
v-fullscreen-img="'https://loremflickr.com/1000/700'"
|
|
62
|
+
>
|
|
63
|
+
Click me to show image
|
|
64
|
+
</MazBtn>
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Global install
|
|
68
|
+
|
|
69
|
+
### Vue
|
|
70
|
+
|
|
71
|
+
`main.ts`
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import { createApp } from 'vue'
|
|
75
|
+
import { vFullscreenImgInstall } from 'maz-ui/directives/vFullscreenImg'
|
|
76
|
+
|
|
77
|
+
const app = createApp(App)
|
|
78
|
+
|
|
79
|
+
app.use(vFullscreenImgInstall)
|
|
80
|
+
|
|
81
|
+
app.mount('#app')
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Nuxt
|
|
85
|
+
|
|
86
|
+
Please refer to the [Nuxt module documentation](./../guide/nuxt.md) for more information.
|
|
87
|
+
|
|
88
|
+
## Types
|
|
89
|
+
|
|
90
|
+
```ts
|
|
91
|
+
interface vFullscreenImgBindingOptions extends vFullscreenImgOptions {
|
|
92
|
+
src: string
|
|
93
|
+
alt?: string | null
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export type vFullscreenImgBindingValue = string | vFullscreenImgBindingOptions | undefined
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
<script setup lang="ts">
|
|
100
|
+
import { vFullscreenImg } from 'maz-ui/directives/vFullscreenImg'
|
|
101
|
+
</script>
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: vLazyImg
|
|
3
|
+
description: vLazyImg is a Vue 3 directive to lazy load images with many options. The image will be loaded on user's scroll
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
## Basic usage
|
|
11
|
+
|
|
12
|
+
<img
|
|
13
|
+
style="background-color: hsl(var(--maz-background-300)); width: 80%;"
|
|
14
|
+
class="flex flex-center rounded"
|
|
15
|
+
v-lazy-img="'https://loremflickr.com/1500/1000'"
|
|
16
|
+
/>
|
|
17
|
+
|
|
18
|
+
```vue
|
|
19
|
+
<script lang="ts" setup>
|
|
20
|
+
import { vLazyImg } from 'maz-ui/directives'
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<img
|
|
25
|
+
v-lazy-img="'https://loremflickr.com/1500/1000'"
|
|
26
|
+
style="background-color: hsl(var(--maz-background-300)); width: 80%;"
|
|
27
|
+
class="flex flex-center rounded"
|
|
28
|
+
>
|
|
29
|
+
</template>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Use background image
|
|
33
|
+
|
|
34
|
+
> Instead of `v-lazy-img` use `v-lazy-img:bg-image`
|
|
35
|
+
|
|
36
|
+
<div
|
|
37
|
+
style="height: 200px; width: 100%; background-size: contain;"
|
|
38
|
+
class="flex flex-center rounded"
|
|
39
|
+
v-lazy-img:bg-image="'https://loremflickr.com/1500/1000'"
|
|
40
|
+
/>
|
|
41
|
+
|
|
42
|
+
```vue
|
|
43
|
+
<template>
|
|
44
|
+
<div
|
|
45
|
+
v-lazy-img:bg-image="'https://loremflickr.com/1500/1000'"
|
|
46
|
+
style="height: 200px; width: 100%; background-size: contain;"
|
|
47
|
+
class="flex flex-center rounded"
|
|
48
|
+
/>
|
|
49
|
+
</template>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Options
|
|
53
|
+
|
|
54
|
+
> Open the developer console to show logs
|
|
55
|
+
|
|
56
|
+
<img
|
|
57
|
+
style="background-color: hsl(var(--maz-background-300)); width: 80%;"
|
|
58
|
+
class="flex flex-center rounded"
|
|
59
|
+
v-lazy-img="lazyBinding"
|
|
60
|
+
/>
|
|
61
|
+
|
|
62
|
+
```vue
|
|
63
|
+
<script lang="ts" setup>
|
|
64
|
+
import { vLazyImg, vLazyImgBindingValue } from 'maz-ui/directives'
|
|
65
|
+
import { ref } from 'vue'
|
|
66
|
+
|
|
67
|
+
const lazyBinding: vLazyImgBindingValue = {
|
|
68
|
+
src: 'https://loremflickr.com/1500/1000',
|
|
69
|
+
baseClass: 'custom-class',
|
|
70
|
+
loadingClass: 'custom-class-loading',
|
|
71
|
+
loadedClass: 'custom-class-loaded',
|
|
72
|
+
errorClass: 'custom-class-error',
|
|
73
|
+
fallbackClass: 'custom-class-fallback',
|
|
74
|
+
observerOnce: false, // launch onIntersecting function each times where the user scrolls on the image
|
|
75
|
+
loadOnce: false,
|
|
76
|
+
onLoading: (el: Element) => console.log('loading', el),
|
|
77
|
+
onLoaded: (el: Element) => console.log('loaded', el),
|
|
78
|
+
onError: (el: Element) => console.log('error', el),
|
|
79
|
+
onIntersecting: (el: Element) => console.log('intersecting', el),
|
|
80
|
+
}
|
|
81
|
+
</script>
|
|
82
|
+
|
|
83
|
+
<template>
|
|
84
|
+
<img
|
|
85
|
+
v-lazy-img="lazyBinding"
|
|
86
|
+
style="background-color: hsl(var(--maz-background-300)); width: 80%;"
|
|
87
|
+
class="flex flex-center rounded"
|
|
88
|
+
>
|
|
89
|
+
</template>
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Global install
|
|
93
|
+
|
|
94
|
+
### Vue
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
import errorPhoto from 'path/to/error-photo.png'
|
|
98
|
+
import { vLazyImgInstall, type vLazyImgOptions } from 'maz-ui/directives'
|
|
99
|
+
import { createApp } from 'vue'
|
|
100
|
+
|
|
101
|
+
const app = createApp(App)
|
|
102
|
+
|
|
103
|
+
// all options (optional)
|
|
104
|
+
const vLazyImgOptions: vLazyImgOptions = {
|
|
105
|
+
baseClass: 'm-lazy-img',
|
|
106
|
+
loadedClass: 'm-lazy-loaded',
|
|
107
|
+
loadingClass: 'm-lazy-loading',
|
|
108
|
+
errorClass: 'm-lazy-error',
|
|
109
|
+
fallbackClass: 'm-lazy-fallback',
|
|
110
|
+
observerOnce: true,
|
|
111
|
+
loadOnce: true,
|
|
112
|
+
noUseErrorPhoto: false,
|
|
113
|
+
observerOptions: {
|
|
114
|
+
root: undefined,
|
|
115
|
+
rootMargin: undefined,
|
|
116
|
+
threshold: 0.1,
|
|
117
|
+
},
|
|
118
|
+
errorPhoto,
|
|
119
|
+
onLoading: (el: Element) => console.log('loading', el),
|
|
120
|
+
onLoaded: (el: Element) => console.log('loaded', el),
|
|
121
|
+
onError: (el: Element) => console.log('error', el),
|
|
122
|
+
onIntersecting: (el: Element) => console.log('intersecting', el),
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
app.use(vLazyImgInstall, vLazyImgOptions)
|
|
126
|
+
|
|
127
|
+
app.mount('#app')
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Nuxt
|
|
131
|
+
|
|
132
|
+
Please refer to the [Nuxt module documentation](./../guide/nuxt.md) for more information.
|
|
133
|
+
|
|
134
|
+
## Types
|
|
135
|
+
|
|
136
|
+
```ts
|
|
137
|
+
export interface vLazyImgOptions {
|
|
138
|
+
baseClass?: string
|
|
139
|
+
loadingClass?: string
|
|
140
|
+
loadedClass?: string
|
|
141
|
+
errorClass?: string
|
|
142
|
+
fallbackClass?: string
|
|
143
|
+
observerOnce?: boolean
|
|
144
|
+
loadOnce?: boolean
|
|
145
|
+
observerOptions?: {
|
|
146
|
+
root?: HTMLElement | null
|
|
147
|
+
threshold: number
|
|
148
|
+
rootMargin?: string
|
|
149
|
+
}
|
|
150
|
+
fallbackSrc?: string
|
|
151
|
+
onLoading?: (el: Element) => unknown
|
|
152
|
+
onLoaded?: (el: Element) => unknown
|
|
153
|
+
onError?: (el: Element) => unknown
|
|
154
|
+
onIntersecting?: (el: Element) => unknown
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
interface vLazyImgBindingOptions extends vLazyImgOptions {
|
|
158
|
+
src?: string
|
|
159
|
+
disabled?: boolean
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export type vLazyImgBindingValue = string | vLazyImgBindingOptions
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
<script lang="ts" setup>
|
|
166
|
+
import { vLazyImg, type vLazyImgBindingValue } from 'maz-ui/src/directives/vLazyImg'
|
|
167
|
+
import { ref } from 'vue'
|
|
168
|
+
|
|
169
|
+
const lazyBinding: vLazyImgBindingValue = {
|
|
170
|
+
src: 'https://loremflickr.com/1500/1000',
|
|
171
|
+
baseClass: 'custom-class',
|
|
172
|
+
loadingClass: 'custom-class-loading',
|
|
173
|
+
loadedClass: 'custom-class-loaded',
|
|
174
|
+
errorClass: 'custom-class-error',
|
|
175
|
+
fallbackClass: 'custom-class-fallback',
|
|
176
|
+
noUseErrorPhoto: true,
|
|
177
|
+
observerOnce: false,
|
|
178
|
+
loadOnce: true,
|
|
179
|
+
onLoading: (el: Element) => console.log('loading', el),
|
|
180
|
+
onLoaded: (el: Element) => console.log('loaded', el),
|
|
181
|
+
onError: (el: Element) => console.log('error', el),
|
|
182
|
+
onIntersecting: (el: Element) => console.log('intersecting', el),
|
|
183
|
+
}
|
|
184
|
+
</script>
|