@maas/vue-equipment 0.5.0 → 0.6.1
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/composables/index.d.mts +23 -1
- package/dist/composables/index.d.ts +23 -1
- package/dist/composables/index.js +118 -8
- package/dist/composables/index.js.map +1 -1
- package/dist/composables/index.mjs +111 -2
- package/dist/composables/index.mjs.map +1 -1
- package/dist/nuxt/module.json +1 -1
- package/dist/nuxt/module.mjs +16 -2
- package/dist/plugins/MagicMarquee/src/components/MagicMarquee.vue +3 -3
- package/dist/plugins/MagicMarquee/src/composables/{useMarquee.d.ts → useMarqueeApi.d.ts} +2 -2
- package/dist/plugins/MagicMarquee/src/composables/{useMarquee.mjs → useMarqueeApi.mjs} +1 -1
- package/dist/plugins/MagicModal/src/components/MagicModal.vue +39 -59
- package/dist/plugins/MagicModal/src/components/MagicModal.vue.d.ts +15 -15
- package/dist/plugins/MagicModal/src/composables/private/useModalCallback.d.ts +22 -0
- package/dist/plugins/MagicModal/src/composables/private/useModalCallback.mjs +60 -0
- package/dist/plugins/MagicModal/src/composables/useModalApi.d.ts +4 -3
- package/dist/plugins/MagicModal/src/composables/useModalApi.mjs +5 -4
- package/dist/plugins/MagicModal/src/types/index.d.ts +7 -5
- package/dist/plugins/MagicModal/src/utils/defaultOptions.d.ts +2 -2
- package/dist/plugins/MagicPlayer/src/composables/useControlsApi.mjs +1 -2
- package/dist/plugins/MagicPlayer/src/composables/useMediaApi.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/composables/useMediaApi.mjs +2 -2
- package/dist/plugins/MagicPlayer/src/composables/useRuntimeSourceProvider.mjs +1 -2
- package/dist/plugins/MagicPlayer/src/types/index.d.ts +1 -1
- package/dist/plugins/MagicScroll/index.d.ts +2 -2
- package/dist/plugins/MagicScroll/index.mjs +4 -2
- package/dist/plugins/MagicScroll/src/components/MagicScrollMotion.vue +58 -0
- package/dist/plugins/MagicScroll/src/components/MagicScrollMotion.vue.d.ts +42 -0
- package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue +2 -2
- package/dist/plugins/MagicScroll/src/components/MagicScrollTransform.vue.d.ts +9 -9
- package/dist/plugins/MagicScroll/src/composables/{useProgress.d.ts → useScrollApi.d.ts} +4 -4
- package/dist/plugins/MagicScroll/src/composables/{useProgress.mjs → useScrollApi.mjs} +2 -3
- package/dist/plugins/MagicScroll/src/types/injectionKeys.d.ts +1 -2
- package/dist/plugins/MagicToast/demo/DemoToast.vue +22 -0
- package/dist/plugins/MagicToast/demo/DemoToast.vue.d.ts +14 -0
- package/dist/plugins/MagicToast/index.d.ts +5 -0
- package/dist/plugins/MagicToast/index.mjs +9 -0
- package/dist/plugins/MagicToast/nuxt.d.ts +2 -0
- package/dist/plugins/MagicToast/nuxt.mjs +5 -0
- package/dist/plugins/MagicToast/src/components/MagicToast.vue +230 -0
- package/dist/plugins/MagicToast/src/components/MagicToast.vue.d.ts +28 -0
- package/dist/plugins/MagicToast/src/components/MagicToastComponent.vue +101 -0
- package/dist/plugins/MagicToast/src/components/MagicToastComponent.vue.d.ts +48 -0
- package/dist/plugins/MagicToast/src/composables/private/useToastCallback.d.ts +21 -0
- package/dist/plugins/MagicToast/src/composables/private/useToastCallback.mjs +43 -0
- package/dist/plugins/MagicToast/src/composables/private/useToastInternalApi.d.ts +4 -0
- package/dist/plugins/MagicToast/src/composables/private/useToastInternalApi.mjs +26 -0
- package/dist/plugins/MagicToast/src/composables/private/useToastStore.d.ts +17 -0
- package/dist/plugins/MagicToast/src/composables/private/useToastStore.mjs +41 -0
- package/dist/plugins/MagicToast/src/composables/useToastApi.d.ts +11 -0
- package/dist/plugins/MagicToast/src/composables/useToastApi.mjs +60 -0
- package/dist/plugins/MagicToast/src/composables/useToastEmitter.d.ts +15 -0
- package/dist/plugins/MagicToast/src/composables/useToastEmitter.mjs +9 -0
- package/dist/plugins/MagicToast/src/types/index.d.ts +42 -0
- package/dist/plugins/MagicToast/src/types/index.mjs +0 -0
- package/dist/plugins/MagicToast/src/utils/defaultOptions.d.ts +3 -0
- package/dist/plugins/MagicToast/src/utils/defaultOptions.mjs +14 -0
- package/dist/plugins/index.d.ts +2 -1
- package/dist/plugins/index.mjs +2 -1
- package/package.json +13 -1
- /package/dist/plugins/MagicModal/src/composables/{useModalStore.d.ts → private/useModalStore.d.ts} +0 -0
- /package/dist/plugins/MagicModal/src/composables/{useModalStore.mjs → private/useModalStore.mjs} +0 -0
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { InjectionKey, Ref } from 'vue';
|
|
2
|
-
import type { MaybeRefOrGetter } from '@vueuse/core';
|
|
1
|
+
import type { InjectionKey, Ref, MaybeRefOrGetter } from 'vue';
|
|
3
2
|
declare const ScrollParentKey: InjectionKey<MaybeRefOrGetter<HTMLElement | undefined>>;
|
|
4
3
|
declare const ScrollPositionKey: InjectionKey<{
|
|
5
4
|
x: import("vue").WritableComputedRef<number>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="bg-gray-300 text-black rounded-md p-3 w-[250px] max-w-sm text-sm pointer-events-auto cursor-pointer flex items-center"
|
|
4
|
+
>
|
|
5
|
+
{{ message }}
|
|
6
|
+
<button
|
|
7
|
+
@click="emit('close')"
|
|
8
|
+
class="text-xs bg-gray-900/5 ml-auto p-2 rounded-full"
|
|
9
|
+
>
|
|
10
|
+
Close
|
|
11
|
+
</button>
|
|
12
|
+
</div>
|
|
13
|
+
</template>
|
|
14
|
+
|
|
15
|
+
<script setup lang="ts">
|
|
16
|
+
interface Props {
|
|
17
|
+
message: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const emit = defineEmits(['close'])
|
|
21
|
+
const props = defineProps<Props>()
|
|
22
|
+
</script>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<{
|
|
2
|
+
message: {
|
|
3
|
+
type: import("vue").PropType<string>;
|
|
4
|
+
required: true;
|
|
5
|
+
};
|
|
6
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "close"[], "close", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
7
|
+
message: {
|
|
8
|
+
type: import("vue").PropType<string>;
|
|
9
|
+
required: true;
|
|
10
|
+
};
|
|
11
|
+
}>> & {
|
|
12
|
+
onClose?: ((...args: any[]) => any) | undefined;
|
|
13
|
+
}, {}, {}>;
|
|
14
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import MagicToastComponent from "./src/components/MagicToast.vue";
|
|
2
|
+
import { useToastApi } from "./src/composables/useToastApi.mjs";
|
|
3
|
+
import { useToastEmitter } from "./src/composables/useToastEmitter.mjs";
|
|
4
|
+
const MagicToast = {
|
|
5
|
+
install: (app) => {
|
|
6
|
+
app.component("MagicToast", MagicToastComponent);
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
export { MagicToast, useToastApi, useToastEmitter };
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<Teleport
|
|
3
|
+
:to="mappedOptions.teleport?.target"
|
|
4
|
+
:disabled="mappedOptions.teleport?.disabled"
|
|
5
|
+
>
|
|
6
|
+
<div class="magic-toast" :id="toValue(id)" :class="toValue(props.class)">
|
|
7
|
+
<transition-group
|
|
8
|
+
tag="ol"
|
|
9
|
+
ref="listRef"
|
|
10
|
+
class="magic-toast__inner"
|
|
11
|
+
:name="mappedOptions.transitions!.list"
|
|
12
|
+
:on-before-enter="onBeforeEnter"
|
|
13
|
+
:on-enter="onEnter"
|
|
14
|
+
:on-after-enter="onAfterEnter"
|
|
15
|
+
:on-before-leave="onBeforeLeave"
|
|
16
|
+
:on-leave="onLeave"
|
|
17
|
+
:on-after-leave="onAfterLeave"
|
|
18
|
+
>
|
|
19
|
+
<magic-toast-component
|
|
20
|
+
v-for="(toast, index) in toasts"
|
|
21
|
+
:id="toast.id"
|
|
22
|
+
:key="toast.id"
|
|
23
|
+
:index="index"
|
|
24
|
+
:total="count || 0"
|
|
25
|
+
:siblings="activeElements"
|
|
26
|
+
:class="{
|
|
27
|
+
expanded: isExpanded,
|
|
28
|
+
}"
|
|
29
|
+
@mouseenter="onMouseenter"
|
|
30
|
+
@mouseleave="onMouseleave"
|
|
31
|
+
>
|
|
32
|
+
<component
|
|
33
|
+
:is="toast.component"
|
|
34
|
+
v-bind="toast.props"
|
|
35
|
+
@close="toast.remove"
|
|
36
|
+
@click.self="onClick"
|
|
37
|
+
/>
|
|
38
|
+
</magic-toast-component>
|
|
39
|
+
</transition-group>
|
|
40
|
+
</div>
|
|
41
|
+
</Teleport>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<script setup lang="ts">
|
|
45
|
+
import { defu } from 'defu'
|
|
46
|
+
import { toValue, ref, type MaybeRef } from 'vue'
|
|
47
|
+
import { onClickOutside, type MaybeElement } from '@vueuse/core'
|
|
48
|
+
import { defaultOptions } from './../utils/defaultOptions'
|
|
49
|
+
import { useToastApi } from './../composables/useToastApi'
|
|
50
|
+
import { useToastCallback } from './../composables/private/useToastCallback'
|
|
51
|
+
|
|
52
|
+
import MagicToastComponent from './MagicToastComponent.vue'
|
|
53
|
+
|
|
54
|
+
import type { Options } from './../types/index'
|
|
55
|
+
|
|
56
|
+
interface MagicToastProps {
|
|
57
|
+
id: MaybeRef<string>
|
|
58
|
+
class: MaybeRef<string>
|
|
59
|
+
options?: Options
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const props = defineProps<MagicToastProps>()
|
|
63
|
+
|
|
64
|
+
const { toasts, count, oldest } = useToastApi(props.id)
|
|
65
|
+
|
|
66
|
+
const mappedOptions = defu(props.options, defaultOptions)
|
|
67
|
+
const isExpanded = ref(mappedOptions.layout?.expand === true)
|
|
68
|
+
const listRef = ref<MaybeElement>()
|
|
69
|
+
|
|
70
|
+
const {
|
|
71
|
+
onBeforeEnter,
|
|
72
|
+
onEnter,
|
|
73
|
+
onAfterEnter,
|
|
74
|
+
onBeforeLeave,
|
|
75
|
+
onLeave,
|
|
76
|
+
onAfterLeave,
|
|
77
|
+
activeElements,
|
|
78
|
+
} = useToastCallback({ id: props.id, mappedOptions, count, oldest })
|
|
79
|
+
|
|
80
|
+
function onMouseenter() {
|
|
81
|
+
if (mappedOptions.layout?.expand === 'hover') {
|
|
82
|
+
isExpanded.value = true
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function onMouseleave() {
|
|
87
|
+
if (mappedOptions.layout?.expand === 'hover') {
|
|
88
|
+
isExpanded.value = false
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function onClick() {
|
|
93
|
+
if (mappedOptions.layout?.expand === 'click') {
|
|
94
|
+
isExpanded.value = true
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function outsideClickCallback() {
|
|
99
|
+
if (mappedOptions.layout?.expand === 'click') {
|
|
100
|
+
isExpanded.value = false
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
onClickOutside(listRef, outsideClickCallback)
|
|
105
|
+
</script>
|
|
106
|
+
|
|
107
|
+
<style lang="css">
|
|
108
|
+
:root {
|
|
109
|
+
--magic-toast-enter-x: 0;
|
|
110
|
+
--magic-toast-enter-y: 0;
|
|
111
|
+
--magic-toast-scale: 0.1;
|
|
112
|
+
--magic-toast-transform-x: 0;
|
|
113
|
+
--magic-toast-transform-y: 0;
|
|
114
|
+
--magic-toast-transition: transform 300ms ease-out;
|
|
115
|
+
--magic-toast-z-index: 999;
|
|
116
|
+
--magic-toast-gap: 0.75rem;
|
|
117
|
+
--magic-toast-padding-x: 1rem;
|
|
118
|
+
--magic-toast-padding-y: 1rem;
|
|
119
|
+
|
|
120
|
+
--mt-multiplier: 1;
|
|
121
|
+
--mt-transform-x: -50%;
|
|
122
|
+
--mt-transform-y: -50%;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
.magic-toast {
|
|
126
|
+
position: fixed;
|
|
127
|
+
inset: 0;
|
|
128
|
+
width: 100%;
|
|
129
|
+
height: 100%;
|
|
130
|
+
display: flex;
|
|
131
|
+
flex-direction: column;
|
|
132
|
+
justify-content: center;
|
|
133
|
+
align-items: center;
|
|
134
|
+
z-index: var(--magic-toast-z-index, 999);
|
|
135
|
+
background: transparent;
|
|
136
|
+
color: inherit;
|
|
137
|
+
pointer-events: none;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.magic-toast__inner {
|
|
141
|
+
position: relative;
|
|
142
|
+
overflow: scroll;
|
|
143
|
+
max-height: 100%;
|
|
144
|
+
width: 100%;
|
|
145
|
+
height: 100%;
|
|
146
|
+
& .magic-toast-component {
|
|
147
|
+
left: 50%;
|
|
148
|
+
top: 50%;
|
|
149
|
+
transform: translateX(var(--mt-transform-x, -50%))
|
|
150
|
+
translateY(var(--mt-transform-y, -50%));
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
.magic-toast__inner * {
|
|
155
|
+
pointer-events: all;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
.magic-toast.-top-left,
|
|
159
|
+
.magic-toast.-top-center,
|
|
160
|
+
.magic-toast.-top-right {
|
|
161
|
+
--magic-toast-transform-y: 10;
|
|
162
|
+
--magic-toast-enter-y: -100%;
|
|
163
|
+
--mt-multiplier: 1;
|
|
164
|
+
& .magic-toast-component {
|
|
165
|
+
top: var(--magic-toast-padding-y, 1rem);
|
|
166
|
+
--mt-transform-y: 0;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
.magic-toast.-bottom-left,
|
|
171
|
+
.magic-toast.-bottom-center,
|
|
172
|
+
.magic-toast.-bottom-right {
|
|
173
|
+
--magic-toast-transform-y: 10;
|
|
174
|
+
--magic-toast-enter-y: 100%;
|
|
175
|
+
--mt-multiplier: -1;
|
|
176
|
+
& .magic-toast-component {
|
|
177
|
+
top: unset;
|
|
178
|
+
bottom: var(--magic-toast-padding-y, 1rem);
|
|
179
|
+
--mt-transform-y: 0;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
.magic-toast.-top-left,
|
|
184
|
+
.magic-toast.-bottom-left {
|
|
185
|
+
& .magic-toast-component {
|
|
186
|
+
left: var(--magic-toast-padding-x, 1rem);
|
|
187
|
+
--mt-transform-x: 0;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
.magic-toast.-top-right,
|
|
192
|
+
.magic-toast.-bottom-right {
|
|
193
|
+
& .magic-toast-component {
|
|
194
|
+
left: unset;
|
|
195
|
+
right: var(--magic-toast-padding-x, 1rem);
|
|
196
|
+
--mt-transform-x: 0;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
.magic-toast.-from-left {
|
|
201
|
+
--magic-toast-enter-x: -100%;
|
|
202
|
+
--magic-toast-enter-y: 0;
|
|
203
|
+
--magic-toast-transform-y: 0;
|
|
204
|
+
--magic-toast-transform-x: -30;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
.magic-toast.-from-right {
|
|
208
|
+
--magic-toast-enter-x: 100%;
|
|
209
|
+
--magic-toast-enter-y: 0;
|
|
210
|
+
--magic-toast-transform-y: 0;
|
|
211
|
+
--magic-toast-transform-x: 30;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.magic-toast--list-enter-active * {
|
|
215
|
+
transition: all 300ms ease-out;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.magic-toast--list-enter-from * {
|
|
219
|
+
transform: translateY(var(--magic-toast-enter-y, 0))
|
|
220
|
+
translateX(var(--magic-toast-enter-x, 0));
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
.magic-toast--list-leave-active {
|
|
224
|
+
transition: all 150ms ease-out;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
.magic-toast--list-leave-to {
|
|
228
|
+
opacity: 0;
|
|
229
|
+
}
|
|
230
|
+
</style>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type MaybeRef } from 'vue';
|
|
2
|
+
import type { Options } from './../types/index';
|
|
3
|
+
declare const _default: import("vue").DefineComponent<{
|
|
4
|
+
id: {
|
|
5
|
+
type: import("vue").PropType<MaybeRef<string>>;
|
|
6
|
+
required: true;
|
|
7
|
+
};
|
|
8
|
+
class: {
|
|
9
|
+
type: import("vue").PropType<MaybeRef<string>>;
|
|
10
|
+
required: true;
|
|
11
|
+
};
|
|
12
|
+
options: {
|
|
13
|
+
type: import("vue").PropType<Options>;
|
|
14
|
+
};
|
|
15
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
16
|
+
id: {
|
|
17
|
+
type: import("vue").PropType<MaybeRef<string>>;
|
|
18
|
+
required: true;
|
|
19
|
+
};
|
|
20
|
+
class: {
|
|
21
|
+
type: import("vue").PropType<MaybeRef<string>>;
|
|
22
|
+
required: true;
|
|
23
|
+
};
|
|
24
|
+
options: {
|
|
25
|
+
type: import("vue").PropType<Options>;
|
|
26
|
+
};
|
|
27
|
+
}>>, {}, {}>;
|
|
28
|
+
export default _default;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<li
|
|
3
|
+
class="magic-toast-component"
|
|
4
|
+
ref="elRef"
|
|
5
|
+
@mouseenter="onMouseenter"
|
|
6
|
+
:id="id"
|
|
7
|
+
>
|
|
8
|
+
<div class="magic-toast-component__inner">
|
|
9
|
+
<slot />
|
|
10
|
+
</div>
|
|
11
|
+
</li>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script lang="ts" setup>
|
|
15
|
+
import { ref, computed, onMounted, watchEffect } from 'vue'
|
|
16
|
+
import { type ActiveElement } from './../types'
|
|
17
|
+
|
|
18
|
+
interface Props {
|
|
19
|
+
index: number
|
|
20
|
+
total: number
|
|
21
|
+
id: string
|
|
22
|
+
siblings: ActiveElement[]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const props = defineProps<Props>()
|
|
26
|
+
const emit = defineEmits<{
|
|
27
|
+
mouseenter: [event: Event]
|
|
28
|
+
}>()
|
|
29
|
+
|
|
30
|
+
const elRef = ref<HTMLElement | undefined>(undefined)
|
|
31
|
+
const newerSiblings = computed(() => {
|
|
32
|
+
return props.siblings.slice(props.index + 1)
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
function setIndex() {
|
|
36
|
+
const index = (props.total - props.index - 1).toString()
|
|
37
|
+
elRef.value?.style.setProperty('--mt-index', index)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function setOffset() {
|
|
41
|
+
const offset = newerSiblings.value.reduce((acc, curr) => {
|
|
42
|
+
return acc + curr.height
|
|
43
|
+
}, 0)
|
|
44
|
+
elRef.value?.style.setProperty('--mt-offset', `${offset}`)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function onMouseenter(event: Event) {
|
|
48
|
+
emit('mouseenter', event)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
onMounted(() => {
|
|
52
|
+
setIndex()
|
|
53
|
+
setOffset()
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
watchEffect(() => {
|
|
57
|
+
setIndex()
|
|
58
|
+
setOffset()
|
|
59
|
+
})
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<style lang="css">
|
|
63
|
+
.magic-toast-component {
|
|
64
|
+
--mt-index: 0;
|
|
65
|
+
--mt-offset: 0;
|
|
66
|
+
--mt-matrix-scale: calc(1 - (var(--magic-toast-scale) * var(--mt-index, 0)));
|
|
67
|
+
--mt-matrix-transform-x: calc(
|
|
68
|
+
var(--magic-toast-transform-x) * var(--mt-index, 0) * var(--mt-multiplier)
|
|
69
|
+
);
|
|
70
|
+
--mt-matrix-transform-y: calc(
|
|
71
|
+
var(--magic-toast-transform-y) * var(--mt-index, 0) * var(--mt-multiplier)
|
|
72
|
+
);
|
|
73
|
+
position: absolute;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.magic-toast-component__inner {
|
|
77
|
+
position: relative;
|
|
78
|
+
width: 100%;
|
|
79
|
+
height: 100%;
|
|
80
|
+
transition: var(--magic-toast-transition, transform 300ms ease-out);
|
|
81
|
+
transform: matrix(
|
|
82
|
+
var(--mt-matrix-scale),
|
|
83
|
+
0,
|
|
84
|
+
0,
|
|
85
|
+
var(--mt-matrix-scale),
|
|
86
|
+
var(--mt-matrix-transform-x),
|
|
87
|
+
var(--mt-matrix-transform-y)
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.magic-toast-component.expanded {
|
|
92
|
+
--mt-matrix-scale: 1;
|
|
93
|
+
--mt-matrix-transform-y: calc(((var(--mt-offset)) * var(--mt-multiplier)));
|
|
94
|
+
--mt-matrix-transform-x: 0;
|
|
95
|
+
&:not(:last-child) {
|
|
96
|
+
& .magic-toast-component__inner {
|
|
97
|
+
padding-bottom: calc(var(--magic-toast-gap) * var(--mt-index));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
</style>
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type ActiveElement } from './../types';
|
|
2
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{
|
|
3
|
+
index: {
|
|
4
|
+
type: import("vue").PropType<number>;
|
|
5
|
+
required: true;
|
|
6
|
+
};
|
|
7
|
+
total: {
|
|
8
|
+
type: import("vue").PropType<number>;
|
|
9
|
+
required: true;
|
|
10
|
+
};
|
|
11
|
+
id: {
|
|
12
|
+
type: import("vue").PropType<string>;
|
|
13
|
+
required: true;
|
|
14
|
+
};
|
|
15
|
+
siblings: {
|
|
16
|
+
type: import("vue").PropType<ActiveElement[]>;
|
|
17
|
+
required: true;
|
|
18
|
+
};
|
|
19
|
+
}, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
20
|
+
mouseenter: (event: Event) => void;
|
|
21
|
+
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{
|
|
22
|
+
index: {
|
|
23
|
+
type: import("vue").PropType<number>;
|
|
24
|
+
required: true;
|
|
25
|
+
};
|
|
26
|
+
total: {
|
|
27
|
+
type: import("vue").PropType<number>;
|
|
28
|
+
required: true;
|
|
29
|
+
};
|
|
30
|
+
id: {
|
|
31
|
+
type: import("vue").PropType<string>;
|
|
32
|
+
required: true;
|
|
33
|
+
};
|
|
34
|
+
siblings: {
|
|
35
|
+
type: import("vue").PropType<ActiveElement[]>;
|
|
36
|
+
required: true;
|
|
37
|
+
};
|
|
38
|
+
}>> & {
|
|
39
|
+
onMouseenter?: ((event: Event) => any) | undefined;
|
|
40
|
+
}, {}, {}>, {
|
|
41
|
+
default?(_: {}): any;
|
|
42
|
+
}>;
|
|
43
|
+
export default _default;
|
|
44
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
45
|
+
new (): {
|
|
46
|
+
$slots: S;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Ref, type MaybeRef } from 'vue';
|
|
2
|
+
import type { Options, Toast } from './../../types.js';
|
|
3
|
+
type Args = {
|
|
4
|
+
id: MaybeRef<string>;
|
|
5
|
+
mappedOptions: Options;
|
|
6
|
+
count: Ref<number | undefined>;
|
|
7
|
+
oldest: Ref<Toast | undefined>;
|
|
8
|
+
};
|
|
9
|
+
export declare function useToastCallback({ id, mappedOptions, count, oldest }: Args): {
|
|
10
|
+
onBeforeEnter: (_el: Element) => void;
|
|
11
|
+
onEnter: (_el: Element) => void;
|
|
12
|
+
onAfterEnter: (el: Element) => void;
|
|
13
|
+
onBeforeLeave: (_el: Element) => void;
|
|
14
|
+
onLeave: (el: Element) => void;
|
|
15
|
+
onAfterLeave: (_el: Element) => void;
|
|
16
|
+
activeElements: Ref<{
|
|
17
|
+
id: string;
|
|
18
|
+
height: number;
|
|
19
|
+
}[]>;
|
|
20
|
+
};
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { ref, toValue } from "vue";
|
|
2
|
+
import { useToastEmitter } from "./../useToastEmitter.mjs";
|
|
3
|
+
export function useToastCallback({ id, mappedOptions, count, oldest }) {
|
|
4
|
+
const activeElements = ref([]);
|
|
5
|
+
function onBeforeEnter(_el) {
|
|
6
|
+
useToastEmitter().emit("beforeEnter", toValue(id));
|
|
7
|
+
}
|
|
8
|
+
function onEnter(_el) {
|
|
9
|
+
useToastEmitter().emit("enter", toValue(id));
|
|
10
|
+
if (count.value && mappedOptions.layout?.max && count.value > mappedOptions.layout.max) {
|
|
11
|
+
oldest.value?.remove();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function onAfterEnter(el) {
|
|
15
|
+
useToastEmitter().emit("afterEnter", toValue(id));
|
|
16
|
+
const mappedEl = el;
|
|
17
|
+
activeElements.value = [
|
|
18
|
+
...activeElements.value,
|
|
19
|
+
{ id: el.id, height: mappedEl.offsetHeight }
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
function onBeforeLeave(_el) {
|
|
23
|
+
useToastEmitter().emit("beforeLeave", toValue(id));
|
|
24
|
+
}
|
|
25
|
+
function onLeave(el) {
|
|
26
|
+
useToastEmitter().emit("leave", toValue(id));
|
|
27
|
+
activeElements.value = activeElements.value.filter(
|
|
28
|
+
(item) => item.id !== el.id
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
function onAfterLeave(_el) {
|
|
32
|
+
useToastEmitter().emit("afterLeave", toValue(id));
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
onBeforeEnter,
|
|
36
|
+
onEnter,
|
|
37
|
+
onAfterEnter,
|
|
38
|
+
onBeforeLeave,
|
|
39
|
+
onLeave,
|
|
40
|
+
onAfterLeave,
|
|
41
|
+
activeElements
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from "uuid";
|
|
2
|
+
export function useToastInternalApi() {
|
|
3
|
+
function removeToastAfterTimeout(id, duration, ctx) {
|
|
4
|
+
if (duration > 0) {
|
|
5
|
+
setTimeout(() => {
|
|
6
|
+
ctx.remove(id);
|
|
7
|
+
}, duration);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
function addToast(args, ctx) {
|
|
11
|
+
const id = uuidv4();
|
|
12
|
+
let { component, props, duration = 0 } = args;
|
|
13
|
+
const toast = {
|
|
14
|
+
component,
|
|
15
|
+
props,
|
|
16
|
+
id,
|
|
17
|
+
remove: () => ctx.remove(id)
|
|
18
|
+
};
|
|
19
|
+
ctx.toasts.push(toast);
|
|
20
|
+
removeToastAfterTimeout(id, duration, ctx);
|
|
21
|
+
return id;
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
addToast
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ToastInstance, AddArgs } from '../../types.js';
|
|
2
|
+
export declare function useToastStore(): {
|
|
3
|
+
toastStore: import("vue").Ref<{
|
|
4
|
+
id: string;
|
|
5
|
+
toasts: {
|
|
6
|
+
id: string;
|
|
7
|
+
component: Object;
|
|
8
|
+
props?: Record<string, any> | undefined;
|
|
9
|
+
remove: Function;
|
|
10
|
+
}[];
|
|
11
|
+
add: (args: AddArgs) => string;
|
|
12
|
+
remove: (id: string) => void;
|
|
13
|
+
}[]>;
|
|
14
|
+
findInstance: (id: string) => ToastInstance | undefined;
|
|
15
|
+
addInstance: (id: string) => ToastInstance;
|
|
16
|
+
removeInstance: (id: string) => void;
|
|
17
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ref } from "vue";
|
|
2
|
+
import { useToastInternalApi } from "./useToastInternalApi.mjs";
|
|
3
|
+
const toastStore = ref([]);
|
|
4
|
+
export function useToastStore() {
|
|
5
|
+
const { addToast } = useToastInternalApi();
|
|
6
|
+
function createInstance(id) {
|
|
7
|
+
const instance = {
|
|
8
|
+
id,
|
|
9
|
+
toasts: [],
|
|
10
|
+
add: function(args) {
|
|
11
|
+
return addToast(args, this);
|
|
12
|
+
},
|
|
13
|
+
remove: function(id2) {
|
|
14
|
+
this.toasts = this.toasts.filter((toast) => toast.id !== id2);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
return instance;
|
|
18
|
+
}
|
|
19
|
+
function findInstance(id) {
|
|
20
|
+
const instance = toastStore.value.find(
|
|
21
|
+
(instance2) => instance2.id === id
|
|
22
|
+
);
|
|
23
|
+
return instance;
|
|
24
|
+
}
|
|
25
|
+
function addInstance(id) {
|
|
26
|
+
const instance = createInstance(id);
|
|
27
|
+
toastStore.value.push(instance);
|
|
28
|
+
return instance;
|
|
29
|
+
}
|
|
30
|
+
function removeInstance(id) {
|
|
31
|
+
toastStore.value = toastStore.value.filter(
|
|
32
|
+
(instance) => instance.id !== id
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
toastStore,
|
|
37
|
+
findInstance,
|
|
38
|
+
addInstance,
|
|
39
|
+
removeInstance
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type MaybeRef } from 'vue';
|
|
2
|
+
import type { AddArgs } from './../types.js';
|
|
3
|
+
export declare function useToastApi(id?: MaybeRef<string>): {
|
|
4
|
+
toasts: import("vue").ComputedRef<import("./../types").Toast[] | undefined>;
|
|
5
|
+
count: import("vue").ComputedRef<number | undefined>;
|
|
6
|
+
oldest: import("vue").ComputedRef<import("./../types").Toast | undefined>;
|
|
7
|
+
add: (options: Pick<AddArgs, 'component' | 'props' | 'duration'>) => Promise<string | undefined>;
|
|
8
|
+
remove: (id: string) => void;
|
|
9
|
+
clear: () => void;
|
|
10
|
+
};
|
|
11
|
+
export type UseToastApiReturn = ReturnType<typeof useToastApi>;
|