@maas/vue-equipment 0.29.2 → 0.29.3
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.js +5 -10
- package/dist/composables/index.js.map +1 -1
- package/dist/composables/index.mjs +5 -10
- package/dist/composables/index.mjs.map +1 -1
- package/dist/nuxt/module.json +1 -1
- package/dist/nuxt/module.mjs +16 -9
- package/dist/plugins/MagicCommand/index.d.ts +2 -4
- package/dist/plugins/MagicCommand/index.mjs +2 -2
- package/dist/plugins/MagicCommand/src/components/MagicCommandBody.vue +3 -3
- package/dist/plugins/MagicCommand/src/components/MagicCommandDrawer.vue +2 -2
- package/dist/plugins/MagicCommand/src/components/MagicCommandDrawer.vue.d.ts +2 -2
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.vue +4 -4
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.vue.d.ts +5 -5
- package/dist/plugins/MagicCommand/src/components/MagicCommandModal.vue +2 -2
- package/dist/plugins/MagicCommand/src/components/MagicCommandModal.vue.d.ts +2 -2
- package/dist/plugins/MagicCommand/src/components/MagicCommandProvider.vue +4 -4
- package/dist/plugins/MagicCommand/src/components/MagicCommandProvider.vue.d.ts +5 -5
- package/dist/plugins/MagicCommand/src/components/MagicCommandView.vue +4 -2
- package/dist/plugins/MagicCommand/src/components/MagicCommandView.vue.d.ts +3 -3
- package/dist/plugins/MagicCommand/src/composables/private/useCommandScroll.mjs +1 -1
- package/dist/plugins/MagicCommand/src/composables/private/useCommandStore.mjs +1 -1
- package/dist/plugins/MagicCommand/src/symbols/index.d.ts +3 -3
- package/dist/plugins/MagicCommand/src/symbols/index.mjs +2 -2
- package/dist/plugins/MagicCommand/src/types/index.d.ts +5 -5
- package/dist/plugins/MagicCommand/src/utils/defaultOptions.d.ts +2 -2
- package/dist/plugins/MagicCookie/index.d.ts +0 -2
- package/dist/plugins/MagicCookie/src/components/MagicCookie.vue +6 -7
- package/dist/plugins/MagicCookie/src/components/MagicCookie.vue.d.ts +6 -6
- package/dist/plugins/MagicCookie/src/composables/private/useCookieApi.d.ts +17 -0
- package/dist/plugins/MagicCookie/src/composables/private/{defineCookieApi.mjs → useCookieApi.mjs} +4 -4
- package/dist/plugins/MagicCookie/src/composables/useMagicCookie.d.ts +5 -5
- package/dist/plugins/MagicCookie/src/composables/useMagicCookie.mjs +4 -4
- package/dist/plugins/MagicCookie/src/types/index.d.ts +6 -10
- package/dist/plugins/MagicDraggable/index.d.ts +2 -2
- package/dist/plugins/MagicDraggable/src/components/MagicDraggable.vue +4 -4
- package/dist/plugins/MagicDraggable/src/components/MagicDraggable.vue.d.ts +6 -6
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableState.d.ts +1 -2
- package/dist/plugins/MagicDraggable/src/types/index.d.ts +1 -1
- package/dist/plugins/MagicDraggable/src/utils/defaultOptions.d.ts +4 -4
- package/dist/plugins/MagicDrawer/index.d.ts +2 -2
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue +3 -4
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue.d.ts +3 -3
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerCallback.d.ts +2 -2
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDOM.d.ts +3 -3
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDOM.mjs +2 -2
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDrag.mjs +3 -1
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerProgress.mjs +3 -1
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.mjs +1 -3
- package/dist/plugins/MagicDrawer/src/types/index.d.ts +1 -1
- package/dist/plugins/MagicDrawer/src/utils/defaultOptions.d.ts +7 -7
- package/dist/plugins/MagicEmitter/src/composables/useMagicEmitter.d.ts +494 -170
- package/dist/plugins/MagicEmitter/src/types/index.d.ts +9 -9
- package/dist/plugins/MagicMarquee/nuxt.mjs +1 -5
- package/dist/plugins/MagicMarquee/src/components/MagicMarquee.vue +3 -3
- package/dist/plugins/MagicMarquee/src/components/MagicMarquee.vue.d.ts +3 -3
- package/dist/plugins/MagicMenu/index.d.ts +4 -0
- package/dist/plugins/MagicMenu/index.mjs +27 -0
- package/dist/plugins/MagicMenu/nuxt.d.ts +2 -0
- package/dist/plugins/MagicMenu/nuxt.mjs +14 -0
- package/dist/plugins/MagicMenu/src/components/MagicMenuContent.vue +140 -0
- package/dist/plugins/MagicMenu/src/components/MagicMenuContent.vue.d.ts +26 -0
- package/dist/plugins/MagicMenu/src/components/MagicMenuFloat.vue +169 -0
- package/dist/plugins/MagicMenu/src/components/MagicMenuFloat.vue.d.ts +24 -0
- package/dist/plugins/MagicMenu/src/components/MagicMenuItem.vue +137 -0
- package/dist/plugins/MagicMenu/src/components/MagicMenuItem.vue.d.ts +29 -0
- package/dist/plugins/MagicMenu/src/components/MagicMenuProvider.vue +106 -0
- package/dist/plugins/MagicMenu/src/components/MagicMenuProvider.vue.d.ts +24 -0
- package/dist/plugins/MagicMenu/src/components/MagicMenuTrigger.vue +122 -0
- package/dist/plugins/MagicMenu/src/components/MagicMenuTrigger.vue.d.ts +26 -0
- package/dist/plugins/MagicMenu/src/components/MagicMenuView.vue +53 -0
- package/dist/plugins/MagicMenu/src/components/MagicMenuView.vue.d.ts +21 -0
- package/dist/plugins/MagicMenu/src/composables/private/useMenuCallback.d.ts +18 -0
- package/dist/plugins/MagicMenu/src/composables/private/useMenuCallback.mjs +52 -0
- package/dist/plugins/MagicMenu/src/composables/private/useMenuDOM.d.ts +6 -0
- package/dist/plugins/MagicMenu/src/composables/private/useMenuDOM.mjs +42 -0
- package/dist/plugins/MagicMenu/src/composables/private/useMenuItem.d.ts +15 -0
- package/dist/plugins/MagicMenu/src/composables/private/useMenuItem.mjs +75 -0
- package/dist/plugins/MagicMenu/src/composables/private/useMenuKeyListener.d.ts +10 -0
- package/dist/plugins/MagicMenu/src/composables/private/useMenuKeyListener.mjs +178 -0
- package/dist/plugins/MagicMenu/src/composables/private/useMenuState.d.ts +7 -0
- package/dist/plugins/MagicMenu/src/composables/private/useMenuState.mjs +48 -0
- package/dist/plugins/MagicMenu/src/composables/private/useMenuTrigger.d.ts +18 -0
- package/dist/plugins/MagicMenu/src/composables/private/useMenuTrigger.mjs +262 -0
- package/dist/plugins/MagicMenu/src/composables/private/useMenuUtils.d.ts +3 -0
- package/dist/plugins/MagicMenu/src/composables/private/useMenuUtils.mjs +16 -0
- package/dist/plugins/MagicMenu/src/composables/private/useMenuView.d.ts +20 -0
- package/dist/plugins/MagicMenu/src/composables/private/useMenuView.mjs +116 -0
- package/dist/plugins/MagicMenu/src/symbols/index.d.ts +9 -0
- package/dist/plugins/MagicMenu/src/symbols/index.mjs +16 -0
- package/dist/plugins/MagicMenu/src/types/index.d.ts +72 -0
- package/dist/plugins/MagicMenu/src/types/index.mjs +0 -0
- package/dist/plugins/MagicMenu/src/utils/defaultOptions.d.ts +4 -0
- package/dist/plugins/MagicMenu/src/utils/defaultOptions.mjs +9 -0
- package/dist/plugins/MagicModal/index.d.ts +2 -2
- package/dist/plugins/MagicModal/src/components/MagicModal.vue +4 -4
- package/dist/plugins/MagicModal/src/components/MagicModal.vue.d.ts +5 -5
- package/dist/plugins/MagicModal/src/composables/private/useModalCallback.d.ts +2 -2
- package/dist/plugins/MagicModal/src/composables/private/useModalDOM.d.ts +3 -3
- package/dist/plugins/MagicModal/src/composables/private/useModalDOM.mjs +2 -2
- package/dist/plugins/MagicModal/src/types/index.d.ts +1 -1
- package/dist/plugins/MagicModal/src/utils/defaultOptions.d.ts +2 -2
- package/dist/plugins/MagicNoise/index.d.ts +1 -2
- package/dist/plugins/MagicNoise/index.mjs +1 -2
- package/dist/plugins/MagicNoise/nuxt.mjs +1 -5
- package/dist/plugins/MagicNoise/src/components/MagicNoise.vue +4 -4
- package/dist/plugins/MagicNoise/src/components/MagicNoise.vue.d.ts +5 -5
- package/dist/plugins/MagicNoise/src/composables/private/useNoiseApi.d.ts +2 -2
- package/dist/plugins/MagicNoise/src/types/index.d.ts +1 -1
- package/dist/plugins/MagicNoise/src/utils/defaultOptions.d.ts +2 -2
- package/dist/plugins/MagicPlayer/index.d.ts +0 -1
- package/dist/plugins/MagicPlayer/src/components/MagicAudioPlayer.vue +2 -2
- package/dist/plugins/MagicPlayer/src/components/MagicAudioPlayer.vue.d.ts +3 -3
- package/dist/plugins/MagicPlayer/src/components/MagicAudioPlayerControls.vue +2 -2
- package/dist/plugins/MagicPlayer/src/components/MagicAudioPlayerControls.vue.d.ts +2 -2
- package/dist/plugins/MagicPlayer/src/components/MagicPlayer.vue +9 -30
- package/dist/plugins/MagicPlayer/src/components/MagicPlayer.vue.d.ts +10 -14
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerControls.vue +79 -56
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerControls.vue.d.ts +20 -2
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerDisplayTime.vue +2 -2
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerDisplayTime.vue.d.ts +3 -3
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerMuxPopover.vue +9 -7
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerMuxPopover.vue.d.ts +2 -2
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerOverlay.vue +2 -2
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerOverlay.vue.d.ts +2 -2
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerTimeline.vue +2 -3
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerTimeline.vue.d.ts +2 -2
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerMediaApi.mjs +3 -0
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerRuntime.d.ts +2 -2
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerRuntime.mjs +23 -4
- package/dist/plugins/MagicPlayer/src/types/index.d.ts +1 -1
- package/dist/plugins/MagicScroll/index.d.ts +3 -3
- package/dist/plugins/MagicScroll/index.mjs +1 -2
- package/dist/plugins/MagicScroll/src/components/MagicScrollCollision.vue +11 -7
- package/dist/plugins/MagicScroll/src/components/MagicScrollCollision.vue.d.ts +2 -2
- package/dist/plugins/MagicScroll/src/components/MagicScrollMotion.vue +2 -2
- package/dist/plugins/MagicScroll/src/components/MagicScrollMotion.vue.d.ts +3 -3
- package/dist/plugins/MagicScroll/src/components/MagicScrollProvider.vue +2 -2
- package/dist/plugins/MagicScroll/src/components/MagicScrollProvider.vue.d.ts +3 -3
- package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue +2 -2
- package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue.d.ts +3 -3
- package/dist/plugins/MagicScroll/src/components/MagicScrollTransform.vue +2 -2
- package/dist/plugins/MagicScroll/src/components/MagicScrollTransform.vue.d.ts +3 -3
- package/dist/plugins/MagicScroll/src/composables/private/useCollisionDetect.d.ts +28 -0
- package/dist/plugins/MagicScroll/src/composables/private/useCollisionDetect.mjs +144 -0
- package/dist/plugins/MagicScroll/src/composables/private/useScrollApi.d.ts +0 -1
- package/dist/plugins/MagicScroll/src/types/index.d.ts +19 -25
- package/dist/plugins/MagicToast/index.d.ts +0 -2
- package/dist/plugins/MagicToast/src/components/MagicToast.vue +4 -4
- package/dist/plugins/MagicToast/src/components/MagicToast.vue.d.ts +2 -2
- package/dist/plugins/MagicToast/src/components/MagicToastComponent.vue +4 -4
- package/dist/plugins/MagicToast/src/components/MagicToastComponent.vue.d.ts +5 -5
- package/dist/plugins/MagicToast/src/composables/private/useToastApi.d.ts +1 -1
- package/dist/plugins/MagicToast/src/composables/private/useToastCallback.d.ts +3 -3
- package/dist/plugins/MagicToast/src/composables/private/useToastCallback.mjs +5 -7
- package/dist/plugins/MagicToast/src/composables/private/useToastInternalApi.d.ts +2 -2
- package/dist/plugins/MagicToast/src/composables/private/useToastStore.d.ts +4 -14
- package/dist/plugins/MagicToast/src/composables/useMagicToast.d.ts +6 -6
- package/dist/plugins/MagicToast/src/types/index.d.ts +20 -21
- package/dist/plugins/MagicToast/src/utils/defaultOptions.d.ts +2 -2
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.mjs +1 -0
- package/dist/utils/index.js +4 -8
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +4 -8
- package/dist/utils/index.mjs.map +1 -1
- package/package.json +9 -4
- package/dist/plugins/MagicCookie/src/composables/private/defineCookieApi.d.ts +0 -12
- package/dist/plugins/MagicScroll/src/composables/useCollisionDetect.d.ts +0 -6
- package/dist/plugins/MagicScroll/src/composables/useCollisionDetect.mjs +0 -119
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
<script setup lang="ts">
|
|
8
8
|
import { computed } from 'vue'
|
|
9
9
|
|
|
10
|
-
interface
|
|
10
|
+
interface MagicScrollTransformProps {
|
|
11
11
|
as?: string
|
|
12
12
|
scale?: number
|
|
13
13
|
scaleX?: number
|
|
@@ -18,7 +18,7 @@ interface Props {
|
|
|
18
18
|
translateY?: number
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const props = withDefaults(defineProps<
|
|
21
|
+
const props = withDefaults(defineProps<MagicScrollTransformProps>(), {
|
|
22
22
|
as: 'div',
|
|
23
23
|
scale: 1,
|
|
24
24
|
scaleX: 1,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
interface
|
|
1
|
+
interface MagicScrollTransformProps {
|
|
2
2
|
as?: string;
|
|
3
3
|
scale?: number;
|
|
4
4
|
scaleX?: number;
|
|
@@ -8,7 +8,7 @@ interface Props {
|
|
|
8
8
|
translateX?: number;
|
|
9
9
|
translateY?: number;
|
|
10
10
|
}
|
|
11
|
-
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<
|
|
11
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<MagicScrollTransformProps>, {
|
|
12
12
|
as: string;
|
|
13
13
|
scale: number;
|
|
14
14
|
scaleX: number;
|
|
@@ -17,7 +17,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
17
17
|
skewY: number;
|
|
18
18
|
translateX: number;
|
|
19
19
|
translateY: number;
|
|
20
|
-
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<
|
|
20
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<MagicScrollTransformProps>, {
|
|
21
21
|
as: string;
|
|
22
22
|
scale: number;
|
|
23
23
|
scaleX: number;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type MaybeRef } from 'vue';
|
|
2
|
+
import type { MagicScrollCollisionEntry, Offset } from '../../types.js';
|
|
3
|
+
type UseCollisionDetectArgs = {
|
|
4
|
+
scrollY: MaybeRef<number>;
|
|
5
|
+
entries: MagicScrollCollisionEntry[];
|
|
6
|
+
parent: HTMLElement | undefined;
|
|
7
|
+
};
|
|
8
|
+
export declare function useCollisionDetect(args: UseCollisionDetectArgs): {
|
|
9
|
+
mappedEntries: import("vue").Ref<{
|
|
10
|
+
element: HTMLElement;
|
|
11
|
+
alerted: {
|
|
12
|
+
up: {
|
|
13
|
+
top: boolean;
|
|
14
|
+
bottom: boolean;
|
|
15
|
+
};
|
|
16
|
+
down: {
|
|
17
|
+
top: boolean;
|
|
18
|
+
bottom: boolean;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
data: Record<string, unknown>;
|
|
22
|
+
offset?: {
|
|
23
|
+
top: Offset;
|
|
24
|
+
bottom: Offset;
|
|
25
|
+
} | undefined;
|
|
26
|
+
}[]>;
|
|
27
|
+
};
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { ref, watch, computed, toValue } from "vue";
|
|
2
|
+
import { useIntersectionObserver, useWindowSize } from "@vueuse/core";
|
|
3
|
+
import { useMagicEmitter } from "@maas/vue-equipment/plugins";
|
|
4
|
+
export function useCollisionDetect(args) {
|
|
5
|
+
const { scrollY, entries, parent } = args;
|
|
6
|
+
const lastScrollY = ref(0);
|
|
7
|
+
const intersecting = ref();
|
|
8
|
+
const scrollDirection = ref();
|
|
9
|
+
const mappedEntries = ref([]);
|
|
10
|
+
const oppositeScrollDirection = computed(
|
|
11
|
+
() => scrollDirection.value === "up" ? "down" : "up"
|
|
12
|
+
);
|
|
13
|
+
const windowDimensions = useWindowSize();
|
|
14
|
+
function getOffset(payload) {
|
|
15
|
+
return typeof payload === "function" ? payload({
|
|
16
|
+
vh: toValue(windowDimensions.height),
|
|
17
|
+
vw: toValue(windowDimensions.width)
|
|
18
|
+
}) : payload ?? 0;
|
|
19
|
+
}
|
|
20
|
+
function initialize() {
|
|
21
|
+
if (!parent)
|
|
22
|
+
return;
|
|
23
|
+
mappedEntries.value = entries.map((entry) => {
|
|
24
|
+
const alerted = {
|
|
25
|
+
up: {
|
|
26
|
+
top: false,
|
|
27
|
+
bottom: false
|
|
28
|
+
},
|
|
29
|
+
down: {
|
|
30
|
+
top: false,
|
|
31
|
+
bottom: false
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
const offset = { top: 0, bottom: 0, ...entry.offset };
|
|
35
|
+
const element = entry.element ? parent?.querySelector(entry.element) : parent;
|
|
36
|
+
if (!element) {
|
|
37
|
+
return void 0;
|
|
38
|
+
} else {
|
|
39
|
+
return { ...entry, offset, element, alerted };
|
|
40
|
+
}
|
|
41
|
+
}).filter((element) => !!element);
|
|
42
|
+
useIntersectionObserver(
|
|
43
|
+
parent.querySelector("*"),
|
|
44
|
+
([{ isIntersecting }]) => {
|
|
45
|
+
intersecting.value = isIntersecting;
|
|
46
|
+
},
|
|
47
|
+
{ rootMargin: "50% 0px 50% 0px", threshold: 0.01 }
|
|
48
|
+
);
|
|
49
|
+
observeAll();
|
|
50
|
+
}
|
|
51
|
+
function observeAll() {
|
|
52
|
+
if (!lastScrollY.value) {
|
|
53
|
+
lastScrollY.value = toValue(scrollY);
|
|
54
|
+
resetAll();
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
scrollDirection.value = lastScrollY.value <= toValue(scrollY) ? "down" : "up";
|
|
58
|
+
lastScrollY.value = toValue(scrollY);
|
|
59
|
+
let i = mappedEntries.value.length;
|
|
60
|
+
while (i--) {
|
|
61
|
+
const entry = mappedEntries.value[i];
|
|
62
|
+
if (!entry.element)
|
|
63
|
+
return;
|
|
64
|
+
const boundingRect = entry.element.getBoundingClientRect();
|
|
65
|
+
if (scrollDirection.value) {
|
|
66
|
+
observeEntry({
|
|
67
|
+
position: "top",
|
|
68
|
+
direction: scrollDirection.value,
|
|
69
|
+
boundingRect,
|
|
70
|
+
entry
|
|
71
|
+
});
|
|
72
|
+
observeEntry({
|
|
73
|
+
position: "bottom",
|
|
74
|
+
direction: scrollDirection.value,
|
|
75
|
+
boundingRect,
|
|
76
|
+
entry
|
|
77
|
+
});
|
|
78
|
+
resetEntry({
|
|
79
|
+
position: "top",
|
|
80
|
+
direction: oppositeScrollDirection.value,
|
|
81
|
+
boundingRect,
|
|
82
|
+
entry
|
|
83
|
+
});
|
|
84
|
+
resetEntry({
|
|
85
|
+
position: "bottom",
|
|
86
|
+
direction: oppositeScrollDirection.value,
|
|
87
|
+
boundingRect,
|
|
88
|
+
entry
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function resetAll() {
|
|
94
|
+
mappedEntries.value = mappedEntries.value.map((entry) => {
|
|
95
|
+
const alerted = {
|
|
96
|
+
up: {
|
|
97
|
+
top: false,
|
|
98
|
+
bottom: false
|
|
99
|
+
},
|
|
100
|
+
down: {
|
|
101
|
+
top: false,
|
|
102
|
+
bottom: false
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
return { ...entry, alerted };
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
function observeEntry(args2) {
|
|
109
|
+
const { position, direction, boundingRect, entry } = args2;
|
|
110
|
+
const offset = getOffset(entry.offset[position] ?? 0);
|
|
111
|
+
if (entry.alerted[direction][position])
|
|
112
|
+
return;
|
|
113
|
+
if (direction === "down" && boundingRect[position] <= offset || direction === "up" && boundingRect[position] >= offset) {
|
|
114
|
+
entry.alerted[direction][position] = true;
|
|
115
|
+
useMagicEmitter().emit("collision", {
|
|
116
|
+
direction,
|
|
117
|
+
position,
|
|
118
|
+
element: entry.element,
|
|
119
|
+
data: entry.data
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function resetEntry(args2) {
|
|
124
|
+
const { position, direction, boundingRect, entry } = args2;
|
|
125
|
+
const offset = getOffset(entry.offset[position] ?? 0);
|
|
126
|
+
if (!entry.alerted[direction][position])
|
|
127
|
+
return;
|
|
128
|
+
if (direction === "down" && boundingRect[position] >= offset || direction === "up" && boundingRect[position] <= offset) {
|
|
129
|
+
entry.alerted[direction][position] = false;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
initialize();
|
|
133
|
+
watch(
|
|
134
|
+
() => toValue(scrollY),
|
|
135
|
+
() => {
|
|
136
|
+
if (intersecting.value) {
|
|
137
|
+
observeAll();
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
return {
|
|
142
|
+
mappedEntries
|
|
143
|
+
};
|
|
144
|
+
}
|
|
@@ -1,33 +1,27 @@
|
|
|
1
|
-
type
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
type CollisionEvents = {
|
|
6
|
-
collision: {
|
|
7
|
-
dir: 'up' | 'down';
|
|
8
|
-
pos: 'top' | 'bottom';
|
|
9
|
-
el: HTMLElement;
|
|
10
|
-
data?: Record<string, unknown>;
|
|
11
|
-
};
|
|
1
|
+
export type Dimensions = {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
12
4
|
};
|
|
13
|
-
|
|
5
|
+
export type ScrollDirection = 'up' | 'down';
|
|
6
|
+
export type Position = 'top' | 'bottom';
|
|
7
|
+
export type FromTo = 'top-top' | 'top-center' | 'top-bottom' | 'center-top' | 'center-center' | 'center-bottom' | 'bottom-top' | 'bottom-center' | 'bottom-bottom';
|
|
8
|
+
export type Offset = number | (({ vw, vh }: {
|
|
9
|
+
vw: number;
|
|
10
|
+
vh: number;
|
|
11
|
+
}) => number);
|
|
12
|
+
export interface MagicScrollCollisionEntry {
|
|
14
13
|
offset?: {
|
|
15
|
-
top:
|
|
16
|
-
bottom:
|
|
14
|
+
top: Offset;
|
|
15
|
+
bottom: Offset;
|
|
17
16
|
};
|
|
18
17
|
element?: string;
|
|
19
18
|
data: Record<string, unknown>;
|
|
20
19
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
export type ScrollEvents = {
|
|
21
|
+
collision: {
|
|
22
|
+
direction: ScrollDirection;
|
|
23
|
+
position: Position;
|
|
24
|
+
element: HTMLElement;
|
|
25
|
+
data?: Record<string, unknown>;
|
|
25
26
|
};
|
|
26
|
-
element: HTMLElement;
|
|
27
|
-
}
|
|
28
|
-
type Dimensions = {
|
|
29
|
-
width: number;
|
|
30
|
-
height: number;
|
|
31
27
|
};
|
|
32
|
-
type FromTo = 'top-top' | 'top-center' | 'top-bottom' | 'center-top' | 'center-center' | 'center-bottom' | 'bottom-top' | 'bottom-center' | 'bottom-bottom';
|
|
33
|
-
export type { FromTo, CollisionEvents, CollisionEntry, MappedCollisionEntry, Dimensions, };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import MagicToast from './src/components/MagicToast.vue.js';
|
|
2
2
|
import { useMagicToast } from './src/composables/useMagicToast.js';
|
|
3
3
|
import type { Plugin } from 'vue';
|
|
4
|
-
import type { ToastEvents } from './src/types/index.js';
|
|
5
4
|
declare const MagicToastPlugin: Plugin;
|
|
6
5
|
export { MagicToastPlugin, MagicToast, useMagicToast };
|
|
7
|
-
export type { ToastEvents };
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
:key="toast.id"
|
|
24
24
|
:index="index"
|
|
25
25
|
:total="count || 0"
|
|
26
|
-
:siblings="
|
|
26
|
+
:siblings="activeToasts"
|
|
27
27
|
:class="{
|
|
28
28
|
expanded: isExpanded,
|
|
29
29
|
}"
|
|
@@ -61,7 +61,7 @@ import { useMagicToast } from '../composables/useMagicToast'
|
|
|
61
61
|
|
|
62
62
|
import MagicToastComponent from './MagicToastComponent.vue'
|
|
63
63
|
|
|
64
|
-
import type {
|
|
64
|
+
import type { MagicToastOptions } from './../types/index'
|
|
65
65
|
|
|
66
66
|
import '@maas/vue-equipment/utils/css/animations/fade-out.css'
|
|
67
67
|
import '@maas/vue-equipment/utils/css/animations/slide-ltr-in.css'
|
|
@@ -72,7 +72,7 @@ import '@maas/vue-equipment/utils/css/animations/slide-btt-in.css'
|
|
|
72
72
|
interface MagicToastProps {
|
|
73
73
|
id: MaybeRef<string>
|
|
74
74
|
class: MaybeRef<string>
|
|
75
|
-
options?:
|
|
75
|
+
options?: MagicToastOptions
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
const props = defineProps<MagicToastProps>()
|
|
@@ -92,7 +92,7 @@ const {
|
|
|
92
92
|
onBeforeLeave,
|
|
93
93
|
onLeave,
|
|
94
94
|
onAfterLeave,
|
|
95
|
-
|
|
95
|
+
activeToasts,
|
|
96
96
|
} = useToastCallback({ id: props.id, mappedOptions, count, firstToast })
|
|
97
97
|
|
|
98
98
|
function onMouseenter() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type MaybeRef } from 'vue';
|
|
2
|
-
import type {
|
|
2
|
+
import type { MagicToastOptions } from './../types/index';
|
|
3
3
|
import '@maas/vue-equipment/utils/css/animations/fade-out.css';
|
|
4
4
|
import '@maas/vue-equipment/utils/css/animations/slide-ltr-in.css';
|
|
5
5
|
import '@maas/vue-equipment/utils/css/animations/slide-rtl-in.css';
|
|
@@ -8,7 +8,7 @@ import '@maas/vue-equipment/utils/css/animations/slide-btt-in.css';
|
|
|
8
8
|
interface MagicToastProps {
|
|
9
9
|
id: MaybeRef<string>;
|
|
10
10
|
class: MaybeRef<string>;
|
|
11
|
-
options?:
|
|
11
|
+
options?: MagicToastOptions;
|
|
12
12
|
}
|
|
13
13
|
declare const _default: import("vue").DefineComponent<__VLS_TypePropsToOption<MagicToastProps>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<MagicToastProps>>>, {}, {}>;
|
|
14
14
|
export default _default;
|
|
@@ -13,16 +13,16 @@
|
|
|
13
13
|
|
|
14
14
|
<script lang="ts" setup>
|
|
15
15
|
import { ref, computed, onMounted, watchEffect } from 'vue'
|
|
16
|
-
import { type
|
|
16
|
+
import { type ActiveToast } from './../types'
|
|
17
17
|
|
|
18
|
-
interface
|
|
18
|
+
interface MagicToastComponentProps {
|
|
19
19
|
index: number
|
|
20
20
|
total: number
|
|
21
21
|
id: string
|
|
22
|
-
siblings:
|
|
22
|
+
siblings: ActiveToast[]
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
const props = defineProps<
|
|
25
|
+
const props = defineProps<MagicToastComponentProps>()
|
|
26
26
|
const emit = defineEmits<{
|
|
27
27
|
mouseenter: [event: Event]
|
|
28
28
|
}>()
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
interface
|
|
1
|
+
import { type ActiveToast } from './../types';
|
|
2
|
+
interface MagicToastComponentProps {
|
|
3
3
|
index: number;
|
|
4
4
|
total: number;
|
|
5
5
|
id: string;
|
|
6
|
-
siblings:
|
|
6
|
+
siblings: ActiveToast[];
|
|
7
7
|
}
|
|
8
|
-
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_TypePropsToOption<
|
|
8
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_TypePropsToOption<MagicToastComponentProps>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
9
9
|
mouseenter: (event: Event) => void;
|
|
10
|
-
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<
|
|
10
|
+
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<MagicToastComponentProps>>> & {
|
|
11
11
|
onMouseenter?: ((event: Event) => any) | undefined;
|
|
12
12
|
}, {}, {}>, {
|
|
13
13
|
default?(_: {}): any;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type Ref, type MaybeRef } from 'vue';
|
|
2
|
-
import type {
|
|
2
|
+
import type { MagicToastOptions, Toast } from './../../types.js';
|
|
3
3
|
type UseToastCallbackArgs = {
|
|
4
4
|
id: MaybeRef<string>;
|
|
5
|
-
mappedOptions:
|
|
5
|
+
mappedOptions: MagicToastOptions;
|
|
6
6
|
count: Ref<number | undefined>;
|
|
7
7
|
firstToast: Ref<Toast | undefined>;
|
|
8
8
|
};
|
|
@@ -13,7 +13,7 @@ export declare function useToastCallback(args: UseToastCallbackArgs): {
|
|
|
13
13
|
onBeforeLeave: (_el: Element) => void;
|
|
14
14
|
onLeave: (el: Element) => void;
|
|
15
15
|
onAfterLeave: (_el: Element) => void;
|
|
16
|
-
|
|
16
|
+
activeToasts: Ref<{
|
|
17
17
|
id: string;
|
|
18
18
|
height: number;
|
|
19
19
|
padding: {
|
|
@@ -2,7 +2,7 @@ import { ref, toValue } from "vue";
|
|
|
2
2
|
import { useMagicEmitter } from "@maas/vue-equipment/plugins";
|
|
3
3
|
export function useToastCallback(args) {
|
|
4
4
|
const { id, mappedOptions, count, firstToast } = args;
|
|
5
|
-
const
|
|
5
|
+
const activeToasts = ref([]);
|
|
6
6
|
const emitter = useMagicEmitter();
|
|
7
7
|
function onBeforeEnter(_el) {
|
|
8
8
|
emitter.emit("beforeEnter", toValue(id));
|
|
@@ -17,8 +17,8 @@ export function useToastCallback(args) {
|
|
|
17
17
|
emitter.emit("afterEnter", toValue(id));
|
|
18
18
|
const mappedEl = el;
|
|
19
19
|
const style = window.getComputedStyle(mappedEl);
|
|
20
|
-
|
|
21
|
-
...
|
|
20
|
+
activeToasts.value = [
|
|
21
|
+
...activeToasts.value,
|
|
22
22
|
{
|
|
23
23
|
id: el.id,
|
|
24
24
|
height: mappedEl.offsetHeight,
|
|
@@ -34,9 +34,7 @@ export function useToastCallback(args) {
|
|
|
34
34
|
}
|
|
35
35
|
function onLeave(el) {
|
|
36
36
|
emitter.emit("leave", toValue(id));
|
|
37
|
-
|
|
38
|
-
(item) => item.id !== el.id
|
|
39
|
-
);
|
|
37
|
+
activeToasts.value = activeToasts.value.filter((item) => item.id !== el.id);
|
|
40
38
|
}
|
|
41
39
|
function onAfterLeave(_el) {
|
|
42
40
|
emitter.emit("afterLeave", toValue(id));
|
|
@@ -48,6 +46,6 @@ export function useToastCallback(args) {
|
|
|
48
46
|
onBeforeLeave,
|
|
49
47
|
onLeave,
|
|
50
48
|
onAfterLeave,
|
|
51
|
-
|
|
49
|
+
activeToasts
|
|
52
50
|
};
|
|
53
51
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ToastInstance,
|
|
1
|
+
import type { ToastInstance, AddToastArgs } from './../../types.js';
|
|
2
2
|
export declare function useToastInternalApi(): {
|
|
3
|
-
addToast: (args:
|
|
3
|
+
addToast: (args: AddToastArgs, ctx: ToastInstance) => string;
|
|
4
4
|
};
|
|
@@ -1,17 +1,7 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MagicToastInstance } from '../../types.js';
|
|
2
2
|
export declare function useToastStore(): {
|
|
3
|
-
toastStore: import("vue").Ref<
|
|
4
|
-
|
|
5
|
-
|
|
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;
|
|
3
|
+
toastStore: import("vue").Ref<any[]>;
|
|
4
|
+
findInstance: (id: string) => MagicToastInstance | undefined;
|
|
5
|
+
addInstance: (id: string) => MagicToastInstance;
|
|
16
6
|
removeInstance: (id: string) => void;
|
|
17
7
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { type MaybeRef } from 'vue';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AddToastArgs } from './../types.js';
|
|
3
3
|
export declare function useMagicToast(id: MaybeRef<string>): {
|
|
4
|
-
toasts: import("vue").ComputedRef<
|
|
5
|
-
count: import("vue").ComputedRef<
|
|
6
|
-
firstToast: import("vue").ComputedRef<
|
|
7
|
-
lastToast: import("vue").ComputedRef<
|
|
8
|
-
add: (options:
|
|
4
|
+
toasts: import("vue").ComputedRef<any>;
|
|
5
|
+
count: import("vue").ComputedRef<any>;
|
|
6
|
+
firstToast: import("vue").ComputedRef<any>;
|
|
7
|
+
lastToast: import("vue").ComputedRef<any>;
|
|
8
|
+
add: (options: AddToastArgs) => Promise<any>;
|
|
9
9
|
remove: (toastId: string) => void;
|
|
10
10
|
clear: () => void;
|
|
11
11
|
};
|
|
@@ -1,31 +1,21 @@
|
|
|
1
1
|
import type { MaybeRef } from 'vue';
|
|
2
2
|
import type { PickPartial } from '@maas/vue-equipment/utils';
|
|
3
|
-
type Toast = {
|
|
3
|
+
export type Toast = {
|
|
4
4
|
id: string;
|
|
5
5
|
component: Object;
|
|
6
6
|
props?: MaybeRef<Record<string, any>>;
|
|
7
7
|
remove: Function;
|
|
8
8
|
};
|
|
9
|
-
type
|
|
9
|
+
export type AddToastArgs = Pick<Toast, 'component'> & PickPartial<Toast, 'props'> & {
|
|
10
|
+
duration?: number;
|
|
11
|
+
};
|
|
12
|
+
export type ToastInstance = {
|
|
10
13
|
id: string;
|
|
11
14
|
toasts: Toast[];
|
|
12
|
-
add: (args:
|
|
15
|
+
add: (args: AddToastArgs) => string;
|
|
13
16
|
remove: (id: string) => void;
|
|
14
17
|
};
|
|
15
|
-
type
|
|
16
|
-
teleport?: {
|
|
17
|
-
target?: string;
|
|
18
|
-
disabled?: boolean;
|
|
19
|
-
};
|
|
20
|
-
transitions?: {
|
|
21
|
-
list: string;
|
|
22
|
-
};
|
|
23
|
-
layout?: {
|
|
24
|
-
expand?: boolean | 'hover' | 'click';
|
|
25
|
-
max?: false | number;
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
type ActiveElement = {
|
|
18
|
+
export type ActiveToast = {
|
|
29
19
|
id: string;
|
|
30
20
|
height: number;
|
|
31
21
|
padding: {
|
|
@@ -33,7 +23,7 @@ type ActiveElement = {
|
|
|
33
23
|
bottom: number;
|
|
34
24
|
};
|
|
35
25
|
};
|
|
36
|
-
type ToastEvents = {
|
|
26
|
+
export type ToastEvents = {
|
|
37
27
|
beforeEnter: string;
|
|
38
28
|
enter: string;
|
|
39
29
|
afterEnter: string;
|
|
@@ -41,7 +31,16 @@ type ToastEvents = {
|
|
|
41
31
|
leave: string;
|
|
42
32
|
afterLeave: string;
|
|
43
33
|
};
|
|
44
|
-
type
|
|
45
|
-
|
|
34
|
+
export type MagicToastOptions = {
|
|
35
|
+
teleport?: {
|
|
36
|
+
target?: string;
|
|
37
|
+
disabled?: boolean;
|
|
38
|
+
};
|
|
39
|
+
transitions?: {
|
|
40
|
+
list: string;
|
|
41
|
+
};
|
|
42
|
+
layout?: {
|
|
43
|
+
expand?: boolean | 'hover' | 'click';
|
|
44
|
+
max?: false | number;
|
|
45
|
+
};
|
|
46
46
|
};
|
|
47
|
-
export type { Toast, ToastInstance, ToastOptions, ActiveElement, ToastEvents, AddArgs, };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MagicToastOptions } from '../types/index.js';
|
|
2
2
|
import type { RequireAll } from '@maas/vue-equipment/utils';
|
|
3
|
-
declare const defaultOptions: RequireAll<
|
|
3
|
+
declare const defaultOptions: RequireAll<MagicToastOptions>;
|
|
4
4
|
export { defaultOptions };
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './MagicDraggable/index.js';
|
|
|
4
4
|
export * from './MagicDrawer/index.js';
|
|
5
5
|
export * from './MagicEmitter/index.js';
|
|
6
6
|
export * from './MagicMarquee/index.js';
|
|
7
|
+
export * from './MagicMenu/index.js';
|
|
7
8
|
export * from './MagicModal/index.js';
|
|
8
9
|
export * from './MagicNoise/index.js';
|
|
9
10
|
export * from './MagicPlayer/index.js';
|
package/dist/plugins/index.mjs
CHANGED
|
@@ -4,6 +4,7 @@ export * from "./MagicDraggable/index.mjs";
|
|
|
4
4
|
export * from "./MagicDrawer/index.mjs";
|
|
5
5
|
export * from "./MagicEmitter/index.mjs";
|
|
6
6
|
export * from "./MagicMarquee/index.mjs";
|
|
7
|
+
export * from "./MagicMenu/index.mjs";
|
|
7
8
|
export * from "./MagicModal/index.mjs";
|
|
8
9
|
export * from "./MagicNoise/index.mjs";
|
|
9
10
|
export * from "./MagicPlayer/index.mjs";
|
package/dist/utils/index.js
CHANGED
|
@@ -123,8 +123,7 @@ function interpolate(args) {
|
|
|
123
123
|
const { from, to, duration, callback, easing = (t) => t * (2 - t) } = args;
|
|
124
124
|
let startTime;
|
|
125
125
|
function animate(timestamp) {
|
|
126
|
-
if (!startTime)
|
|
127
|
-
startTime = timestamp;
|
|
126
|
+
if (!startTime) startTime = timestamp;
|
|
128
127
|
const progress = Math.min(1, (timestamp - startTime) / duration);
|
|
129
128
|
const easedProgress = easing(progress);
|
|
130
129
|
const value = from + (to - from) * easedProgress;
|
|
@@ -138,8 +137,7 @@ function interpolate(args) {
|
|
|
138
137
|
|
|
139
138
|
// src/functions/isIOS.ts
|
|
140
139
|
function isIOS() {
|
|
141
|
-
if (typeof window === "undefined")
|
|
142
|
-
return false;
|
|
140
|
+
if (typeof window === "undefined") return false;
|
|
143
141
|
return /iPad|iPhone|iPod/.test(navigator == null ? void 0 : navigator.userAgent);
|
|
144
142
|
}
|
|
145
143
|
|
|
@@ -175,10 +173,8 @@ function slugify(string, options) {
|
|
|
175
173
|
const charMap = {};
|
|
176
174
|
let slug = string.normalize().split("").reduce(function(result, ch) {
|
|
177
175
|
let appendChar = charMap[ch];
|
|
178
|
-
if (appendChar === void 0)
|
|
179
|
-
|
|
180
|
-
if (appendChar === (_options == null ? void 0 : _options.separator))
|
|
181
|
-
appendChar = " ";
|
|
176
|
+
if (appendChar === void 0) appendChar = ch;
|
|
177
|
+
if (appendChar === (_options == null ? void 0 : _options.separator)) appendChar = " ";
|
|
182
178
|
return result + appendChar.replace((_options == null ? void 0 : _options.remove) || /[^\w\s$*_+~.()'"!\-:@]+/g, "");
|
|
183
179
|
}, "");
|
|
184
180
|
if (_options.strict) {
|