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,104 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "useTimer"
|
|
3
|
+
description: "The useTimer composable manages timeouts. It allows you to start, pause, resume, and stop a timer with reactive updates on the remaining time. Ideal for handling asynchronous operations or user interactions with a specified timeout."
|
|
4
|
+
package: "maz-ui"
|
|
5
|
+
url: "https://maz-ui.com/composables/use-timer"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# useTimer
|
|
9
|
+
|
|
10
|
+
> The useTimer composable manages timeouts. It allows you to start, pause, resume, and stop a timer with reactive updates on the remaining time. Ideal for handling asynchronous operations or user interactions with a specified timeout.
|
|
11
|
+
|
|
12
|
+
- Package: `maz-ui`
|
|
13
|
+
- Import: `import { useTimer } from 'maz-ui/composables/useTimer'`
|
|
14
|
+
- Nuxt: auto-imported by `@maz-ui/nuxt`, no import needed in a Nuxt app
|
|
15
|
+
- Web: https://maz-ui.com/composables/use-timer
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
The composable provides the following functionality:
|
|
20
|
+
|
|
21
|
+
- **start**: Initiates a timer that decrements the remaining time every second until the timeout is reached. When the timeout is reached, it executes the provided callback function.
|
|
22
|
+
- **pause**: Pauses the active timer, allowing it to be resumed later from the point it was paused.
|
|
23
|
+
- **resume**: Resumes the timer from the point it was paused, considering the remaining time.
|
|
24
|
+
- **stop**: Stops the timer completely, resetting the remaining time to the initial timeout value.
|
|
25
|
+
- **remainingTime**: A reactive variable that holds the current remaining time in milliseconds. It updates reactively as the timer progresses.
|
|
26
|
+
|
|
27
|
+
The composable also includes cleanup logic using onBeforeUnmount to ensure that the timer is stopped when the component is unmounted.
|
|
28
|
+
|
|
29
|
+
This composable can be used in Vue components to handle timeouts in a flexible and reactive manner.
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
**Remaning time**: ms
|
|
34
|
+
|
|
35
|
+
```vue
|
|
36
|
+
<script lang="ts" setup>
|
|
37
|
+
import { useTimer, useToast } from 'maz-ui/composables'
|
|
38
|
+
|
|
39
|
+
const toast = useToast()
|
|
40
|
+
|
|
41
|
+
const { start, stop, pause, resume, remainingTime } = useTimer({
|
|
42
|
+
timeout: 4000,
|
|
43
|
+
callback: () => toast.info('Timeout end', {
|
|
44
|
+
button: {
|
|
45
|
+
onClick: start,
|
|
46
|
+
text: 're-start',
|
|
47
|
+
closeToast: true,
|
|
48
|
+
},
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<template>
|
|
54
|
+
<MazBtn @click="start">
|
|
55
|
+
Start
|
|
56
|
+
</MazBtn>
|
|
57
|
+
<MazBtn color="destructive" @click="stop">
|
|
58
|
+
Stop
|
|
59
|
+
</MazBtn>
|
|
60
|
+
<MazBtn color="warning" @click="pause">
|
|
61
|
+
Pause
|
|
62
|
+
</MazBtn>
|
|
63
|
+
<MazBtn color="secondary" @click="resume">
|
|
64
|
+
Resume
|
|
65
|
+
</MazBtn>
|
|
66
|
+
</template>
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Set timeout with start function
|
|
70
|
+
|
|
71
|
+
Starts the timer with the specified timeout. If the timeout is not provided, it uses the default value of 1000ms.
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
const { start } = useTimer()
|
|
75
|
+
|
|
76
|
+
start(4000)
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Types
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
export interface TimerOptions {
|
|
83
|
+
/**
|
|
84
|
+
* The time in milliseconds
|
|
85
|
+
* @default 1000
|
|
86
|
+
*/
|
|
87
|
+
timeout?: number
|
|
88
|
+
/**
|
|
89
|
+
* The callback to execute when the timer is finished
|
|
90
|
+
* @default undefined
|
|
91
|
+
*/
|
|
92
|
+
callback?: () => unknown
|
|
93
|
+
/**
|
|
94
|
+
* The interval to update the remaining time
|
|
95
|
+
* @default 200
|
|
96
|
+
*/
|
|
97
|
+
remainingTimeUpdate?: number
|
|
98
|
+
/**
|
|
99
|
+
* The offset time to execute the callback
|
|
100
|
+
* @default 0
|
|
101
|
+
*/
|
|
102
|
+
callbackOffsetTime?: number
|
|
103
|
+
}
|
|
104
|
+
```
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "useToast"
|
|
3
|
+
description: "Vue composable for handling toast plugin in your components"
|
|
4
|
+
package: "maz-ui"
|
|
5
|
+
url: "https://maz-ui.com/composables/use-toast"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# useToast
|
|
9
|
+
|
|
10
|
+
> Vue composable for handling toast plugin in your components
|
|
11
|
+
|
|
12
|
+
- Package: `maz-ui`
|
|
13
|
+
- Import: `import { useToast } from 'maz-ui/composables/useToast'`
|
|
14
|
+
- Nuxt: auto-imported by `@maz-ui/nuxt` when `mazUi.plugins.toast` is enabled
|
|
15
|
+
- Web: https://maz-ui.com/composables/use-toast
|
|
16
|
+
|
|
17
|
+
**Warning:**
|
|
18
|
+
|
|
19
|
+
You must install [toast plugin](../plugins/toast.md#install) before use it
|
|
20
|
+
|
|
21
|
+
**Tip:**
|
|
22
|
+
|
|
23
|
+
More info about [toast plugin](../plugins/toast.md) in its documentation
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```vue
|
|
28
|
+
<script lang="ts" setup>
|
|
29
|
+
import { useToast } from 'maz-ui/composables'
|
|
30
|
+
|
|
31
|
+
const toast = useToast()
|
|
32
|
+
|
|
33
|
+
toast.info('info message', {
|
|
34
|
+
button: {
|
|
35
|
+
onClick: () => toast.success('clicked'),
|
|
36
|
+
text: 'Click me',
|
|
37
|
+
closeToast: true
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
toast.success('success message', {
|
|
41
|
+
button: {
|
|
42
|
+
href: '/composables/use-toast',
|
|
43
|
+
text: 'Follow me',
|
|
44
|
+
closeToast: true,
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
toast.warning('warning message')
|
|
48
|
+
toast.error('error message')
|
|
49
|
+
</script>
|
|
50
|
+
```
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "user-visibility"
|
|
3
|
+
description: "Plugin to see and manage the user page visibility"
|
|
4
|
+
package: "maz-ui"
|
|
5
|
+
url: "https://maz-ui.com/composables/use-user-visibility"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# user-visibility
|
|
9
|
+
|
|
10
|
+
> Plugin to see and manage the user page visibility
|
|
11
|
+
|
|
12
|
+
- Package: `maz-ui`
|
|
13
|
+
- Import: `import { useUserVisibility } from 'maz-ui/composables/useUserVisibility'`
|
|
14
|
+
- Nuxt: auto-imported by `@maz-ui/nuxt`, no import needed in a Nuxt app
|
|
15
|
+
- Web: https://maz-ui.com/composables/use-user-visibility
|
|
16
|
+
|
|
17
|
+
**Tip:**
|
|
18
|
+
|
|
19
|
+
Useful to know if the user is displaying your website
|
|
20
|
+
|
|
21
|
+
## Demo
|
|
22
|
+
|
|
23
|
+
**Tip:**
|
|
24
|
+
|
|
25
|
+
Switch tabs for a second to see events
|
|
26
|
+
|
|
27
|
+
## How to use it?
|
|
28
|
+
|
|
29
|
+
```vue
|
|
30
|
+
<script lang="ts" setup>
|
|
31
|
+
import { useUserVisibility } from 'maz-ui/composables'
|
|
32
|
+
|
|
33
|
+
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
|
34
|
+
|
|
35
|
+
const events = ref([])
|
|
36
|
+
|
|
37
|
+
function callback({ isVisible }) {
|
|
38
|
+
console.log('isVisible', isVisible)
|
|
39
|
+
events.value.push({ isVisible })
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const options = {
|
|
43
|
+
immediate: true,
|
|
44
|
+
once: false,
|
|
45
|
+
timeout: 1000,
|
|
46
|
+
ssr: true,
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const userVisibility = useUserVisibility({ callback, options })
|
|
50
|
+
|
|
51
|
+
onMounted(() => {
|
|
52
|
+
userVisibility.start()
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
onBeforeUnmount(() => {
|
|
56
|
+
userVisibility.destroy()
|
|
57
|
+
})
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<template>
|
|
61
|
+
<MazBtn color="destructive" @click="userVisibility.destroy()">
|
|
62
|
+
Destroy
|
|
63
|
+
</MazBtn>
|
|
64
|
+
|
|
65
|
+
<MazBtn color="destructive" @click="userVisibility.destroy()">
|
|
66
|
+
Destroy
|
|
67
|
+
</MazBtn>
|
|
68
|
+
|
|
69
|
+
<MazCard overflow-hidden style="width: 100%;">
|
|
70
|
+
<h3>Logs</h3>
|
|
71
|
+
|
|
72
|
+
<div v-for="({ isVisible }, i) in events" :key="i">
|
|
73
|
+
isVisible: {{ isVisible }}
|
|
74
|
+
</div>
|
|
75
|
+
</MazCard>
|
|
76
|
+
</template>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Callback
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
export type UserVisibilyCallback = ({
|
|
83
|
+
isVisible,
|
|
84
|
+
}: {
|
|
85
|
+
isVisible: boolean
|
|
86
|
+
}) => void
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Options
|
|
90
|
+
|
|
91
|
+
```ts
|
|
92
|
+
interface UserVisibilyStrictOptions {
|
|
93
|
+
immediate: boolean
|
|
94
|
+
timeout: number
|
|
95
|
+
once: boolean
|
|
96
|
+
ssr: boolean // if `true`
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Default Options
|
|
101
|
+
|
|
102
|
+
```ts
|
|
103
|
+
const defaultOptions: UserVisibilyOptions = {
|
|
104
|
+
immediate: false,
|
|
105
|
+
timeout: 5000,
|
|
106
|
+
once: false,
|
|
107
|
+
ssr: false,
|
|
108
|
+
}
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## Actions
|
|
112
|
+
|
|
113
|
+
### Start
|
|
114
|
+
|
|
115
|
+
Will start the user visibility tracking
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
userVisibility.start()
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Destroy
|
|
122
|
+
|
|
123
|
+
Will destroy the instance and stop the tracking
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
userVisibility.destroy()
|
|
127
|
+
```
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "useWait"
|
|
3
|
+
description: "Vue composable for handling wait plugins"
|
|
4
|
+
package: "maz-ui"
|
|
5
|
+
url: "https://maz-ui.com/composables/use-wait"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# useWait
|
|
9
|
+
|
|
10
|
+
> Vue composable for handling wait plugins
|
|
11
|
+
|
|
12
|
+
- Package: `maz-ui`
|
|
13
|
+
- Import: `import { useWait } from 'maz-ui/composables/useWait'`
|
|
14
|
+
- Nuxt: auto-imported by `@maz-ui/nuxt` when `mazUi.plugins.wait` is enabled
|
|
15
|
+
- Web: https://maz-ui.com/composables/use-wait
|
|
16
|
+
|
|
17
|
+
**Warning:**
|
|
18
|
+
|
|
19
|
+
You must install the [wait plugin](../plugins/wait.md#install) before using it
|
|
20
|
+
|
|
21
|
+
**Tip:**
|
|
22
|
+
|
|
23
|
+
More info about the [wait plugin](../plugins/wait.md) in its documentation
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
```vue
|
|
28
|
+
<script lang="ts" setup>
|
|
29
|
+
import { sleep } from '@maz-ui/utils'
|
|
30
|
+
import { useWait } from 'maz-ui/composables'
|
|
31
|
+
import { onMounted } from 'vue'
|
|
32
|
+
|
|
33
|
+
const wait = useWait()
|
|
34
|
+
|
|
35
|
+
onMounted(async () => {
|
|
36
|
+
wait.start('MAIN_LOADER')
|
|
37
|
+
await sleep(2000)
|
|
38
|
+
wait.stop('MAIN_LOADER')
|
|
39
|
+
})
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<template>
|
|
43
|
+
<MazFullscreenLoader v-if="wait.isLoading('MAIN_LOADER')">
|
|
44
|
+
Loading
|
|
45
|
+
</MazFullscreenLoader>
|
|
46
|
+
<p v-else>
|
|
47
|
+
Loaded
|
|
48
|
+
</p>
|
|
49
|
+
</template>
|
|
50
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "useWindowSize"
|
|
3
|
+
description: "This composable provides a simple utility to track the width and height of the browser window with reactivity"
|
|
4
|
+
package: "maz-ui"
|
|
5
|
+
url: "https://maz-ui.com/composables/use-window-size"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# useWindowSize
|
|
9
|
+
|
|
10
|
+
> This composable provides a simple utility to track the width and height of the browser window with reactivity
|
|
11
|
+
|
|
12
|
+
- Package: `maz-ui`
|
|
13
|
+
- Import: `import { useWindowSize } from 'maz-ui/composables/useWindowSize'`
|
|
14
|
+
- Nuxt: auto-imported by `@maz-ui/nuxt`, no import needed in a Nuxt app
|
|
15
|
+
- Web: https://maz-ui.com/composables/use-window-size
|
|
16
|
+
|
|
17
|
+
## Basic usage
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
const { height, width } = useWindowSize()
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
**Warning:**
|
|
24
|
+
|
|
25
|
+
More documentation to come
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "vClickOutside"
|
|
3
|
+
description: "vClickOutside is a Vue directive to trigger a function when the user clicks outside an element"
|
|
4
|
+
package: "maz-ui"
|
|
5
|
+
url: "https://maz-ui.com/directives/click-outside"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# vClickOutside
|
|
9
|
+
|
|
10
|
+
> vClickOutside is a Vue directive to trigger a function when the user clicks outside an element
|
|
11
|
+
|
|
12
|
+
- Package: `maz-ui`
|
|
13
|
+
- Import: `import { vClickOutside } from 'maz-ui/directives/vClickOutside'`
|
|
14
|
+
- Web: https://maz-ui.com/directives/click-outside
|
|
15
|
+
|
|
16
|
+
## Basic usage
|
|
17
|
+
|
|
18
|
+
```vue
|
|
19
|
+
<script lang="ts" setup>
|
|
20
|
+
import { vClickOutside } from 'maz-ui/directives'
|
|
21
|
+
import { ref } from 'vue'
|
|
22
|
+
|
|
23
|
+
const hasClikedOutside = ref(false)
|
|
24
|
+
|
|
25
|
+
function clikedOutside() {
|
|
26
|
+
hasClikedOutside.value = true
|
|
27
|
+
setTimeout(() => hasClikedOutside.value = false, 2000)
|
|
28
|
+
}
|
|
29
|
+
</script>
|
|
30
|
+
|
|
31
|
+
<template>
|
|
32
|
+
<div
|
|
33
|
+
class="flex flex-center rounded-md p-12 bg-surface-300"
|
|
34
|
+
>
|
|
35
|
+
<MazCard v-click-outside="clikedOutside">
|
|
36
|
+
Click outside me
|
|
37
|
+
</MazCard>
|
|
38
|
+
</div>
|
|
39
|
+
|
|
40
|
+
<div
|
|
41
|
+
v-if="hasClikedOutside"
|
|
42
|
+
class="flex flex-center rounded-md bg-sucess text-success-foreground p-4 mt-4"
|
|
43
|
+
>
|
|
44
|
+
You clicked outside
|
|
45
|
+
</div>
|
|
46
|
+
</template>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Advanced usage with options
|
|
50
|
+
|
|
51
|
+
The directive can accept an options object to customize its behavior:
|
|
52
|
+
|
|
53
|
+
```vue
|
|
54
|
+
<script lang="ts" setup>
|
|
55
|
+
import { vClickOutside } from 'maz-ui/directives'
|
|
56
|
+
import { ref } from 'vue'
|
|
57
|
+
|
|
58
|
+
const hasClickedOutsideWithIgnore = ref(false)
|
|
59
|
+
|
|
60
|
+
function clickedOutsideWithIgnore() {
|
|
61
|
+
hasClickedOutsideWithIgnore.value = true
|
|
62
|
+
setTimeout(() => hasClickedOutsideWithIgnore.value = false, 2000)
|
|
63
|
+
}
|
|
64
|
+
</script>
|
|
65
|
+
|
|
66
|
+
<template>
|
|
67
|
+
<MazCard v-click-outside="{ callback: clickedOutsideWithIgnore, ignore: ['.ignore-me'] }">
|
|
68
|
+
<div class="p-4">
|
|
69
|
+
<p>Click outside me (but not on the button below)</p>
|
|
70
|
+
<MazBtn class="ignore-me mt-2" color="secondary">
|
|
71
|
+
This button is ignored
|
|
72
|
+
</MazBtn>
|
|
73
|
+
</div>
|
|
74
|
+
</MazCard>
|
|
75
|
+
</template>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Using the `once` option
|
|
79
|
+
|
|
80
|
+
The directive can be configured to trigger only once:
|
|
81
|
+
|
|
82
|
+
```vue
|
|
83
|
+
<script lang="ts" setup>
|
|
84
|
+
import { vClickOutside } from 'maz-ui/directives'
|
|
85
|
+
import { ref } from 'vue'
|
|
86
|
+
|
|
87
|
+
const hasClickedOnce = ref(false)
|
|
88
|
+
|
|
89
|
+
function clickedOnce() {
|
|
90
|
+
hasClickedOnce.value = true
|
|
91
|
+
// This callback will only be triggered once
|
|
92
|
+
}
|
|
93
|
+
</script>
|
|
94
|
+
|
|
95
|
+
<template>
|
|
96
|
+
<MazCard v-click-outside="{ callback: clickedOnce, once: true }">
|
|
97
|
+
Click outside me (works only once)
|
|
98
|
+
</MazCard>
|
|
99
|
+
</template>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## All options combined
|
|
103
|
+
|
|
104
|
+
Here's an example using all available options:
|
|
105
|
+
|
|
106
|
+
```vue
|
|
107
|
+
<script lang="ts" setup>
|
|
108
|
+
import { vClickOutside, type VClickOutsideOptions } from 'maz-ui/directives'
|
|
109
|
+
|
|
110
|
+
const options: VClickOutsideOptions = {
|
|
111
|
+
callback: handleClickOutside,
|
|
112
|
+
ignore: ['.modal', '.tooltip', '.dropdown-menu'],
|
|
113
|
+
capture: true,
|
|
114
|
+
once: false
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function handleClickOutside(event: Event) {
|
|
118
|
+
console.log('Clicked outside!', event)
|
|
119
|
+
}
|
|
120
|
+
</script>
|
|
121
|
+
|
|
122
|
+
<template>
|
|
123
|
+
<div v-click-outside="options">
|
|
124
|
+
<!-- Your content -->
|
|
125
|
+
</div>
|
|
126
|
+
</template>
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## API Reference
|
|
130
|
+
|
|
131
|
+
### Usage Patterns
|
|
132
|
+
|
|
133
|
+
```vue
|
|
134
|
+
<!-- Simple function -->
|
|
135
|
+
<div v-click-outside="myCallback">...</div>
|
|
136
|
+
|
|
137
|
+
<!-- With options object -->
|
|
138
|
+
<div v-click-outside="{ callback: myCallback, ignore: ['.ignore'] }">...</div>
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Options
|
|
142
|
+
|
|
143
|
+
| Option | Type | Default | Description |
|
|
144
|
+
|--------|------|---------|-------------|
|
|
145
|
+
| `callback` | `Function` | `undefined` | **Required.** Function to call when clicking outside |
|
|
146
|
+
| `ignore` | `string[]` | `[]` | Array of CSS selectors to ignore when detecting clicks |
|
|
147
|
+
| `capture` | `boolean` | `false` | Whether to use capture phase for event listening |
|
|
148
|
+
| `once` | `boolean` | `false` | Whether to trigger the callback only once |
|
|
149
|
+
|
|
150
|
+
### Type Definitions
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
interface VClickOutsideOptions {
|
|
154
|
+
callback: (...args: any[]) => any
|
|
155
|
+
ignore?: string[]
|
|
156
|
+
capture?: boolean
|
|
157
|
+
once?: boolean
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
type vClickOutsideBindingValue =
|
|
161
|
+
| ((...args: any[]) => any)
|
|
162
|
+
| VClickOutsideOptions
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Global install
|
|
166
|
+
|
|
167
|
+
### Vue
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
import { vClickOutsideInstall } from 'maz-ui/directives'
|
|
171
|
+
import { createApp } from 'vue'
|
|
172
|
+
|
|
173
|
+
const app = createApp(App)
|
|
174
|
+
|
|
175
|
+
app.use(vClickOutsideInstall)
|
|
176
|
+
|
|
177
|
+
app.mount('#app')
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Nuxt
|
|
181
|
+
|
|
182
|
+
Please refer to the [Nuxt module documentation](../ecosystem/nuxt.md) for more information.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "v-fullscreen-img"
|
|
3
|
+
description: "Displays images fullscreen on click"
|
|
4
|
+
package: "maz-ui"
|
|
5
|
+
url: "https://maz-ui.com/directives/fullscreen-img"
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
# v-fullscreen-img
|
|
9
|
+
|
|
10
|
+
> Displays images fullscreen on click
|
|
11
|
+
|
|
12
|
+
- Package: `maz-ui`
|
|
13
|
+
- Import: `import { vFullscreenImg } from 'maz-ui/directives/vFullscreenImg'`
|
|
14
|
+
- Web: https://maz-ui.com/directives/fullscreen-img
|
|
15
|
+
|
|
16
|
+
## Basic usage
|
|
17
|
+
|
|
18
|
+
```vue
|
|
19
|
+
<template>
|
|
20
|
+
<img
|
|
21
|
+
v-fullscreen-img
|
|
22
|
+
src="https://placedog.net/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
|
+
```html
|
|
34
|
+
<img
|
|
35
|
+
v-fullscreen-img="{
|
|
36
|
+
scaleOnHover: true,
|
|
37
|
+
blurOnHover: true,
|
|
38
|
+
}"
|
|
39
|
+
src="https://placedog.net/1000/600"
|
|
40
|
+
/>
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## On custom element
|
|
44
|
+
|
|
45
|
+
```html
|
|
46
|
+
<MazBtn
|
|
47
|
+
v-fullscreen-img="'https://placedog.net/1000/700'"
|
|
48
|
+
>
|
|
49
|
+
Click me to show image
|
|
50
|
+
</MazBtn>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Global install
|
|
54
|
+
|
|
55
|
+
### Vue
|
|
56
|
+
|
|
57
|
+
`main.ts`
|
|
58
|
+
|
|
59
|
+
```ts
|
|
60
|
+
import { createApp } from 'vue'
|
|
61
|
+
import { vFullscreenImgInstall } from 'maz-ui/directives/vFullscreenImg'
|
|
62
|
+
|
|
63
|
+
const app = createApp(App)
|
|
64
|
+
|
|
65
|
+
app.use(vFullscreenImgInstall)
|
|
66
|
+
|
|
67
|
+
app.mount('#app')
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### Nuxt
|
|
71
|
+
|
|
72
|
+
Please refer to the [Nuxt module documentation](../ecosystem/nuxt.md) for more information.
|
|
73
|
+
|
|
74
|
+
## Types
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
interface vFullscreenImgBindingOptions extends vFullscreenImgOptions {
|
|
78
|
+
src: string
|
|
79
|
+
alt?: string | null
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export type vFullscreenImgBindingValue = string | vFullscreenImgBindingOptions | undefined
|
|
83
|
+
```
|