@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,223 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: useSwipe
|
|
3
|
+
description: useSwipe is a Vue 3 composable that simplifies the management of "swipe" interactions on HTML elements.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
## Introduction
|
|
11
|
+
|
|
12
|
+
`useSwipe` allows you to detect and react to swiping movements on an HTML element. It provides you with various information about the swipe movement, such as the direction, distance, start, and end coordinates.
|
|
13
|
+
You can use this information to implement specific interactions in your application, such as scrolling a carousel, opening a side menu, etc.
|
|
14
|
+
|
|
15
|
+
## Key Features
|
|
16
|
+
|
|
17
|
+
- Detects swipes in all 4 directions (left, right, up, down)
|
|
18
|
+
- Provides key information about the swipe movement (start/end coordinates, horizontal/vertical distance)
|
|
19
|
+
- Allows you to configure callbacks for each swipe direction
|
|
20
|
+
- Possibility to customize the swipe detection threshold
|
|
21
|
+
- Automatically handles the addition and removal of event listeners
|
|
22
|
+
- Can be used with any HTML element
|
|
23
|
+
|
|
24
|
+
## Basic Usage
|
|
25
|
+
|
|
26
|
+
<div ref="swipeContainer" class="swipe-container">
|
|
27
|
+
<p>
|
|
28
|
+
Swipe in any direction<br>
|
|
29
|
+
<span class="maz-text-xs maz-text-muted">
|
|
30
|
+
(You should use a real device or a mobile simulator to test the swipe functionality)
|
|
31
|
+
</span>
|
|
32
|
+
<br><br>
|
|
33
|
+
Last swipe direction: {{lastSwipeDirection || 'None'}}
|
|
34
|
+
</p>
|
|
35
|
+
</div>
|
|
36
|
+
|
|
37
|
+
Here's an example of using the useSwipe composable:
|
|
38
|
+
|
|
39
|
+
```vue
|
|
40
|
+
<script lang="ts" setup>
|
|
41
|
+
import { useSwipe } from 'maz-ui/composables'
|
|
42
|
+
import { onMounted, onUnmounted, ref } from 'vue'
|
|
43
|
+
|
|
44
|
+
const swipeContainer = ref<HTMLDivElement>()
|
|
45
|
+
|
|
46
|
+
const lastSwipeDirection = ref<string>('None')
|
|
47
|
+
|
|
48
|
+
const { xDiff, yDiff, start, stop } = useSwipe({
|
|
49
|
+
element: swipeContainer,
|
|
50
|
+
onLeft: () => lastSwipeDirection.value = 'Swiped left',
|
|
51
|
+
onRight: () => lastSwipeDirection.value = 'Swiped right',
|
|
52
|
+
onUp: () => lastSwipeDirection.value = 'Swiped up',
|
|
53
|
+
onDown: () => lastSwipeDirection.value = 'Swiped down',
|
|
54
|
+
threshold: 50,
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Start listening for swipe events
|
|
59
|
+
* You can also call start() directly
|
|
60
|
+
* But it's better to call it in onMounted specially for SSR
|
|
61
|
+
*/
|
|
62
|
+
onMounted(() => {
|
|
63
|
+
start()
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
// Stop listening for swipe events
|
|
67
|
+
onUnmounted(() => {
|
|
68
|
+
stop()
|
|
69
|
+
})
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<template>
|
|
73
|
+
<div ref="swipeContainer" class="swipe-container">
|
|
74
|
+
<p>
|
|
75
|
+
Swipe in any direction<br>
|
|
76
|
+
<span class="maz-text-sm maz-text-muted">
|
|
77
|
+
(You should use a real device or a mobile simulator to test the swipe functionality)
|
|
78
|
+
</span>
|
|
79
|
+
<br><br>
|
|
80
|
+
Last swipe direction: {{ lastSwipeDirection || 'None' }}
|
|
81
|
+
</p>
|
|
82
|
+
</div>
|
|
83
|
+
</template>
|
|
84
|
+
|
|
85
|
+
<style>
|
|
86
|
+
.swipe-container {
|
|
87
|
+
border: 1px solid #e2e2e3;
|
|
88
|
+
border-radius: 10px;
|
|
89
|
+
height: 200px;
|
|
90
|
+
display: flex;
|
|
91
|
+
justify-content: center;
|
|
92
|
+
align-items: center;
|
|
93
|
+
text-align: center;
|
|
94
|
+
font-size: 1.2rem;
|
|
95
|
+
}
|
|
96
|
+
</style>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
<script lang="ts" setup>
|
|
100
|
+
import { useSwipe } from 'maz-ui/src/composables/useSwipe'
|
|
101
|
+
import { onMounted, onUnmounted, ref } from 'vue'
|
|
102
|
+
|
|
103
|
+
const swipeContainer = ref<HTMLDivElement>()
|
|
104
|
+
|
|
105
|
+
const lastSwipeDirection = ref<string>('None')
|
|
106
|
+
|
|
107
|
+
const { xDiff, yDiff, start, stop } = useSwipe({
|
|
108
|
+
element: swipeContainer,
|
|
109
|
+
onLeft: () => lastSwipeDirection.value = 'Swiped left',
|
|
110
|
+
onRight: () => lastSwipeDirection.value = 'Swiped right',
|
|
111
|
+
onUp: () => lastSwipeDirection.value = 'Swiped up',
|
|
112
|
+
onDown: () => lastSwipeDirection.value = 'Swiped down',
|
|
113
|
+
threshold: 50,
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
onMounted(() => {
|
|
117
|
+
start()
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
onUnmounted(() => {
|
|
121
|
+
stop()
|
|
122
|
+
})
|
|
123
|
+
</script>
|
|
124
|
+
|
|
125
|
+
<style>
|
|
126
|
+
.swipe-container {
|
|
127
|
+
border: 1px solid #e2e2e3;
|
|
128
|
+
border-radius: 10px;
|
|
129
|
+
height: 200px;
|
|
130
|
+
display: flex;
|
|
131
|
+
justify-content: center;
|
|
132
|
+
align-items: center;
|
|
133
|
+
text-align: center;
|
|
134
|
+
font-size: 1.2rem;
|
|
135
|
+
}
|
|
136
|
+
</style>
|
|
137
|
+
|
|
138
|
+
In this example, the `useSwipe` composable is used to detect swiping movements on an HTML element with the `container` class. When a swipe is detected, the horizontal (`xDiff`) and vertical (`yDiff`) coordinates of the movement are displayed.
|
|
139
|
+
|
|
140
|
+
Additionally, callbacks are defined for each swipe direction (`onLeft`, `onRight`, `onUp`, `onDown`), which will be called when the corresponding swipe is detected.
|
|
141
|
+
|
|
142
|
+
The swipe detection threshold is also customized to 50 pixels.
|
|
143
|
+
|
|
144
|
+
## Options
|
|
145
|
+
|
|
146
|
+
`useSwipe` accepts an options object with the following properties:
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
interface UseSwipeOptions {
|
|
150
|
+
/**
|
|
151
|
+
* The HTML element on which the swipe events will be handled. This can be either a direct reference to the element or a CSS selector.
|
|
152
|
+
* @required
|
|
153
|
+
*/
|
|
154
|
+
element: HTMLElement | string | Ref<HTMLElement>
|
|
155
|
+
/** Callback executed when a left swipe is detected. */
|
|
156
|
+
onLeft?: (event: TouchEvent) => void
|
|
157
|
+
/** Callback executed when a right swipe is detected. */
|
|
158
|
+
onRight?: (event: TouchEvent) => void
|
|
159
|
+
/** Callback executed when an up swipe is detected. */
|
|
160
|
+
onUp?: (event: TouchEvent) => void
|
|
161
|
+
/** Callback executed when a down swipe is detected. */
|
|
162
|
+
onDown?: (event: TouchEvent) => void
|
|
163
|
+
/**
|
|
164
|
+
* The minimum distance the swipe must travel to be considered valid.
|
|
165
|
+
* @default 50
|
|
166
|
+
*/
|
|
167
|
+
threshold?: number
|
|
168
|
+
/**
|
|
169
|
+
* Whether to prevent the default behavior of the touchmove event.
|
|
170
|
+
* @default false
|
|
171
|
+
*/
|
|
172
|
+
preventDefaultOnTouchMove?: boolean
|
|
173
|
+
/**
|
|
174
|
+
* Whether to prevent the default behavior of the mousewheel event.
|
|
175
|
+
* @default false
|
|
176
|
+
*/
|
|
177
|
+
preventDefaultOnMouseWheel?: boolean
|
|
178
|
+
/**
|
|
179
|
+
* Whether to trigger the swipe event immediately on touchstart/mousedown.
|
|
180
|
+
* @default false
|
|
181
|
+
*/
|
|
182
|
+
immediate?: boolean
|
|
183
|
+
/**
|
|
184
|
+
* Whether to trigger the swipe event only on touchend/mouseup.
|
|
185
|
+
* @default false
|
|
186
|
+
*/
|
|
187
|
+
triggerOnEnd?: boolean
|
|
188
|
+
}
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
## Composable Return
|
|
192
|
+
|
|
193
|
+
`useSwipe` returns an object with the following properties:
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
interface UseSwipeReturn {
|
|
197
|
+
/** A function to start listening for swipe events. */
|
|
198
|
+
start: () => void
|
|
199
|
+
/** A function to stop listening for swipe events. */
|
|
200
|
+
stop: () => void
|
|
201
|
+
/** The horizontal difference between the start and end coordinates of the swipe. */
|
|
202
|
+
xDiff: Ref<number | undefined>
|
|
203
|
+
/** The vertical difference between the start and end coordinates of the swipe. */
|
|
204
|
+
yDiff: Ref<number | undefined>
|
|
205
|
+
/** The horizontal start coordinate of the swipe. */
|
|
206
|
+
xStart: Ref<number | undefined>
|
|
207
|
+
/** The horizontal end coordinate of the swipe. */
|
|
208
|
+
xEnd: Ref<number | undefined>
|
|
209
|
+
/** The vertical start coordinate of the swipe. */
|
|
210
|
+
yStart: Ref<number | undefined>
|
|
211
|
+
/** The vertical end coordinate of the swipe. */
|
|
212
|
+
yEnd: Ref<number | undefined>
|
|
213
|
+
}
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
## Notes
|
|
217
|
+
|
|
218
|
+
- Make sure to call the `start()` function to start listening for swipe events.
|
|
219
|
+
- You can call the `stop()` function to stop listening for swipe events.
|
|
220
|
+
- If you use the composable in a Vue component, make sure to call it in the `setup()` and clean up the event listeners in the `onUnmounted()`.
|
|
221
|
+
- The composable automatically handles the addition and removal of event listeners based on the provided options.
|
|
222
|
+
- You can customize the swipe detection threshold by modifying the `threshold` option.
|
|
223
|
+
- If you want to prevent the default behavior of touchmove or mousewheel events, you can set the `preventDefaultOnTouchMove` and `preventDefaultOnMouseWheel` options, respectively.
|
|
@@ -0,0 +1,130 @@
|
|
|
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
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
The composable provides the following functionality:
|
|
13
|
+
|
|
14
|
+
- **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.
|
|
15
|
+
- **pause**: Pauses the active timer, allowing it to be resumed later from the point it was paused.
|
|
16
|
+
- **resume**: Resumes the timer from the point it was paused, considering the remaining time.
|
|
17
|
+
- **stop**: Stops the timer completely, resetting the remaining time to the initial timeout value.
|
|
18
|
+
- **remainingTime**: A reactive variable that holds the current remaining time in milliseconds. It updates reactively as the timer progresses.
|
|
19
|
+
|
|
20
|
+
The composable also includes cleanup logic using onBeforeUnmount to ensure that the timer is stopped when the component is unmounted.
|
|
21
|
+
|
|
22
|
+
This composable can be used in Vue 3 components to handle timeouts in a flexible and reactive manner.
|
|
23
|
+
|
|
24
|
+
## Usage
|
|
25
|
+
|
|
26
|
+
**Remaning time**: {{ remainingTime }}ms
|
|
27
|
+
|
|
28
|
+
<div class="maz-flex maz-items-center maz-gap-2">
|
|
29
|
+
<MazBtn @click="start">
|
|
30
|
+
Start
|
|
31
|
+
</MazBtn>
|
|
32
|
+
<MazBtn color="destructive" @click="stop">
|
|
33
|
+
Stop
|
|
34
|
+
</MazBtn>
|
|
35
|
+
<MazBtn color="warning" @click="pause">
|
|
36
|
+
Pause
|
|
37
|
+
</MazBtn>
|
|
38
|
+
<MazBtn color="secondary" @click="resume">
|
|
39
|
+
Resume
|
|
40
|
+
</MazBtn>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
<script lang="ts" setup>
|
|
44
|
+
import { useTimer } from 'maz-ui/src/composables/useTimer'
|
|
45
|
+
import { useToast } from 'maz-ui/src/composables/useToast'
|
|
46
|
+
|
|
47
|
+
const toast = useToast()
|
|
48
|
+
|
|
49
|
+
const { start, stop, pause, resume, remainingTime } = useTimer({
|
|
50
|
+
timeout: 4000,
|
|
51
|
+
callback: () => toast.info('Timeout end', {
|
|
52
|
+
button: {
|
|
53
|
+
onClick: start,
|
|
54
|
+
text: 're-start',
|
|
55
|
+
closeToast: true,
|
|
56
|
+
},
|
|
57
|
+
})
|
|
58
|
+
})
|
|
59
|
+
</script>
|
|
60
|
+
|
|
61
|
+
```vue
|
|
62
|
+
<script lang="ts" setup>
|
|
63
|
+
import { useTimer, useToast } from 'maz-ui/composables'
|
|
64
|
+
|
|
65
|
+
const toast = useToast()
|
|
66
|
+
|
|
67
|
+
const { start, stop, pause, resume, remainingTime } = useTimer({
|
|
68
|
+
timeout: 4000,
|
|
69
|
+
callback: () => toast.info('Timeout end', {
|
|
70
|
+
button: {
|
|
71
|
+
onClick: start,
|
|
72
|
+
text: 're-start',
|
|
73
|
+
closeToast: true,
|
|
74
|
+
},
|
|
75
|
+
})
|
|
76
|
+
})
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<template>
|
|
80
|
+
<MazBtn @click="start">
|
|
81
|
+
Start
|
|
82
|
+
</MazBtn>
|
|
83
|
+
<MazBtn color="destructive" @click="stop">
|
|
84
|
+
Stop
|
|
85
|
+
</MazBtn>
|
|
86
|
+
<MazBtn color="warning" @click="pause">
|
|
87
|
+
Pause
|
|
88
|
+
</MazBtn>
|
|
89
|
+
<MazBtn color="secondary" @click="resume">
|
|
90
|
+
Resume
|
|
91
|
+
</MazBtn>
|
|
92
|
+
</template>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Set timeout with start function
|
|
96
|
+
|
|
97
|
+
Starts the timer with the specified timeout. If the timeout is not provided, it uses the default value of 1000ms.
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
const { start } = useTimer()
|
|
101
|
+
|
|
102
|
+
start(4000)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Types
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
export interface TimerOptions {
|
|
109
|
+
/**
|
|
110
|
+
* The time in milliseconds
|
|
111
|
+
* @default 1000
|
|
112
|
+
*/
|
|
113
|
+
timeout?: number
|
|
114
|
+
/**
|
|
115
|
+
* The callback to execute when the timer is finished
|
|
116
|
+
* @default undefined
|
|
117
|
+
*/
|
|
118
|
+
callback?: () => unknown
|
|
119
|
+
/**
|
|
120
|
+
* The interval to update the remaining time
|
|
121
|
+
* @default 200
|
|
122
|
+
*/
|
|
123
|
+
remainingTimeUpdate?: number
|
|
124
|
+
/**
|
|
125
|
+
* The offset time to execute the callback
|
|
126
|
+
* @default 0
|
|
127
|
+
*/
|
|
128
|
+
callbackOffsetTime?: number
|
|
129
|
+
}
|
|
130
|
+
```
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: useToast
|
|
3
|
+
description: Vue composable for handling toast plugin in your components
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
::: warning
|
|
11
|
+
You must install [toast plugin](./../plugins/toast.md#install) before use it
|
|
12
|
+
:::
|
|
13
|
+
|
|
14
|
+
::: tip
|
|
15
|
+
More info about [toast plugin](./../plugins/toast.md) in its documentation
|
|
16
|
+
:::
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
```vue
|
|
21
|
+
<script lang="ts" setup>
|
|
22
|
+
import { useToast } from 'maz-ui/composables'
|
|
23
|
+
|
|
24
|
+
const toast = useToast()
|
|
25
|
+
|
|
26
|
+
toast.info('info message', {
|
|
27
|
+
button: {
|
|
28
|
+
onClick: () => toast.success('clicked'),
|
|
29
|
+
text: 'Click me',
|
|
30
|
+
closeToast: true
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
toast.success('success message', {
|
|
34
|
+
button: {
|
|
35
|
+
href: '/composables/use-toast',
|
|
36
|
+
text: 'Follow me',
|
|
37
|
+
closeToast: true,
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
toast.warning('warning message')
|
|
41
|
+
toast.error('error message')
|
|
42
|
+
</script>
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
<script lang="ts" setup>
|
|
46
|
+
import { onMounted } from 'vue'
|
|
47
|
+
import { useToast } from 'maz-ui/src/composables/useToast'
|
|
48
|
+
|
|
49
|
+
const toast = useToast()
|
|
50
|
+
|
|
51
|
+
onMounted(() => {
|
|
52
|
+
toast.info('info message', {
|
|
53
|
+
button: {
|
|
54
|
+
onClick: () => toast.success('clicked'),
|
|
55
|
+
text: 'Click me',
|
|
56
|
+
closeToast: true
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
toast.success('success message', {
|
|
60
|
+
button: {
|
|
61
|
+
href: '/composables/use-toast',
|
|
62
|
+
text: 'Follow me',
|
|
63
|
+
closeToast: true,
|
|
64
|
+
}
|
|
65
|
+
})
|
|
66
|
+
toast.warning('warning message')
|
|
67
|
+
toast.error('error message')
|
|
68
|
+
toast.message('message')
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
</script>
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: user-visibility
|
|
3
|
+
description: Plugin to see and manage the user page visibility
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
::: tip
|
|
11
|
+
Useful to know if the user is displaying your website
|
|
12
|
+
:::
|
|
13
|
+
|
|
14
|
+
## Demo
|
|
15
|
+
|
|
16
|
+
<MazCard overflow-hidden style="width: 100%; margin-bottom: 1rem;">
|
|
17
|
+
<h3 style="margin-top: 0; margin-bottom: 1rem;">Logs</h3>
|
|
18
|
+
|
|
19
|
+
<div v-for="({isVisible}, i) in events" :key="i">
|
|
20
|
+
isVisible: {{isVisible}}
|
|
21
|
+
</div>
|
|
22
|
+
</MazCard>
|
|
23
|
+
|
|
24
|
+
<div class="flex items-start gap-05 items-center flex-wrap">
|
|
25
|
+
<MazBtn @click="userVisibility.start()" color="info">
|
|
26
|
+
Start
|
|
27
|
+
</MazBtn>
|
|
28
|
+
|
|
29
|
+
<MazBtn @click="userVisibility.destroy()" color="destructive">
|
|
30
|
+
Destroy
|
|
31
|
+
</MazBtn>
|
|
32
|
+
|
|
33
|
+
</div>
|
|
34
|
+
|
|
35
|
+
::: tip
|
|
36
|
+
Switch tabs for a second to see events
|
|
37
|
+
:::
|
|
38
|
+
|
|
39
|
+
## How to use it?
|
|
40
|
+
|
|
41
|
+
```vue
|
|
42
|
+
<script lang="ts" setup>
|
|
43
|
+
import { useUserVisibility } from 'maz-ui/composables'
|
|
44
|
+
|
|
45
|
+
import { onBeforeUnmount, onMounted, ref } from 'vue'
|
|
46
|
+
|
|
47
|
+
const events = ref([])
|
|
48
|
+
|
|
49
|
+
function callback({ isVisible }) {
|
|
50
|
+
console.log('isVisible', isVisible)
|
|
51
|
+
events.value.push({ isVisible })
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const options = {
|
|
55
|
+
immediate: true,
|
|
56
|
+
once: false,
|
|
57
|
+
timeout: 1000,
|
|
58
|
+
ssr: true,
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const userVisibility = useUserVisibility({ callback, options })
|
|
62
|
+
|
|
63
|
+
onMounted(() => {
|
|
64
|
+
userVisibility.start()
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
onBeforeUnmount(() => {
|
|
68
|
+
userVisibility.destroy()
|
|
69
|
+
})
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<template>
|
|
73
|
+
<MazBtn color="destructive" @click="userVisibility.destroy()">
|
|
74
|
+
Destroy
|
|
75
|
+
</MazBtn>
|
|
76
|
+
|
|
77
|
+
<MazBtn color="destructive" @click="userVisibility.destroy()">
|
|
78
|
+
Destroy
|
|
79
|
+
</MazBtn>
|
|
80
|
+
|
|
81
|
+
<MazCard overflow-hidden style="width: 100%;">
|
|
82
|
+
<h3>Logs</h3>
|
|
83
|
+
|
|
84
|
+
<div v-for="({ isVisible }, i) in events" :key="i">
|
|
85
|
+
isVisible: {{ isVisible }}
|
|
86
|
+
</div>
|
|
87
|
+
</MazCard>
|
|
88
|
+
</template>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
<script lang="ts" setup>
|
|
92
|
+
import { onMounted, ref, onBeforeUnmount } from 'vue'
|
|
93
|
+
|
|
94
|
+
import { useUserVisibility } from 'maz-ui/src/composables/useUserVisibility'
|
|
95
|
+
|
|
96
|
+
const events = ref([])
|
|
97
|
+
|
|
98
|
+
const callback = ({ isVisible }) => {
|
|
99
|
+
console.log('isVisible', isVisible)
|
|
100
|
+
events.value.push({ isVisible: isVisible })
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const options = {
|
|
104
|
+
immediate: true,
|
|
105
|
+
once: false,
|
|
106
|
+
timeout: 1000,
|
|
107
|
+
ssr: true,
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const userVisibility = useUserVisibility({ callback, options })
|
|
111
|
+
|
|
112
|
+
onMounted(() => {
|
|
113
|
+
userVisibility.start()
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
onBeforeUnmount(() => {
|
|
117
|
+
userVisibility.destroy()
|
|
118
|
+
})
|
|
119
|
+
</script>
|
|
120
|
+
|
|
121
|
+
## Callback
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
export type UserVisibilyCallback = ({
|
|
125
|
+
isVisible,
|
|
126
|
+
}: {
|
|
127
|
+
isVisible: boolean
|
|
128
|
+
}) => void
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Options
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
interface UserVisibilyStrictOptions {
|
|
135
|
+
immediate: boolean
|
|
136
|
+
timeout: number
|
|
137
|
+
once: boolean
|
|
138
|
+
ssr: boolean // if `true`
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Default Options
|
|
143
|
+
|
|
144
|
+
```ts
|
|
145
|
+
const defaultOptions: UserVisibilyOptions = {
|
|
146
|
+
immediate: false,
|
|
147
|
+
timeout: 5000,
|
|
148
|
+
once: false,
|
|
149
|
+
ssr: false,
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Actions
|
|
154
|
+
|
|
155
|
+
### Start
|
|
156
|
+
|
|
157
|
+
Will start the user visibility tracking
|
|
158
|
+
|
|
159
|
+
```ts
|
|
160
|
+
userVisibility.start()
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
### Destroy
|
|
164
|
+
|
|
165
|
+
Will destroy the instance and stop the tracking
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
userVisibility.destroy()
|
|
169
|
+
```
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: useWait
|
|
3
|
+
description: Vue composable for handling wait plugins
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
::: warning
|
|
11
|
+
You must install the [wait plugin](./../plugins/wait.md#install) before using it
|
|
12
|
+
:::
|
|
13
|
+
|
|
14
|
+
::: tip
|
|
15
|
+
More info about the [wait plugin](./../plugins/wait.md) in its documentation
|
|
16
|
+
:::
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
<MazFullscreenLoader v-if="wait.isLoading('MAIN_LOADER')">
|
|
21
|
+
Loading
|
|
22
|
+
</MazFullscreenLoader>
|
|
23
|
+
<p v-else> Loaded </p>
|
|
24
|
+
|
|
25
|
+
```vue
|
|
26
|
+
<script lang="ts" setup>
|
|
27
|
+
import { sleep } from 'maz-ui'
|
|
28
|
+
import { useWait } from 'maz-ui/composables'
|
|
29
|
+
import { onMounted } from 'vue'
|
|
30
|
+
|
|
31
|
+
const wait = useWait()
|
|
32
|
+
|
|
33
|
+
onMounted(async () => {
|
|
34
|
+
wait.start('MAIN_LOADER')
|
|
35
|
+
await sleep(2000)
|
|
36
|
+
wait.stop('MAIN_LOADER')
|
|
37
|
+
})
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<template>
|
|
41
|
+
<MazFullscreenLoader v-if="wait.isLoading('MAIN_LOADER')">
|
|
42
|
+
Loading
|
|
43
|
+
</MazFullscreenLoader>
|
|
44
|
+
<p v-else>
|
|
45
|
+
Loaded
|
|
46
|
+
</p>
|
|
47
|
+
</template>
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
<script lang="ts" setup>
|
|
51
|
+
import { onMounted } from 'vue'
|
|
52
|
+
import { sleep } from 'maz-ui/src/index'
|
|
53
|
+
import { useWait } from 'maz-ui/src/composables/useWait'
|
|
54
|
+
|
|
55
|
+
const wait = useWait()
|
|
56
|
+
|
|
57
|
+
onMounted(async () => {
|
|
58
|
+
wait.start('MAIN_LOADER')
|
|
59
|
+
await sleep(2000)
|
|
60
|
+
wait.stop('MAIN_LOADER')
|
|
61
|
+
})
|
|
62
|
+
</script>
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
---
|
|
5
|
+
|
|
6
|
+
# {{ $frontmatter.title }}
|
|
7
|
+
|
|
8
|
+
{{ $frontmatter.description }}
|
|
9
|
+
|
|
10
|
+
## Basic usage
|
|
11
|
+
|
|
12
|
+
```ts
|
|
13
|
+
const { height, width } = useWindowSize()
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
::: warning
|
|
17
|
+
More documentation to come
|
|
18
|
+
:::
|