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,182 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "vLazyImg"
|
|
3
|
+
description: "vLazyImg is a Vue directive to lazy load images with many options. Images are loaded when they enter the viewport, using a shared IntersectionObserver for optimal performance."
|
|
4
|
+
package: "maz-ui"
|
|
5
|
+
url: "https://maz-ui.com/directives/lazy-img"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# vLazyImg
|
|
9
|
+
|
|
10
|
+
> vLazyImg is a Vue directive to lazy load images with many options. Images are loaded when they enter the viewport, using a shared IntersectionObserver for optimal performance.
|
|
11
|
+
|
|
12
|
+
- Package: `maz-ui`
|
|
13
|
+
- Import: `import { vLazyImg } from 'maz-ui/directives/vLazyImg'`
|
|
14
|
+
- Web: https://maz-ui.com/directives/lazy-img
|
|
15
|
+
|
|
16
|
+
**Tip: Performance**
|
|
17
|
+
|
|
18
|
+
Every element bound to the directive shares a pooled `IntersectionObserver` (grouped by observer options) and keeps its state per element. You can render hundreds of lazy images - like a list of [`MazAvatar`](../components/maz-avatar.md) - with only a handful of observers and no leak when elements unmount.
|
|
19
|
+
|
|
20
|
+
## Basic usage
|
|
21
|
+
|
|
22
|
+
```vue
|
|
23
|
+
<script lang="ts" setup>
|
|
24
|
+
import { vLazyImg } from 'maz-ui/directives'
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<template>
|
|
28
|
+
<img
|
|
29
|
+
v-lazy-img="'https://placedog.net/1500/1000'"
|
|
30
|
+
style="background-color: var(--maz-surface-300); width: 80%;"
|
|
31
|
+
class="flex flex-center rounded"
|
|
32
|
+
>
|
|
33
|
+
</template>
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Use background image
|
|
37
|
+
|
|
38
|
+
> Instead of `v-lazy-img` use `v-lazy-img:bg-image`
|
|
39
|
+
|
|
40
|
+
```vue
|
|
41
|
+
<template>
|
|
42
|
+
<div
|
|
43
|
+
v-lazy-img:bg-image="'https://placedog.net/1500/1000'"
|
|
44
|
+
style="height: 200px; width: 100%; background-size: contain;"
|
|
45
|
+
class="flex flex-center rounded"
|
|
46
|
+
/>
|
|
47
|
+
</template>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Disable lazy loading
|
|
51
|
+
|
|
52
|
+
Set `disabled: true` to load the image immediately, bypassing the `IntersectionObserver`. Useful for above-the-fold images or server-side rendering.
|
|
53
|
+
|
|
54
|
+
```vue
|
|
55
|
+
<template>
|
|
56
|
+
<img
|
|
57
|
+
v-lazy-img="{ src: 'https://placedog.net/1500/1000', disabled: true }"
|
|
58
|
+
>
|
|
59
|
+
</template>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Fallback image on error
|
|
63
|
+
|
|
64
|
+
Provide a `fallbackSrc` to replace the image when it fails to load. Set `fallbackSrc: false` to keep the broken image instead of loading the default placeholder.
|
|
65
|
+
|
|
66
|
+
```vue
|
|
67
|
+
<template>
|
|
68
|
+
<img
|
|
69
|
+
v-lazy-img="{
|
|
70
|
+
src: 'https://broken-link.example',
|
|
71
|
+
fallbackSrc: '/images/fallback.png',
|
|
72
|
+
}"
|
|
73
|
+
>
|
|
74
|
+
</template>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Options
|
|
78
|
+
|
|
79
|
+
> Open the developer console to show logs
|
|
80
|
+
|
|
81
|
+
```vue
|
|
82
|
+
<script lang="ts" setup>
|
|
83
|
+
import { vLazyImg, type vLazyImgBindingValue } from 'maz-ui/directives'
|
|
84
|
+
|
|
85
|
+
const lazyBinding: vLazyImgBindingValue = {
|
|
86
|
+
src: 'https://placedog.net/1500/1000',
|
|
87
|
+
baseClass: 'custom-class',
|
|
88
|
+
loadingClass: 'custom-class-loading',
|
|
89
|
+
loadedClass: 'custom-class-loaded',
|
|
90
|
+
errorClass: 'custom-class-error',
|
|
91
|
+
fallbackClass: 'custom-class-fallback',
|
|
92
|
+
observerOnce: false, // run onIntersecting each time the user scrolls onto the image
|
|
93
|
+
loadOnce: false,
|
|
94
|
+
onLoading: (el: Element) => console.log('loading', el),
|
|
95
|
+
onLoaded: (el: Element) => console.log('loaded', el),
|
|
96
|
+
onError: (el: Element) => console.log('error', el),
|
|
97
|
+
onIntersecting: (el: Element) => console.log('intersecting', el),
|
|
98
|
+
}
|
|
99
|
+
</script>
|
|
100
|
+
|
|
101
|
+
<template>
|
|
102
|
+
<img
|
|
103
|
+
v-lazy-img="lazyBinding"
|
|
104
|
+
style="background-color: var(--maz-surface-300); width: 80%;"
|
|
105
|
+
class="flex flex-center rounded"
|
|
106
|
+
>
|
|
107
|
+
</template>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Global install
|
|
111
|
+
|
|
112
|
+
### Vue
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
import { vLazyImgInstall, type vLazyImgOptions } from 'maz-ui/directives'
|
|
116
|
+
import { createApp } from 'vue'
|
|
117
|
+
|
|
118
|
+
const app = createApp(App)
|
|
119
|
+
|
|
120
|
+
// all options (optional)
|
|
121
|
+
const vLazyImgOptions: vLazyImgOptions = {
|
|
122
|
+
baseClass: 'm-lazy-img',
|
|
123
|
+
loadedClass: 'm-lazy-loaded',
|
|
124
|
+
loadingClass: 'm-lazy-loading',
|
|
125
|
+
errorClass: 'm-lazy-error',
|
|
126
|
+
fallbackClass: 'm-lazy-fallback',
|
|
127
|
+
observerOnce: true,
|
|
128
|
+
loadOnce: true,
|
|
129
|
+
observerOptions: {
|
|
130
|
+
root: undefined,
|
|
131
|
+
rootMargin: undefined,
|
|
132
|
+
threshold: 0.1,
|
|
133
|
+
},
|
|
134
|
+
fallbackSrc: '/images/fallback.png', // or `false` to disable the default placeholder
|
|
135
|
+
onLoading: (el: Element) => console.log('loading', el),
|
|
136
|
+
onLoaded: (el: Element) => console.log('loaded', el),
|
|
137
|
+
onError: (el: Element) => console.log('error', el),
|
|
138
|
+
onIntersecting: (el: Element) => console.log('intersecting', el),
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
app.use(vLazyImgInstall, vLazyImgOptions)
|
|
142
|
+
|
|
143
|
+
app.mount('#app')
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### Nuxt
|
|
147
|
+
|
|
148
|
+
Please refer to the [Nuxt module documentation](../ecosystem/nuxt.md) for more information.
|
|
149
|
+
|
|
150
|
+
## Types
|
|
151
|
+
|
|
152
|
+
```ts
|
|
153
|
+
export interface vLazyImgOptions {
|
|
154
|
+
baseClass?: string
|
|
155
|
+
loadingClass?: string
|
|
156
|
+
loadedClass?: string
|
|
157
|
+
errorClass?: string
|
|
158
|
+
fallbackClass?: string
|
|
159
|
+
observerOnce?: boolean
|
|
160
|
+
loadOnce?: boolean
|
|
161
|
+
observerOptions?: {
|
|
162
|
+
root?: HTMLElement | null
|
|
163
|
+
threshold: number
|
|
164
|
+
rootMargin?: string
|
|
165
|
+
}
|
|
166
|
+
/** Image loaded on error - set to `false` to keep the broken image */
|
|
167
|
+
fallbackSrc?: string | false
|
|
168
|
+
onLoading?: (el: Element) => unknown
|
|
169
|
+
onLoaded?: (el: Element) => unknown
|
|
170
|
+
onError?: (el: Element) => unknown
|
|
171
|
+
onIntersecting?: (el: Element) => unknown
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
interface vLazyImgBindingOptions extends vLazyImgOptions {
|
|
175
|
+
/** The source of the image when the binding value is an options object */
|
|
176
|
+
src?: string
|
|
177
|
+
/** Load the image immediately, bypassing the IntersectionObserver */
|
|
178
|
+
disabled?: boolean
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export type vLazyImgBindingValue = string | vLazyImgBindingOptions
|
|
182
|
+
```
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "vTooltip"
|
|
3
|
+
description: "vTooltip is a Vue directive to display a text when the user hovers an element"
|
|
4
|
+
package: "maz-ui"
|
|
5
|
+
url: "https://maz-ui.com/directives/tooltip"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# vTooltip
|
|
9
|
+
|
|
10
|
+
> vTooltip is a Vue directive to display a text when the user hovers an element
|
|
11
|
+
|
|
12
|
+
- Package: `maz-ui`
|
|
13
|
+
- Import: `import { vTooltip } from 'maz-ui/directives/vTooltip'`
|
|
14
|
+
- Web: https://maz-ui.com/directives/tooltip
|
|
15
|
+
|
|
16
|
+
## Basic usage
|
|
17
|
+
|
|
18
|
+
```vue
|
|
19
|
+
<script lang="ts" setup>
|
|
20
|
+
import { vTooltip } from 'maz-ui/directives'
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<template>
|
|
24
|
+
<MazBtn v-tooltip="'This is a top tooltip'">
|
|
25
|
+
Top
|
|
26
|
+
</MazBtn>
|
|
27
|
+
<MazBtn v-tooltip.right="'This is a top tooltip'">
|
|
28
|
+
Right
|
|
29
|
+
</MazBtn>
|
|
30
|
+
<MazBtn v-tooltip.left="'This is a top tooltip'">
|
|
31
|
+
Left
|
|
32
|
+
</MazBtn>
|
|
33
|
+
<MazBtn v-tooltip.bottom="'This is a top tooltip'">
|
|
34
|
+
Bottom
|
|
35
|
+
</MazBtn>
|
|
36
|
+
</template>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Colors
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
<MazBtn v-tooltip="{ text: 'Tooltip text', color: 'primary' }">
|
|
43
|
+
Primary
|
|
44
|
+
</MazBtn>
|
|
45
|
+
|
|
46
|
+
<MazBtn v-tooltip="{ text: 'Tooltip text', color: 'secondary' }" color="secondary">
|
|
47
|
+
Secondary
|
|
48
|
+
</MazBtn>
|
|
49
|
+
|
|
50
|
+
<MazBtn v-tooltip="{ text: 'Tooltip text', color: 'success' }" color="success">
|
|
51
|
+
Success
|
|
52
|
+
</MazBtn>
|
|
53
|
+
|
|
54
|
+
<MazBtn v-tooltip="{ text: 'Tooltip text', color: 'warning' }" color="warning">
|
|
55
|
+
Warning
|
|
56
|
+
</MazBtn>
|
|
57
|
+
|
|
58
|
+
<MazBtn v-tooltip="{ text: 'Tooltip text', color: 'destructive' }" color="destructive">
|
|
59
|
+
destructive
|
|
60
|
+
</MazBtn>
|
|
61
|
+
|
|
62
|
+
<MazBtn v-tooltip="{ text: 'Tooltip text', color: 'info' }" color="info">
|
|
63
|
+
Info
|
|
64
|
+
</MazBtn>
|
|
65
|
+
|
|
66
|
+
<MazBtn v-tooltip="{ text: 'Tooltip text', color: 'accent' }" color="accent">
|
|
67
|
+
Accent
|
|
68
|
+
</MazBtn>
|
|
69
|
+
|
|
70
|
+
<MazBtn v-tooltip="{ text: 'Tooltip text', color: 'contrast' }" color="contrast">
|
|
71
|
+
Contrast
|
|
72
|
+
</MazBtn>
|
|
73
|
+
|
|
74
|
+
<MazBtn v-tooltip="{ text: 'Tooltip text', color: 'default' }" color="surface">
|
|
75
|
+
Background
|
|
76
|
+
</MazBtn>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Position
|
|
80
|
+
|
|
81
|
+
You can change the position of the tooltip by passing a `position` option or using the directive modifier (e.g. `v-tooltip.top`).
|
|
82
|
+
|
|
83
|
+
```html
|
|
84
|
+
<MazBtn v-tooltip.bottom="{ text: 'Tooltip text' }">
|
|
85
|
+
Bottom
|
|
86
|
+
</MazBtn>
|
|
87
|
+
|
|
88
|
+
<MazBtn v-tooltip.left="{ text: 'Tooltip text' }">
|
|
89
|
+
Left
|
|
90
|
+
</MazBtn>
|
|
91
|
+
|
|
92
|
+
<MazBtn v-tooltip.right="{ text: 'Tooltip text' }">
|
|
93
|
+
Right
|
|
94
|
+
</MazBtn>
|
|
95
|
+
|
|
96
|
+
<MazBtn v-tooltip.top="{ text: 'Tooltip text' }">
|
|
97
|
+
Top
|
|
98
|
+
</MazBtn>
|
|
99
|
+
|
|
100
|
+
<MazBtn v-tooltip.top-start="{ text: 'Tooltip text' }">
|
|
101
|
+
Top start
|
|
102
|
+
</MazBtn>
|
|
103
|
+
|
|
104
|
+
<MazBtn v-tooltip.top-end="{ text: 'Tooltip text' }">
|
|
105
|
+
Top end
|
|
106
|
+
</MazBtn>
|
|
107
|
+
|
|
108
|
+
<MazBtn v-tooltip.bottom-start="{ text: 'Tooltip text' }">
|
|
109
|
+
Bottom start
|
|
110
|
+
</MazBtn>
|
|
111
|
+
|
|
112
|
+
<MazBtn v-tooltip.bottom-end="{ text: 'Tooltip text' }">
|
|
113
|
+
Bottom end
|
|
114
|
+
</MazBtn>
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## HTML content
|
|
118
|
+
|
|
119
|
+
You can also use HTML content in the tooltip by passing a string to the `html` option.
|
|
120
|
+
|
|
121
|
+
```html
|
|
122
|
+
<MazBtn v-tooltip="{ html: '<strong>Tooltip</strong> text <br> with <br> line breaks' }">
|
|
123
|
+
HTML
|
|
124
|
+
</MazBtn>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Customization
|
|
128
|
+
|
|
129
|
+
You can customize the tooltip by passing a `panelClass` or `panelStyle` option.
|
|
130
|
+
|
|
131
|
+
```html
|
|
132
|
+
<MazBtn v-tooltip="{ text: 'Custom panel class', panelClass: 'text-red-500!' }">
|
|
133
|
+
panelClass
|
|
134
|
+
</MazBtn>
|
|
135
|
+
<MazBtn v-tooltip="{ text: 'Custom panel style', panelStyle: 'background-color: red; color: white;' }">
|
|
136
|
+
panelStyle
|
|
137
|
+
</MazBtn>
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
## Trigger
|
|
141
|
+
|
|
142
|
+
You can change the trigger mode of the tooltip by passing a `trigger` option.
|
|
143
|
+
|
|
144
|
+
The default trigger is `hover`.
|
|
145
|
+
|
|
146
|
+
The `adaptive` trigger will use the `click` trigger on touch devices (mobile and tablet) and the `hover` trigger on non-touch devices (desktop).
|
|
147
|
+
|
|
148
|
+
```html
|
|
149
|
+
<MazBtn v-tooltip="{ text: 'Tooltip text', trigger: 'click' }">
|
|
150
|
+
Click
|
|
151
|
+
</MazBtn>
|
|
152
|
+
|
|
153
|
+
<MazBtn v-tooltip="{ text: 'Tooltip text', trigger: 'hover' }">
|
|
154
|
+
Hover
|
|
155
|
+
</MazBtn>
|
|
156
|
+
|
|
157
|
+
<MazBtn v-tooltip="{ text: 'Tooltip text', trigger: 'adaptive' }">
|
|
158
|
+
Adaptive
|
|
159
|
+
</MazBtn>
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Offset
|
|
163
|
+
|
|
164
|
+
The `offset` (in px) option allows you to adjust the position of the tooltip relative to the original element.
|
|
165
|
+
|
|
166
|
+
```html
|
|
167
|
+
<MazBtn v-tooltip="{ text: 'Tooltip text', offset: 0 }">
|
|
168
|
+
0
|
|
169
|
+
</MazBtn>
|
|
170
|
+
|
|
171
|
+
<MazBtn v-tooltip="{ text: 'Tooltip text', offset: 10 }">
|
|
172
|
+
10
|
|
173
|
+
</MazBtn>
|
|
174
|
+
|
|
175
|
+
<MazBtn v-tooltip="{ text: 'Tooltip text', offset: 20 }">
|
|
176
|
+
20
|
|
177
|
+
</MazBtn>
|
|
178
|
+
|
|
179
|
+
<MazBtn v-tooltip="{ text: 'Tooltip text', offset: 40 }">
|
|
180
|
+
40
|
|
181
|
+
</MazBtn>
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Open programmatically
|
|
185
|
+
|
|
186
|
+
```vue
|
|
187
|
+
<script lang="ts" setup>
|
|
188
|
+
import { vTooltip } from 'maz-ui/directives'
|
|
189
|
+
import { ref } from 'vue'
|
|
190
|
+
|
|
191
|
+
const open = ref(true)
|
|
192
|
+
</script>
|
|
193
|
+
|
|
194
|
+
<template>
|
|
195
|
+
<MazBtn v-tooltip.top="{ text: 'Tooltip text', open: open }">
|
|
196
|
+
Primary
|
|
197
|
+
</MazBtn>
|
|
198
|
+
<MazBtn color="secondary" @click="open = !open">
|
|
199
|
+
Toggle tooltip
|
|
200
|
+
</MazBtn>
|
|
201
|
+
</template>
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
## Conditionally disable
|
|
205
|
+
|
|
206
|
+
Pass `false`, `null` or `undefined` as the binding value to silently disable the tooltip - no popover instance is created, no listeners are attached, and no warning is logged. This is the recommended way to skip the tooltip on the fly without conditionally rendering two different elements:
|
|
207
|
+
|
|
208
|
+
```vue
|
|
209
|
+
<script lang="ts" setup>
|
|
210
|
+
import { vTooltip } from 'maz-ui/directives'
|
|
211
|
+
import { computed, ref } from 'vue'
|
|
212
|
+
|
|
213
|
+
const label = ref<string>('')
|
|
214
|
+
const tooltipBinding = computed(() => label.value ? { text: label.value } : false)
|
|
215
|
+
</script>
|
|
216
|
+
|
|
217
|
+
<template>
|
|
218
|
+
<!-- When label is empty the directive becomes a no-op -->
|
|
219
|
+
<MazBtn v-tooltip="tooltipBinding">
|
|
220
|
+
Hover me
|
|
221
|
+
</MazBtn>
|
|
222
|
+
</template>
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
If the binding switches back to a valid value later, the tooltip mounts as expected. Toggling the value off again destroys the existing popover instance.
|
|
226
|
+
|
|
227
|
+
## Global install
|
|
228
|
+
|
|
229
|
+
### Vue
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
import { vTooltipInstall } from 'maz-ui/directives'
|
|
233
|
+
import { createApp } from 'vue'
|
|
234
|
+
|
|
235
|
+
const app = createApp(App)
|
|
236
|
+
|
|
237
|
+
// Options are optional
|
|
238
|
+
app.use(vTooltipInstall, {
|
|
239
|
+
position: 'top',
|
|
240
|
+
color: 'primary',
|
|
241
|
+
})
|
|
242
|
+
|
|
243
|
+
app.mount('#app')
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
### Nuxt
|
|
247
|
+
|
|
248
|
+
Please refer to the [Nuxt module documentation](../ecosystem/nuxt.md) for more information.
|
|
249
|
+
|
|
250
|
+
## Types
|
|
251
|
+
|
|
252
|
+
```ts
|
|
253
|
+
interface VTooltipOptions extends Partial<Omit<MazPopoverProps, 'modelValue'>> {
|
|
254
|
+
/**
|
|
255
|
+
* Text to display in the tooltip
|
|
256
|
+
*/
|
|
257
|
+
text?: string
|
|
258
|
+
/**
|
|
259
|
+
* HTML content (alternative to text)
|
|
260
|
+
*/
|
|
261
|
+
html?: string
|
|
262
|
+
/**
|
|
263
|
+
* Color variant of the tooltip
|
|
264
|
+
* @default default
|
|
265
|
+
*/
|
|
266
|
+
color?: MazPopoverProps['color']
|
|
267
|
+
/**
|
|
268
|
+
* Position of the tooltip
|
|
269
|
+
* @default top
|
|
270
|
+
*/
|
|
271
|
+
position?: PopoverPosition
|
|
272
|
+
/**
|
|
273
|
+
* Trigger of the tooltip
|
|
274
|
+
* @default hover
|
|
275
|
+
*/
|
|
276
|
+
trigger?: MazPopoverTrigger
|
|
277
|
+
/**
|
|
278
|
+
* Close on click outside
|
|
279
|
+
* @default false
|
|
280
|
+
*/
|
|
281
|
+
closeOnClickOutside?: boolean
|
|
282
|
+
/**
|
|
283
|
+
* Close on escape
|
|
284
|
+
* @default false
|
|
285
|
+
*/
|
|
286
|
+
closeOnEscape?: boolean
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* Open the tooltip
|
|
290
|
+
* @default false
|
|
291
|
+
*/
|
|
292
|
+
open?: boolean
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
type VTooltipBindingValue
|
|
296
|
+
= | string
|
|
297
|
+
| VTooltipOptions
|
|
298
|
+
```
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "vZoomImg"
|
|
3
|
+
description: "vZoomImg is a Vue directive to enlarge an image like a modal on click, if you have several images, you can pass them like a carousel"
|
|
4
|
+
package: "maz-ui"
|
|
5
|
+
url: "https://maz-ui.com/directives/zoom-img"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# vZoomImg
|
|
9
|
+
|
|
10
|
+
> vZoomImg is a Vue directive to enlarge an image like a modal on click, if you have several images, you can pass them like a carousel
|
|
11
|
+
|
|
12
|
+
- Package: `maz-ui`
|
|
13
|
+
- Import: `import { vZoomImg } from 'maz-ui/directives/vZoomImg'`
|
|
14
|
+
- Web: https://maz-ui.com/directives/zoom-img
|
|
15
|
+
|
|
16
|
+
> Can be mixed with [vLazyImg](./lazy-img.md) directive
|
|
17
|
+
|
|
18
|
+
## Basic usage
|
|
19
|
+
|
|
20
|
+
> Click on the photo
|
|
21
|
+
|
|
22
|
+
```vue
|
|
23
|
+
<script lang="ts" setup>
|
|
24
|
+
import { vZoomImg } from 'maz-ui/directives'
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
<template>
|
|
28
|
+
<MazCard overflow-hidden>
|
|
29
|
+
<img
|
|
30
|
+
v-zoom-img="{ src: 'https://placedog.net/1500/1000' }"
|
|
31
|
+
src="https://placedog.net/1500/1000"
|
|
32
|
+
>
|
|
33
|
+
</MazCard>
|
|
34
|
+
|
|
35
|
+
<MazBtn v-zoom-img="{ src: 'https://placedog.net/1000/500' }">
|
|
36
|
+
Show photo
|
|
37
|
+
</MazBtn>
|
|
38
|
+
</template>
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Options
|
|
42
|
+
|
|
43
|
+
```vue
|
|
44
|
+
<script lang="ts" setup>
|
|
45
|
+
import { vZoomImg, type vZoomImgBindingValue } from 'maz-ui/directives'
|
|
46
|
+
|
|
47
|
+
const zoomImgBinding: vZoomImgBindingValue = {
|
|
48
|
+
src: 'https://placedog.net/1200/800',
|
|
49
|
+
alt: 'alt image', // will be set on the zoomed image
|
|
50
|
+
blur: false,
|
|
51
|
+
scale: false,
|
|
52
|
+
disabled: false
|
|
53
|
+
}
|
|
54
|
+
</script>
|
|
55
|
+
|
|
56
|
+
<template>
|
|
57
|
+
<MazCard overflow-hidden>
|
|
58
|
+
<img
|
|
59
|
+
v-zoom-img="zoomImgBinding"
|
|
60
|
+
src="https://placedog.net/1200/800"
|
|
61
|
+
>
|
|
62
|
+
</MazCard>
|
|
63
|
+
</template>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Global install
|
|
67
|
+
|
|
68
|
+
### Vue
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
import { vZoomImgInstall, type vZoomImgOptions } from 'maz-ui/directives'
|
|
72
|
+
import { createApp } from 'vue'
|
|
73
|
+
|
|
74
|
+
const app = createApp(App)
|
|
75
|
+
|
|
76
|
+
app.use(vZoomImgInstall)
|
|
77
|
+
|
|
78
|
+
app.mount('#app')
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Nuxt
|
|
82
|
+
|
|
83
|
+
Please refer to the [Nuxt module documentation](../ecosystem/nuxt.md) for more information.
|
|
84
|
+
|
|
85
|
+
## Types
|
|
86
|
+
|
|
87
|
+
```ts
|
|
88
|
+
export interface vZoomImgOptions {
|
|
89
|
+
disabled?: boolean
|
|
90
|
+
scale?: boolean
|
|
91
|
+
blur?: boolean
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
interface vZoomImgBindingOptions extends vZoomImgOptions {
|
|
95
|
+
src: string
|
|
96
|
+
alt?: string
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export type vZoomImgBindingValue = string | vZoomImgBindingOptions
|
|
100
|
+
```
|