@maas/vue-equipment 0.27.2 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/composables/index.d.mts +1 -9
- package/dist/composables/index.d.ts +1 -9
- package/dist/composables/index.js +2 -55
- package/dist/composables/index.js.map +1 -1
- package/dist/composables/index.mjs +1 -53
- package/dist/composables/index.mjs.map +1 -1
- package/dist/nuxt/module.json +1 -1
- package/dist/nuxt/module.mjs +16 -16
- package/dist/plugins/MagicCommand/index.d.ts +3 -4
- package/dist/plugins/MagicCommand/index.mjs +8 -7
- package/dist/plugins/MagicCommand/nuxt.mjs +1 -5
- package/dist/plugins/MagicCommand/src/components/MagicCommandBody.vue +3 -3
- package/dist/plugins/MagicCommand/src/components/MagicCommandDrawer.vue +10 -8
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.vue +2 -2
- package/dist/plugins/MagicCommand/src/components/MagicCommandModal.vue +10 -8
- package/dist/plugins/MagicCommand/src/components/MagicCommandProvider.vue +6 -6
- package/dist/plugins/MagicCommand/src/components/MagicCommandView.vue +2 -2
- package/dist/plugins/MagicCommand/src/composables/{useCommandApi.d.ts → useMagicCommand.d.ts} +1 -1
- package/dist/plugins/MagicCommand/src/composables/{useCommandApi.mjs → useMagicCommand.mjs} +5 -7
- package/dist/plugins/MagicCommand/src/symbols/index.d.ts +3 -3
- package/dist/plugins/MagicCommand/src/symbols/index.mjs +3 -3
- package/dist/plugins/MagicCookie/index.d.ts +2 -3
- package/dist/plugins/MagicCookie/index.mjs +2 -3
- package/dist/plugins/MagicCookie/nuxt.mjs +1 -1
- package/dist/plugins/MagicCookie/src/components/MagicCookie.vue +2 -2
- package/dist/plugins/MagicCookie/src/composables/{useCookieApi.d.ts → useMagicCookie.d.ts} +2 -1
- package/dist/plugins/MagicCookie/src/composables/{useCookieApi.mjs → useMagicCookie.mjs} +3 -3
- package/dist/plugins/MagicDraggable/index.d.ts +1 -2
- package/dist/plugins/MagicDraggable/index.mjs +1 -2
- package/dist/plugins/MagicDraggable/src/components/MagicDraggable.vue +12 -10
- package/dist/plugins/MagicDraggable/src/components/MagicDraggable.vue.d.ts +2 -2
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableDrag.d.ts +1 -0
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableDrag.mjs +33 -3
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableScrollLock.d.ts +6 -0
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableScrollLock.mjs +42 -0
- package/dist/plugins/MagicDraggable/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicDraggable/src/utils/defaultOptions.d.ts +4 -1
- package/dist/plugins/MagicDraggable/src/utils/defaultOptions.mjs +2 -1
- package/dist/plugins/MagicDrawer/index.d.ts +2 -3
- package/dist/plugins/MagicDrawer/index.mjs +2 -3
- package/dist/plugins/MagicDrawer/nuxt.mjs +1 -5
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue +13 -23
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerCallback.mjs +10 -9
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDOM.d.ts +13 -0
- package/dist/plugins/MagicDrawer/src/composables/{useDrawerApi.mjs → private/useDrawerDOM.mjs} +4 -46
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDrag.mjs +14 -10
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerProgress.mjs +22 -20
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerSnap.mjs +5 -4
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.d.ts +4 -0
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.mjs +5 -1
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerUtils.d.ts +0 -7
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerUtils.mjs +1 -6
- package/dist/plugins/MagicDrawer/src/composables/useMagicDrawer.d.ts +13 -0
- package/dist/plugins/MagicDrawer/src/composables/useMagicDrawer.mjs +31 -0
- package/dist/plugins/MagicDrawer/src/types/index.d.ts +5 -1
- package/dist/plugins/MagicEmitter/index.d.ts +4 -0
- package/dist/plugins/MagicEmitter/index.mjs +2 -0
- package/dist/plugins/MagicEmitter/nuxt.d.ts +2 -0
- package/dist/plugins/MagicEmitter/nuxt.mjs +12 -0
- package/dist/plugins/MagicEmitter/src/composables/useMagicEmitter.d.ts +446 -0
- package/dist/plugins/{MagicModal/src/composables/useModalEmitter.mjs → MagicEmitter/src/composables/useMagicEmitter.mjs} +1 -1
- package/dist/plugins/MagicEmitter/src/types/index.d.ts +19 -0
- package/dist/plugins/MagicEmitter/src/types/index.mjs +0 -0
- package/dist/plugins/MagicMarquee/nuxt.mjs +1 -3
- package/dist/plugins/MagicMarquee/src/components/MagicMarquee.vue +1 -1
- package/dist/plugins/MagicModal/index.d.ts +2 -3
- package/dist/plugins/MagicModal/index.mjs +2 -3
- package/dist/plugins/MagicModal/nuxt.mjs +1 -5
- package/dist/plugins/MagicModal/src/components/MagicModal.vue +8 -9
- package/dist/plugins/MagicModal/src/composables/private/useModalCallback.mjs +10 -9
- package/dist/plugins/MagicModal/src/composables/private/useModalDOM.d.ts +13 -0
- package/dist/plugins/MagicModal/src/composables/{useModalApi.mjs → private/useModalDOM.mjs} +3 -17
- package/dist/plugins/MagicModal/src/composables/useMagicModal.d.ts +6 -0
- package/dist/plugins/MagicModal/src/composables/useMagicModal.mjs +17 -0
- package/dist/plugins/MagicNoise/index.d.ts +1 -1
- package/dist/plugins/MagicNoise/index.mjs +1 -1
- package/dist/plugins/MagicNoise/nuxt.mjs +1 -6
- package/dist/plugins/MagicNoise/src/components/MagicNoise.vue +2 -2
- package/dist/plugins/MagicNoise/src/composables/{useNoiseApi.d.ts → private/useNoiseApi.d.ts} +1 -1
- package/dist/plugins/MagicNoise/src/composables/{useNoiseApi.mjs → private/useNoiseApi.mjs} +1 -1
- package/dist/plugins/MagicPlayer/index.d.ts +2 -2
- package/dist/plugins/MagicPlayer/index.mjs +2 -2
- package/dist/plugins/MagicPlayer/nuxt.mjs +1 -1
- package/dist/plugins/MagicPlayer/src/composables/{usePlayerApi.d.ts → useMagicPlayer.d.ts} +2 -2
- package/dist/plugins/MagicPlayer/src/composables/{usePlayerApi.mjs → useMagicPlayer.mjs} +1 -1
- package/dist/plugins/MagicScroll/index.d.ts +2 -4
- package/dist/plugins/MagicScroll/index.mjs +6 -10
- package/dist/plugins/MagicScroll/src/components/MagicScrollCollision.vue +3 -3
- package/dist/plugins/MagicScroll/src/components/MagicScrollMotion.vue +2 -2
- package/dist/plugins/MagicScroll/src/components/MagicScrollProvider.vue +5 -5
- package/dist/plugins/MagicScroll/src/components/MagicScrollProvider.vue.d.ts +1 -1
- package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue +8 -8
- package/dist/plugins/MagicScroll/src/composables/{useScrollApi.d.ts → private/useScrollApi.d.ts} +1 -1
- package/dist/plugins/MagicScroll/src/composables/{useScrollApi.mjs → private/useScrollApi.mjs} +4 -4
- package/dist/plugins/MagicScroll/src/composables/useCollisionDetect.mjs +2 -2
- package/dist/plugins/MagicScroll/src/symbols/index.d.ts +4 -4
- package/dist/plugins/MagicScroll/src/symbols/index.mjs +4 -4
- package/dist/plugins/MagicScroll/src/types/index.d.ts +2 -2
- package/dist/plugins/MagicToast/index.d.ts +2 -3
- package/dist/plugins/MagicToast/index.mjs +2 -3
- package/dist/plugins/MagicToast/nuxt.mjs +0 -4
- package/dist/plugins/MagicToast/src/components/MagicToast.vue +5 -3
- package/dist/plugins/MagicToast/src/composables/private/useToastApi.d.ts +5 -0
- package/dist/plugins/MagicToast/src/composables/private/useToastApi.mjs +23 -0
- package/dist/plugins/MagicToast/src/composables/private/useToastCallback.d.ts +3 -3
- package/dist/plugins/MagicToast/src/composables/private/useToastCallback.mjs +11 -9
- package/dist/plugins/MagicToast/src/composables/useMagicToast.d.ts +12 -0
- package/dist/plugins/MagicToast/src/composables/useMagicToast.mjs +36 -0
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.mjs +1 -0
- package/dist/utils/index.d.mts +10 -1
- package/dist/utils/index.d.ts +10 -1
- package/dist/utils/index.js +8 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/index.mjs +7 -0
- package/dist/utils/index.mjs.map +1 -1
- package/dist/utils/types/ValueOf.ts +1 -0
- package/dist/utils/types/index.ts +1 -0
- package/package.json +1 -1
- package/dist/plugins/MagicCommand/src/composables/useCommandEmitter.d.ts +0 -15
- package/dist/plugins/MagicCommand/src/composables/useCommandEmitter.mjs +0 -9
- package/dist/plugins/MagicCookie/src/composables/useCookieEmitter.d.ts +0 -15
- package/dist/plugins/MagicCookie/src/composables/useCookieEmitter.mjs +0 -9
- package/dist/plugins/MagicDraggable/src/composables/useDraggableApi.d.ts +0 -1
- package/dist/plugins/MagicDraggable/src/composables/useDraggableApi.mjs +0 -2
- package/dist/plugins/MagicDrawer/src/composables/useDrawerApi.d.ts +0 -26
- package/dist/plugins/MagicDrawer/src/composables/useDrawerEmitter.d.ts +0 -15
- package/dist/plugins/MagicDrawer/src/composables/useDrawerEmitter.mjs +0 -9
- package/dist/plugins/MagicModal/src/composables/useModalApi.d.ts +0 -19
- package/dist/plugins/MagicModal/src/composables/useModalEmitter.d.ts +0 -15
- package/dist/plugins/MagicScroll/src/composables/useCollisionEmitter.d.ts +0 -15
- package/dist/plugins/MagicScroll/src/composables/useCollisionEmitter.mjs +0 -9
- package/dist/plugins/MagicToast/src/composables/useToastApi.d.ts +0 -13
- package/dist/plugins/MagicToast/src/composables/useToastApi.mjs +0 -50
- package/dist/plugins/MagicToast/src/composables/useToastEmitter.d.ts +0 -15
- package/dist/plugins/MagicToast/src/composables/useToastEmitter.mjs +0 -9
- /package/dist/plugins/MagicMarquee/src/composables/{useMarqueeApi.d.ts → private/useMarqueeApi.d.ts} +0 -0
- /package/dist/plugins/MagicMarquee/src/composables/{useMarqueeApi.mjs → private/useMarqueeApi.mjs} +0 -0
|
@@ -1,28 +1,18 @@
|
|
|
1
|
-
import { ref
|
|
1
|
+
import { ref } from "vue";
|
|
2
2
|
import { defu } from "defu";
|
|
3
3
|
import { useScrollLock } from "@vueuse/core";
|
|
4
4
|
import { useFocusTrap } from "@vueuse/integrations/useFocusTrap";
|
|
5
|
-
import {
|
|
6
|
-
import { useModalStore } from "./private/useModalStore.mjs";
|
|
5
|
+
import { matchClass } from "@maas/vue-equipment/utils";
|
|
7
6
|
const defaultOptions = {
|
|
8
7
|
focusTrap: false,
|
|
9
8
|
focusTarget: void 0,
|
|
10
9
|
scrollLock: true
|
|
11
10
|
};
|
|
12
11
|
const scrollLock = typeof window !== "undefined" ? useScrollLock(document?.documentElement) : ref(false);
|
|
13
|
-
export function
|
|
12
|
+
export function useModalDOM(options) {
|
|
14
13
|
const positionFixedElements = ref([]);
|
|
15
|
-
const mappedId = computed(() => toValue(id) || uuid());
|
|
16
14
|
const mappedOptions = defu(options, defaultOptions);
|
|
17
15
|
const focusTrap = mappedOptions.focusTarget ? typeof mappedOptions.focusTrap === "boolean" ? useFocusTrap(mappedOptions.focusTarget) : useFocusTrap(mappedOptions.focusTarget, mappedOptions.focusTrap) : void 0;
|
|
18
|
-
const { modalStore, addInstance, removeInstance } = useModalStore();
|
|
19
|
-
const isActive = computed(() => modalStore.value.includes(mappedId.value));
|
|
20
|
-
function open() {
|
|
21
|
-
addInstance(mappedId.value);
|
|
22
|
-
}
|
|
23
|
-
function close() {
|
|
24
|
-
removeInstance(mappedId.value);
|
|
25
|
-
}
|
|
26
16
|
function trapFocus() {
|
|
27
17
|
if (focusTrap) {
|
|
28
18
|
focusTrap.activate();
|
|
@@ -67,10 +57,6 @@ export function useModalApi(id, options) {
|
|
|
67
57
|
);
|
|
68
58
|
}
|
|
69
59
|
return {
|
|
70
|
-
id: mappedId,
|
|
71
|
-
isActive,
|
|
72
|
-
open,
|
|
73
|
-
close,
|
|
74
60
|
trapFocus,
|
|
75
61
|
releaseFocus,
|
|
76
62
|
lockScroll,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { computed, toValue } from "vue";
|
|
2
|
+
import { useModalStore } from "./private/useModalStore.mjs";
|
|
3
|
+
export function useMagicModal(id) {
|
|
4
|
+
const { modalStore, addInstance, removeInstance } = useModalStore();
|
|
5
|
+
const isActive = computed(() => modalStore.value.includes(toValue(id)));
|
|
6
|
+
function open() {
|
|
7
|
+
addInstance(toValue(id));
|
|
8
|
+
}
|
|
9
|
+
function close() {
|
|
10
|
+
removeInstance(toValue(id));
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
isActive,
|
|
14
|
+
open,
|
|
15
|
+
close
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Plugin } from 'vue';
|
|
2
2
|
import MagicNoise from './src/components/MagicNoise.vue.js';
|
|
3
|
-
import { useNoiseApi } from './src/composables/useNoiseApi.js';
|
|
3
|
+
import { useNoiseApi } from './src/composables/private/useNoiseApi.js';
|
|
4
4
|
declare const MagicNoisePlugin: Plugin;
|
|
5
5
|
export { MagicNoisePlugin, MagicNoise, useNoiseApi };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import MagicNoise from "./src/components/MagicNoise.vue";
|
|
2
|
-
import { useNoiseApi } from "./src/composables/useNoiseApi.mjs";
|
|
2
|
+
import { useNoiseApi } from "./src/composables/private/useNoiseApi.mjs";
|
|
3
3
|
const MagicNoisePlugin = {
|
|
4
4
|
install: (app) => {
|
|
5
5
|
app.component("MagicNoise", MagicNoise);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
defineNuxtModule,
|
|
3
3
|
createResolver,
|
|
4
|
-
addComponent
|
|
5
|
-
addImports
|
|
4
|
+
addComponent
|
|
6
5
|
} from "@nuxt/kit";
|
|
7
6
|
export default defineNuxtModule({
|
|
8
7
|
meta: {
|
|
@@ -15,9 +14,5 @@ export default defineNuxtModule({
|
|
|
15
14
|
name: "MagicNoise",
|
|
16
15
|
global: true
|
|
17
16
|
});
|
|
18
|
-
addImports({
|
|
19
|
-
from: "@maas/vue-equipment/plugins/MagicNoise",
|
|
20
|
-
name: "useNoiseApi"
|
|
21
|
-
});
|
|
22
17
|
}
|
|
23
18
|
});
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<script lang="ts" setup>
|
|
11
11
|
import { onMounted, onUnmounted, watch, shallowRef } from 'vue'
|
|
12
12
|
import { useResizeObserver, useDebounceFn } from '@vueuse/core'
|
|
13
|
-
import { useNoiseApi } from '../composables/useNoiseApi'
|
|
13
|
+
import { useNoiseApi } from '../composables/private/useNoiseApi'
|
|
14
14
|
import type { NoiseOptions } from '../types'
|
|
15
15
|
|
|
16
16
|
interface Props {
|
|
@@ -52,7 +52,7 @@ watch(
|
|
|
52
52
|
drawControls.value?.resume()
|
|
53
53
|
transferControls.value?.resume()
|
|
54
54
|
}
|
|
55
|
-
}
|
|
55
|
+
}
|
|
56
56
|
)
|
|
57
57
|
|
|
58
58
|
onMounted(() => {
|
package/dist/plugins/MagicNoise/src/composables/{useNoiseApi.d.ts → private/useNoiseApi.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Ref, type MaybeRef } from 'vue';
|
|
2
|
-
import type { NoiseOptions, RafControls } from '
|
|
2
|
+
import type { NoiseOptions, RafControls } from '../../types.js';
|
|
3
3
|
type UseNoiseApiArgs = {
|
|
4
4
|
canvasRef: Ref<HTMLCanvasElement | undefined>;
|
|
5
5
|
offCanvasRef: Ref<HTMLCanvasElement | undefined>;
|
|
@@ -6,7 +6,7 @@ import MagicPlayerMuxPopover from './src/components/MagicPlayerMuxPopover.vue.js
|
|
|
6
6
|
import MagicPlayerOverlay from './src/components/MagicPlayerOverlay.vue.js';
|
|
7
7
|
import MagicPlayerPoster from './src/components/MagicPlayerPoster.vue.js';
|
|
8
8
|
import MagicPlayerTimeline from './src/components/MagicPlayerTimeline.vue.js';
|
|
9
|
-
import {
|
|
9
|
+
import { useMagicPlayer } from './src/composables/useMagicPlayer.js';
|
|
10
10
|
declare const MagicPlayerPlugin: Plugin;
|
|
11
|
-
export { MagicPlayerPlugin, MagicPlayer, MagicPlayerControls, MagicPlayerDisplayTime, MagicPlayerMuxPopover, MagicPlayerPoster, MagicPlayerOverlay, MagicPlayerTimeline,
|
|
11
|
+
export { MagicPlayerPlugin, MagicPlayer, MagicPlayerControls, MagicPlayerDisplayTime, MagicPlayerMuxPopover, MagicPlayerPoster, MagicPlayerOverlay, MagicPlayerTimeline, useMagicPlayer, };
|
|
12
12
|
export type * from './src/types/index';
|
|
@@ -6,7 +6,7 @@ import MagicPlayerMuxPopover from "./src/components/MagicPlayerMuxPopover.vue";
|
|
|
6
6
|
import MagicPlayerOverlay from "./src/components/MagicPlayerOverlay.vue";
|
|
7
7
|
import MagicPlayerPoster from "./src/components/MagicPlayerPoster.vue";
|
|
8
8
|
import MagicPlayerTimeline from "./src/components/MagicPlayerTimeline.vue";
|
|
9
|
-
import {
|
|
9
|
+
import { useMagicPlayer } from "./src/composables/useMagicPlayer.mjs";
|
|
10
10
|
const MagicPlayerPlugin = {
|
|
11
11
|
install: (app) => {
|
|
12
12
|
app.component("MagicAudioPlayer", MagicAudioPlayer);
|
|
@@ -28,5 +28,5 @@ export {
|
|
|
28
28
|
MagicPlayerPoster,
|
|
29
29
|
MagicPlayerOverlay,
|
|
30
30
|
MagicPlayerTimeline,
|
|
31
|
-
|
|
31
|
+
useMagicPlayer
|
|
32
32
|
};
|
|
@@ -2,7 +2,7 @@ import type { MaybeRef } from '@vueuse/core';
|
|
|
2
2
|
type usePlayerApiArgs = {
|
|
3
3
|
id: MaybeRef<string>;
|
|
4
4
|
};
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function useMagicPlayer(args: usePlayerApiArgs): {
|
|
6
6
|
mediaApi: {
|
|
7
7
|
currentTime: import("vue").Ref<number>;
|
|
8
8
|
remainingTime: import("vue").ComputedRef<number>;
|
|
@@ -64,5 +64,5 @@ export declare function usePlayerApi(args: usePlayerApiArgs): {
|
|
|
64
64
|
destroy: () => void;
|
|
65
65
|
};
|
|
66
66
|
};
|
|
67
|
-
export type
|
|
67
|
+
export type UseMagicPlayerReturn = ReturnType<typeof useMagicPlayer>;
|
|
68
68
|
export {};
|
|
@@ -2,7 +2,7 @@ import { usePlayerMediaApi } from "./private/usePlayerMediaApi.mjs";
|
|
|
2
2
|
import { usePlayerVideoApi } from "./private/usePlayerVideoApi.mjs";
|
|
3
3
|
import { usePlayerRuntime } from "./private/usePlayerRuntime.mjs";
|
|
4
4
|
import { usePlayerControlsApi } from "./private/usePlayerControlsApi.mjs";
|
|
5
|
-
export function
|
|
5
|
+
export function useMagicPlayer(args) {
|
|
6
6
|
const mediaApi = usePlayerMediaApi({ id: args.id });
|
|
7
7
|
const videoApi = usePlayerVideoApi({ id: args.id });
|
|
8
8
|
const controlsApi = usePlayerControlsApi({ id: args.id });
|
|
@@ -3,12 +3,10 @@ import MagicScrollScene from './src/components/MagicScrollScene.vue.js';
|
|
|
3
3
|
import MagicScrollTransform from './src/components/MagicScrollTransform.vue.js';
|
|
4
4
|
import MagicScrollMotion from './src/components/MagicScrollMotion.vue.js';
|
|
5
5
|
import MagicScrollCollision from './src/components/MagicScrollCollision.vue.js';
|
|
6
|
-
import { useCollisionEmitter } from './src/composables/useCollisionEmitter.js';
|
|
7
|
-
import { useScrollApi } from './src/composables/useScrollApi.js';
|
|
8
6
|
import { useCollisionDetect } from './src/composables/useCollisionDetect.js';
|
|
9
|
-
import {
|
|
7
|
+
import { MagicScrollParent, MagicScrollProgress, MagicScrollReturn } from './src/symbols/index.js';
|
|
10
8
|
import type { Plugin } from 'vue';
|
|
11
9
|
declare const MagicScrollPlugin: Plugin;
|
|
12
|
-
export { MagicScrollPlugin, MagicScrollProvider, MagicScrollScene, MagicScrollTransform, MagicScrollMotion, MagicScrollCollision,
|
|
10
|
+
export { MagicScrollPlugin, MagicScrollProvider, MagicScrollScene, MagicScrollTransform, MagicScrollMotion, MagicScrollCollision, useCollisionDetect, MagicScrollParent, MagicScrollProgress, MagicScrollReturn, };
|
|
13
11
|
export * from './src/symbols/index.js';
|
|
14
12
|
export type * from './src/types/index';
|
|
@@ -3,13 +3,11 @@ import MagicScrollScene from "./src/components/MagicScrollScene.vue";
|
|
|
3
3
|
import MagicScrollTransform from "./src/components/MagicScrollTransform.vue";
|
|
4
4
|
import MagicScrollMotion from "./src/components/MagicScrollMotion.vue";
|
|
5
5
|
import MagicScrollCollision from "./src/components/MagicScrollCollision.vue";
|
|
6
|
-
import { useCollisionEmitter } from "./src/composables/useCollisionEmitter.mjs";
|
|
7
|
-
import { useScrollApi } from "./src/composables/useScrollApi.mjs";
|
|
8
6
|
import { useCollisionDetect } from "./src/composables/useCollisionDetect.mjs";
|
|
9
7
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
MagicScrollParent,
|
|
9
|
+
MagicScrollProgress,
|
|
10
|
+
MagicScrollReturn
|
|
13
11
|
} from "./src/symbols/index.mjs";
|
|
14
12
|
const MagicScrollPlugin = {
|
|
15
13
|
install: (app) => {
|
|
@@ -27,11 +25,9 @@ export {
|
|
|
27
25
|
MagicScrollTransform,
|
|
28
26
|
MagicScrollMotion,
|
|
29
27
|
MagicScrollCollision,
|
|
30
|
-
useCollisionEmitter,
|
|
31
|
-
useScrollApi,
|
|
32
28
|
useCollisionDetect,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
MagicScrollParent,
|
|
30
|
+
MagicScrollProgress,
|
|
31
|
+
MagicScrollReturn
|
|
36
32
|
};
|
|
37
33
|
export * from "./src/symbols/index.mjs";
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
import { ref, inject, computed, onMounted } from 'vue'
|
|
9
9
|
import { toValue } from '@vueuse/core'
|
|
10
10
|
import { useCollisionDetect } from '../composables/useCollisionDetect'
|
|
11
|
-
import {
|
|
11
|
+
import { MagicScrollReturn } from '../symbols'
|
|
12
12
|
|
|
13
13
|
import type { CollisionEntry } from '../types'
|
|
14
14
|
|
|
@@ -19,8 +19,8 @@ interface Props {
|
|
|
19
19
|
const props = defineProps<Props>()
|
|
20
20
|
const targetRef = ref<HTMLElement | undefined>(undefined)
|
|
21
21
|
|
|
22
|
-
const
|
|
23
|
-
const pageYOffset = computed(() => toValue(
|
|
22
|
+
const scrollReturn = inject(MagicScrollReturn, undefined)
|
|
23
|
+
const pageYOffset = computed(() => toValue(scrollReturn?.y) || 0)
|
|
24
24
|
|
|
25
25
|
onMounted(() => {
|
|
26
26
|
useCollisionDetect(pageYOffset, props.collisionEntries, toValue(targetRef))
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
type AnimationControls,
|
|
14
14
|
type Easing,
|
|
15
15
|
} from 'motion'
|
|
16
|
-
import {
|
|
16
|
+
import { MagicScrollProgress } from '../symbols'
|
|
17
17
|
|
|
18
18
|
interface Props {
|
|
19
19
|
keyframes?: MotionKeyframesDefinition
|
|
@@ -30,7 +30,7 @@ const animation = ref<AnimationControls | undefined>(undefined)
|
|
|
30
30
|
const elRef = ref<HTMLElement | undefined>(undefined)
|
|
31
31
|
|
|
32
32
|
const progress = inject(
|
|
33
|
-
|
|
33
|
+
MagicScrollProgress,
|
|
34
34
|
computed(() => 0)
|
|
35
35
|
)
|
|
36
36
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="magic-scroll-provider">
|
|
3
|
-
<slot :scroll-
|
|
3
|
+
<slot :scroll-return="scrollReturn" />
|
|
4
4
|
</div>
|
|
5
5
|
</template>
|
|
6
6
|
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
unrefElement,
|
|
12
12
|
type MaybeComputedElementRef,
|
|
13
13
|
} from '@vueuse/core'
|
|
14
|
-
import {
|
|
14
|
+
import { MagicScrollReturn, MagicScrollParent } from '../symbols'
|
|
15
15
|
|
|
16
16
|
interface Props {
|
|
17
17
|
active?: Boolean
|
|
@@ -33,8 +33,8 @@ const mappedParent = computed(() => {
|
|
|
33
33
|
return undefined
|
|
34
34
|
})
|
|
35
35
|
|
|
36
|
-
const
|
|
36
|
+
const scrollReturn = useScroll(mappedEl)
|
|
37
37
|
|
|
38
|
-
provide(
|
|
39
|
-
provide(
|
|
38
|
+
provide(MagicScrollReturn, scrollReturn)
|
|
39
|
+
provide(MagicScrollParent, mappedParent)
|
|
40
40
|
</script>
|
|
@@ -11,7 +11,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
11
11
|
active: Boolean;
|
|
12
12
|
}, {}>, {
|
|
13
13
|
default?(_: {
|
|
14
|
-
|
|
14
|
+
scrollReturn: {
|
|
15
15
|
x: import("vue").WritableComputedRef<number>;
|
|
16
16
|
y: import("vue").WritableComputedRef<number>;
|
|
17
17
|
isScrolling: import("vue").Ref<boolean>;
|
|
@@ -7,11 +7,11 @@
|
|
|
7
7
|
<script setup lang="ts">
|
|
8
8
|
import { ref, provide, inject, onMounted, watch, nextTick, readonly } from 'vue'
|
|
9
9
|
import { useIntersectionObserver } from '@vueuse/core'
|
|
10
|
-
import { useScrollApi } from '../composables/useScrollApi'
|
|
10
|
+
import { useScrollApi } from '../composables/private/useScrollApi'
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
MagicScrollParent,
|
|
13
|
+
MagicScrollProgress,
|
|
14
|
+
MagicScrollReturn,
|
|
15
15
|
} from '../symbols'
|
|
16
16
|
|
|
17
17
|
import type { FromTo } from '../types'
|
|
@@ -27,8 +27,8 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
27
27
|
to: 'bottom-top',
|
|
28
28
|
})
|
|
29
29
|
|
|
30
|
-
const
|
|
31
|
-
const scrollParent = inject(
|
|
30
|
+
const scrollReturn = inject(MagicScrollReturn, undefined)
|
|
31
|
+
const scrollParent = inject(MagicScrollParent)
|
|
32
32
|
|
|
33
33
|
const elRef = ref<HTMLElement | undefined>(undefined)
|
|
34
34
|
const progress = ref(0)
|
|
@@ -52,7 +52,7 @@ onMounted(() => {
|
|
|
52
52
|
})
|
|
53
53
|
|
|
54
54
|
watch(
|
|
55
|
-
() =>
|
|
55
|
+
() => scrollReturn?.y.value,
|
|
56
56
|
() => {
|
|
57
57
|
if (intersecting.value) {
|
|
58
58
|
calculate()
|
|
@@ -71,5 +71,5 @@ useIntersectionObserver(
|
|
|
71
71
|
{ rootMargin: '150% 0px 150% 0px', immediate: true }
|
|
72
72
|
)
|
|
73
73
|
|
|
74
|
-
provide(
|
|
74
|
+
provide(MagicScrollProgress, readonly(progress))
|
|
75
75
|
</script>
|
package/dist/plugins/MagicScroll/src/composables/{useScrollApi.d.ts → private/useScrollApi.d.ts}
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type MaybeRef, type MaybeRefOrGetter } from 'vue';
|
|
2
|
-
import type { FromTo } from '
|
|
2
|
+
import type { FromTo } from '../../types.js';
|
|
3
3
|
type UseScrollApiParams = {
|
|
4
4
|
child: MaybeRef<HTMLElement | null | undefined>;
|
|
5
5
|
parent: MaybeRefOrGetter<HTMLElement | null | undefined>;
|
package/dist/plugins/MagicScroll/src/composables/{useScrollApi.mjs → private/useScrollApi.mjs}
RENAMED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ref, inject, toValue } from "vue";
|
|
2
2
|
import { useWindowSize } from "@vueuse/core";
|
|
3
|
-
import {
|
|
3
|
+
import { MagicScrollReturn } from "../../symbols/index.mjs";
|
|
4
4
|
import { clampValue } from "@maas/vue-equipment/utils";
|
|
5
5
|
export function useScrollApi(params) {
|
|
6
6
|
const { child, parent, from, to } = params;
|
|
7
|
-
const
|
|
7
|
+
const scrollReturn = inject(MagicScrollReturn, void 0);
|
|
8
8
|
const childRect = ref();
|
|
9
9
|
const parentRect = ref();
|
|
10
10
|
const start = ref(0);
|
|
@@ -19,7 +19,7 @@ export function useScrollApi(params) {
|
|
|
19
19
|
let y = 0;
|
|
20
20
|
if (!childRect.value)
|
|
21
21
|
return y;
|
|
22
|
-
const scrollY = toValue(
|
|
22
|
+
const scrollY = toValue(scrollReturn?.y) || 0;
|
|
23
23
|
switch (points.child) {
|
|
24
24
|
case "top":
|
|
25
25
|
y += childRect.value.top + scrollY;
|
|
@@ -61,7 +61,7 @@ export function useScrollApi(params) {
|
|
|
61
61
|
end.value = getOffsetTop(splitLocation(to));
|
|
62
62
|
}
|
|
63
63
|
function getProgress() {
|
|
64
|
-
const scrollY = toValue(
|
|
64
|
+
const scrollY = toValue(scrollReturn?.y) || 0;
|
|
65
65
|
const total = Math.abs(end.value - start.value);
|
|
66
66
|
const current = scrollY - start.value;
|
|
67
67
|
return clampValue(current / total, 0, 1);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ref, watch, unref, computed } from "vue";
|
|
2
2
|
import { useIntersectionObserver, useWindowSize } from "@vueuse/core";
|
|
3
|
-
import {
|
|
3
|
+
import { useMagicEmitter } from "@maas/vue-equipment/plugins";
|
|
4
4
|
export function useCollisionDetect(pageYOffset, collisionEntries, parent) {
|
|
5
5
|
const scrolled = ref(0);
|
|
6
6
|
const intersecting = ref();
|
|
@@ -88,7 +88,7 @@ export function useCollisionDetect(pageYOffset, collisionEntries, parent) {
|
|
|
88
88
|
return;
|
|
89
89
|
if (dir === "down" && boundingRect[pos] <= offset || dir === "up" && boundingRect[pos] >= offset) {
|
|
90
90
|
entry.alerted[dir][pos] = true;
|
|
91
|
-
|
|
91
|
+
useMagicEmitter().emit("collision", {
|
|
92
92
|
dir,
|
|
93
93
|
pos,
|
|
94
94
|
el: entry.element,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { InjectionKey, Ref, MaybeRefOrGetter } from 'vue';
|
|
2
|
-
declare const
|
|
3
|
-
declare const
|
|
2
|
+
declare const MagicScrollParent: InjectionKey<MaybeRefOrGetter<HTMLElement | undefined>>;
|
|
3
|
+
declare const MagicScrollProgress: InjectionKey<Ref<number>>;
|
|
4
|
+
declare const MagicScrollReturn: InjectionKey<{
|
|
4
5
|
x: import("vue").WritableComputedRef<number>;
|
|
5
6
|
y: import("vue").WritableComputedRef<number>;
|
|
6
7
|
isScrolling: Ref<boolean>;
|
|
@@ -18,5 +19,4 @@ declare const ScrollPositionKey: InjectionKey<{
|
|
|
18
19
|
};
|
|
19
20
|
measure(): void;
|
|
20
21
|
} | undefined>;
|
|
21
|
-
|
|
22
|
-
export { ScrollParentKey, ScrollPositionKey, ScrollProgressKey };
|
|
22
|
+
export { MagicScrollParent, MagicScrollProgress, MagicScrollReturn };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
2
|
-
const
|
|
3
|
-
const
|
|
4
|
-
export {
|
|
1
|
+
const MagicScrollParent = Symbol();
|
|
2
|
+
const MagicScrollProgress = Symbol();
|
|
3
|
+
const MagicScrollReturn = Symbol();
|
|
4
|
+
export { MagicScrollParent, MagicScrollProgress, MagicScrollReturn };
|
|
@@ -7,7 +7,7 @@ type CollisionEvents = {
|
|
|
7
7
|
dir: 'up' | 'down';
|
|
8
8
|
pos: 'top' | 'bottom';
|
|
9
9
|
el: HTMLElement;
|
|
10
|
-
data?: Record<string,
|
|
10
|
+
data?: Record<string, unknown>;
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
13
|
interface CollisionEntry {
|
|
@@ -16,7 +16,7 @@ interface CollisionEntry {
|
|
|
16
16
|
bottom: number | (() => number);
|
|
17
17
|
};
|
|
18
18
|
element?: string;
|
|
19
|
-
data: Record<string,
|
|
19
|
+
data: Record<string, unknown>;
|
|
20
20
|
}
|
|
21
21
|
interface MappedCollisionEntry extends Omit<CollisionEntry, 'element'> {
|
|
22
22
|
alerted: {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import MagicToast from './src/components/MagicToast.vue.js';
|
|
2
|
-
import {
|
|
3
|
-
import { useToastEmitter } from './src/composables/useToastEmitter.js';
|
|
2
|
+
import { useMagicToast } from './src/composables/useMagicToast.js';
|
|
4
3
|
import type { Plugin } from 'vue';
|
|
5
4
|
import type { ToastEvents } from './src/types/index.js';
|
|
6
5
|
declare const MagicToastPlugin: Plugin;
|
|
7
|
-
export { MagicToastPlugin, MagicToast,
|
|
6
|
+
export { MagicToastPlugin, MagicToast, useMagicToast };
|
|
8
7
|
export type { ToastEvents };
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import MagicToast from "./src/components/MagicToast.vue";
|
|
2
|
-
import {
|
|
3
|
-
import { useToastEmitter } from "./src/composables/useToastEmitter.mjs";
|
|
2
|
+
import { useMagicToast } from "./src/composables/useMagicToast.mjs";
|
|
4
3
|
const MagicToastPlugin = {
|
|
5
4
|
install: (app) => {
|
|
6
5
|
app.component("MagicToast", MagicToast);
|
|
7
6
|
}
|
|
8
7
|
};
|
|
9
|
-
export { MagicToastPlugin, MagicToast,
|
|
8
|
+
export { MagicToastPlugin, MagicToast, useMagicToast };
|
|
@@ -55,8 +55,9 @@ import { defu } from 'defu'
|
|
|
55
55
|
import { onClickOutside, type MaybeElement } from '@vueuse/core'
|
|
56
56
|
import { uuid } from '@maas/vue-equipment/utils'
|
|
57
57
|
import { defaultOptions } from './../utils/defaultOptions'
|
|
58
|
-
import { useToastApi } from '
|
|
58
|
+
import { useToastApi } from '../composables/private/useToastApi'
|
|
59
59
|
import { useToastCallback } from './../composables/private/useToastCallback'
|
|
60
|
+
import { useMagicToast } from '../composables/useMagicToast'
|
|
60
61
|
|
|
61
62
|
import MagicToastComponent from './MagicToastComponent.vue'
|
|
62
63
|
|
|
@@ -76,7 +77,8 @@ interface MagicToastProps {
|
|
|
76
77
|
|
|
77
78
|
const props = defineProps<MagicToastProps>()
|
|
78
79
|
|
|
79
|
-
const {
|
|
80
|
+
const { initialize, destroy } = useToastApi(props.id)
|
|
81
|
+
const { toasts, count, firstToast } = useMagicToast(props.id)
|
|
80
82
|
|
|
81
83
|
const mappedOptions = defu(props.options, defaultOptions)
|
|
82
84
|
const isExpanded = ref(mappedOptions.layout?.expand === true)
|
|
@@ -91,7 +93,7 @@ const {
|
|
|
91
93
|
onLeave,
|
|
92
94
|
onAfterLeave,
|
|
93
95
|
activeElements,
|
|
94
|
-
} = useToastCallback({ id: props.id, mappedOptions, count,
|
|
96
|
+
} = useToastCallback({ id: props.id, mappedOptions, count, firstToast })
|
|
95
97
|
|
|
96
98
|
function onMouseenter() {
|
|
97
99
|
if (mappedOptions.layout?.expand === 'hover') {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { toValue } from "vue";
|
|
2
|
+
import { useToastStore } from "./useToastStore.mjs";
|
|
3
|
+
import { useMagicToast } from "../useMagicToast.mjs";
|
|
4
|
+
export function useToastApi(id) {
|
|
5
|
+
const { findInstance, addInstance, removeInstance } = useToastStore();
|
|
6
|
+
const { clear } = useMagicToast(toValue(id));
|
|
7
|
+
function initialize() {
|
|
8
|
+
const mappedId = toValue(id);
|
|
9
|
+
if (!findInstance(mappedId)) {
|
|
10
|
+
return addInstance(mappedId);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function destroy(id2) {
|
|
14
|
+
if (!id2)
|
|
15
|
+
return;
|
|
16
|
+
clear();
|
|
17
|
+
removeInstance(toValue(id2));
|
|
18
|
+
}
|
|
19
|
+
return {
|
|
20
|
+
initialize,
|
|
21
|
+
destroy
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { type Ref, type MaybeRef } from 'vue';
|
|
2
2
|
import type { ToastOptions, Toast } from './../../types.js';
|
|
3
|
-
type
|
|
3
|
+
type UseToastCallbackArgs = {
|
|
4
4
|
id: MaybeRef<string>;
|
|
5
5
|
mappedOptions: ToastOptions;
|
|
6
6
|
count: Ref<number | undefined>;
|
|
7
|
-
|
|
7
|
+
firstToast: Ref<Toast | undefined>;
|
|
8
8
|
};
|
|
9
|
-
export declare function useToastCallback(
|
|
9
|
+
export declare function useToastCallback(args: UseToastCallbackArgs): {
|
|
10
10
|
onBeforeEnter: (_el: Element) => void;
|
|
11
11
|
onEnter: (_el: Element) => void;
|
|
12
12
|
onAfterEnter: (el: Element) => void;
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import { ref, toValue } from "vue";
|
|
2
|
-
import {
|
|
3
|
-
export function useToastCallback(
|
|
2
|
+
import { useMagicEmitter } from "@maas/vue-equipment/plugins";
|
|
3
|
+
export function useToastCallback(args) {
|
|
4
|
+
const { id, mappedOptions, count, firstToast } = args;
|
|
4
5
|
const activeElements = ref([]);
|
|
6
|
+
const emitter = useMagicEmitter();
|
|
5
7
|
function onBeforeEnter(_el) {
|
|
6
|
-
|
|
8
|
+
emitter.emit("beforeEnter", toValue(id));
|
|
7
9
|
}
|
|
8
10
|
function onEnter(_el) {
|
|
9
|
-
|
|
11
|
+
emitter.emit("enter", toValue(id));
|
|
10
12
|
if (count.value && mappedOptions.layout?.max && count.value > mappedOptions.layout.max) {
|
|
11
|
-
|
|
13
|
+
firstToast.value?.remove();
|
|
12
14
|
}
|
|
13
15
|
}
|
|
14
16
|
function onAfterEnter(el) {
|
|
15
|
-
|
|
17
|
+
emitter.emit("afterEnter", toValue(id));
|
|
16
18
|
const mappedEl = el;
|
|
17
19
|
const style = window.getComputedStyle(mappedEl);
|
|
18
20
|
activeElements.value = [
|
|
@@ -28,16 +30,16 @@ export function useToastCallback({ id, mappedOptions, count, oldest }) {
|
|
|
28
30
|
];
|
|
29
31
|
}
|
|
30
32
|
function onBeforeLeave(_el) {
|
|
31
|
-
|
|
33
|
+
emitter.emit("beforeLeave", toValue(id));
|
|
32
34
|
}
|
|
33
35
|
function onLeave(el) {
|
|
34
|
-
|
|
36
|
+
emitter.emit("leave", toValue(id));
|
|
35
37
|
activeElements.value = activeElements.value.filter(
|
|
36
38
|
(item) => item.id !== el.id
|
|
37
39
|
);
|
|
38
40
|
}
|
|
39
41
|
function onAfterLeave(_el) {
|
|
40
|
-
|
|
42
|
+
emitter.emit("afterLeave", toValue(id));
|
|
41
43
|
}
|
|
42
44
|
return {
|
|
43
45
|
onBeforeEnter,
|