@maas/vue-equipment 1.0.0-beta.34 → 1.0.0-beta.36
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/useScrollTo/index.js +6 -2
- package/dist/composables/useScrollTo/index.js.map +1 -1
- package/dist/nuxt/module.d.mts +2 -2
- package/dist/nuxt/module.json +1 -1
- package/dist/nuxt/module.mjs +8 -1
- package/dist/plugins/.turbo/turbo-lint.log +1 -1
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionContent.vue +15 -6
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionContent.vue.d.ts +1 -1
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionProvider.vue.d.ts +1 -1
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionTrigger.vue +17 -12
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionTrigger.vue.d.ts +1 -1
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionView.vue +11 -5
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionView.vue.d.ts +1 -1
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionTrigger.d.ts +2 -2
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionTrigger.mjs +5 -5
- package/dist/plugins/MagicCommand/src/components/MagicCommandContent.vue +28 -10
- package/dist/plugins/MagicCommand/src/components/MagicCommandContent.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandDrawer.vue +11 -5
- package/dist/plugins/MagicCommand/src/components/MagicCommandDrawer.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.vue +19 -9
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandModal.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandProvider.vue +17 -2
- package/dist/plugins/MagicCommand/src/components/MagicCommandProvider.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandRenderer.vue +11 -5
- package/dist/plugins/MagicCommand/src/components/MagicCommandRenderer.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandTrigger.vue +22 -11
- package/dist/plugins/MagicCommand/src/components/MagicCommandTrigger.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandView.vue +11 -3
- package/dist/plugins/MagicCommand/src/components/MagicCommandView.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/composables/private/useCommandItem.mjs +3 -1
- package/dist/plugins/MagicCommand/src/composables/private/useCommandView.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/composables/private/useCommandView.mjs +63 -44
- package/dist/plugins/MagicCommand/src/composables/useMagicCommand.mjs +21 -4
- package/dist/plugins/MagicCookie/src/components/MagicCookieItem.vue +12 -3
- package/dist/plugins/MagicCookie/src/components/MagicCookieItem.vue.d.ts +1 -1
- package/dist/plugins/MagicCookie/src/components/MagicCookieProvider.vue.d.ts +1 -1
- package/dist/plugins/MagicCookie/src/components/MagicCookieView.vue +11 -5
- package/dist/plugins/MagicCookie/src/components/MagicCookieView.vue.d.ts +1 -1
- package/dist/plugins/MagicCookie/src/composables/private/useCookieItem.mjs +9 -2
- package/dist/plugins/MagicDraggable/src/components/MagicDraggable.vue +11 -2
- package/dist/plugins/MagicDraggable/src/components/MagicDraggable.vue.d.ts +1 -1
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableDrag.mjs +8 -3
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableScrollLock.mjs +3 -1
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableSnap.mjs +7 -2
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue +7 -2
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue.d.ts +1 -1
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDOM.mjs +3 -1
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDrag.mjs +6 -1
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerSnap.mjs +55 -21
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.mjs +3 -1
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerUtils.mjs +21 -8
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerWheel.mjs +6 -1
- package/dist/plugins/MagicError/index.d.ts +5 -0
- package/dist/plugins/MagicError/index.mjs +3 -0
- package/dist/plugins/MagicError/nuxt.d.ts +2 -0
- package/dist/plugins/MagicError/nuxt.mjs +12 -0
- package/dist/plugins/MagicError/package.json +40 -0
- package/dist/plugins/MagicError/src/MagicError.d.ts +0 -0
- package/dist/plugins/MagicError/src/MagicError.mjs +0 -0
- package/dist/plugins/MagicError/src/class/MagicError.d.ts +6 -0
- package/dist/plugins/MagicError/src/class/MagicError.mjs +15 -0
- package/dist/plugins/MagicError/src/composables/useMagicError.d.ts +18 -0
- package/dist/plugins/MagicError/src/composables/useMagicError.mjs +31 -0
- package/dist/plugins/MagicMarquee/src/components/MagicMarquee.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuChannel.vue +22 -10
- package/dist/plugins/MagicMenu/src/components/MagicMenuChannel.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuContent.vue +15 -6
- package/dist/plugins/MagicMenu/src/components/MagicMenuContent.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuFloat.vue +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuFloat.vue.d.ts +4 -3
- package/dist/plugins/MagicMenu/src/components/MagicMenuItem.vue +19 -9
- package/dist/plugins/MagicMenu/src/components/MagicMenuItem.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuProvider.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuRemote.vue +19 -13
- package/dist/plugins/MagicMenu/src/components/MagicMenuRemote.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuTrigger.vue +15 -10
- package/dist/plugins/MagicMenu/src/components/MagicMenuTrigger.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuView.vue +12 -4
- package/dist/plugins/MagicMenu/src/components/MagicMenuView.vue.d.ts +3 -3
- package/dist/plugins/MagicMenu/src/composables/private/useMenuDOM.mjs +3 -1
- package/dist/plugins/MagicMenu/src/composables/private/useMenuItem.mjs +12 -2
- package/dist/plugins/MagicMenu/src/composables/private/useMenuKeyListener.mjs +22 -10
- package/dist/plugins/MagicMenu/src/composables/private/useMenuView.mjs +13 -4
- package/dist/plugins/MagicMenu/src/types/index.d.ts +2 -2
- package/dist/plugins/MagicModal/src/components/MagicModal.vue.d.ts +1 -1
- package/dist/plugins/MagicModal/src/composables/private/useModalDOM.mjs +3 -1
- package/dist/plugins/MagicNoise/src/components/MagicNoise.vue.d.ts +1 -1
- package/dist/plugins/MagicNoise/src/composables/private/useNoiseApi.mjs +7 -3
- package/dist/plugins/MagicPie/src/components/MagicPie.vue +15 -2
- package/dist/plugins/MagicPie/src/components/MagicPie.vue.d.ts +1 -1
- package/dist/plugins/MagicPie/src/composables/private/usePieState.mjs +3 -1
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudio.vue +17 -7
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudio.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudioControls.vue +11 -5
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudioControls.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerDisplayTime.vue +11 -5
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerDisplayTime.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerMuxPopover.vue +29 -14
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerMuxPopover.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerOverlay.vue +11 -5
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerOverlay.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerPoster.vue +11 -5
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerPoster.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerProvider.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerTimeline.vue +11 -5
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerTimeline.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideo.vue +17 -7
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideo.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideoControls.vue +11 -5
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideoControls.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/icons/FullscreenEnter.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/icons/FullscreenExit.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/icons/Pause.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/icons/Play.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/icons/VolumeOff.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/icons/VolumeOn.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/icons/Waiting.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerMediaApi.mjs +65 -11
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerRuntime.d.ts +1 -0
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerRuntime.mjs +96 -16
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerState.mjs +3 -1
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerVideoApi.mjs +7 -2
- package/dist/plugins/MagicPlayer/src/types/index.d.ts +2 -0
- package/dist/plugins/MagicPlayer/src/utils/defaultOptions.mjs +1 -0
- package/dist/plugins/MagicScroll/src/components/MagicScrollCollision.vue +12 -6
- package/dist/plugins/MagicScroll/src/components/MagicScrollCollision.vue.d.ts +1 -1
- package/dist/plugins/MagicScroll/src/components/MagicScrollMotion.vue.d.ts +1 -1
- package/dist/plugins/MagicScroll/src/components/MagicScrollProvider.vue.d.ts +1 -1
- package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue +11 -3
- package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue.d.ts +1 -1
- package/dist/plugins/MagicToast/src/components/MagicToastProvider.vue.d.ts +1 -1
- package/dist/plugins/MagicToast/src/components/MagicToastView.vue +11 -3
- package/dist/plugins/MagicToast/src/components/MagicToastView.vue.d.ts +1 -1
- package/dist/plugins/MagicToast/src/composables/private/useToastCallback.d.ts +2 -2
- package/dist/plugins/MagicToast/src/composables/private/useToastCallback.mjs +7 -5
- package/dist/plugins/MagicToast/src/composables/private/useToastScrollLock.mjs +3 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +16 -21
|
@@ -2,12 +2,17 @@ import { ref, toRefs, computed, toValue, nextTick } from "vue";
|
|
|
2
2
|
import { computedWithControl } from "@vueuse/core";
|
|
3
3
|
import { interpolate } from "@maas/vue-equipment/utils";
|
|
4
4
|
import { useMagicEmitter } from "@maas/vue-equipment/plugins/MagicEmitter";
|
|
5
|
+
import { useMagicError } from "@maas/vue-equipment/plugins/MagicError";
|
|
5
6
|
import { defu } from "defu";
|
|
6
7
|
import { useDraggableState } from "./useDraggableState.mjs";
|
|
7
8
|
export function useDraggableSnap(args) {
|
|
8
9
|
const { id, animation, snapPoints } = args;
|
|
9
10
|
const { initializeState } = useDraggableState(toValue(id));
|
|
10
11
|
const state = initializeState();
|
|
12
|
+
const { logWarning } = useMagicError({
|
|
13
|
+
prefix: "MagicDraggable",
|
|
14
|
+
source: "useDraggableSnap"
|
|
15
|
+
});
|
|
11
16
|
const {
|
|
12
17
|
lastDraggedX,
|
|
13
18
|
lastDraggedY,
|
|
@@ -54,11 +59,11 @@ export function useDraggableSnap(args) {
|
|
|
54
59
|
const emitter = useMagicEmitter();
|
|
55
60
|
function mapSnapPoint(snapPoint) {
|
|
56
61
|
if (!wrapperRect.value) {
|
|
57
|
-
|
|
62
|
+
logWarning("Wrapper rect is not defined");
|
|
58
63
|
return void 0;
|
|
59
64
|
}
|
|
60
65
|
if (!elRect.value) {
|
|
61
|
-
|
|
66
|
+
logWarning("Element rect is not defined");
|
|
62
67
|
return void 0;
|
|
63
68
|
}
|
|
64
69
|
const mappedSnapPoint = typeof snapPoint === "string" ? [snapPoint] : snapPoint;
|
|
@@ -72,6 +72,7 @@ import {
|
|
|
72
72
|
} from "vue";
|
|
73
73
|
import { createDefu } from "defu";
|
|
74
74
|
import { onKeyStroke, unrefElement } from "@vueuse/core";
|
|
75
|
+
import { useMagicError } from "@maas/vue-equipment/plugins/MagicError";
|
|
75
76
|
import { useMetaViewport } from "@maas/vue-equipment/composables/useMetaViewport";
|
|
76
77
|
import { defaultOptions } from "./../utils/defaultOptions";
|
|
77
78
|
import { useDrawerDOM } from "../composables/private/useDrawerDOM";
|
|
@@ -121,6 +122,10 @@ const {
|
|
|
121
122
|
focusTrap: mappedOptions.focusTrap
|
|
122
123
|
});
|
|
123
124
|
const { isActive, open, close } = useMagicDrawer(id);
|
|
125
|
+
const { logWarning } = useMagicError({
|
|
126
|
+
prefix: "MagicDrawer",
|
|
127
|
+
source: "MagicDrawer"
|
|
128
|
+
});
|
|
124
129
|
const overshoot = shallowRef(0);
|
|
125
130
|
const {
|
|
126
131
|
position,
|
|
@@ -196,12 +201,12 @@ function convertToPixels(value) {
|
|
|
196
201
|
const regex = /^(\d*\.?\d+)\s*(rem|px)$/;
|
|
197
202
|
const match = value.match(regex);
|
|
198
203
|
if (!match) {
|
|
199
|
-
|
|
204
|
+
logWarning(
|
|
200
205
|
`--magic-drawer-drag-overshoot (${value}) needs to be specified in px or rem`
|
|
201
206
|
);
|
|
202
207
|
return 0;
|
|
203
208
|
}
|
|
204
|
-
const numericValue = parseFloat(match[1]);
|
|
209
|
+
const numericValue = parseFloat(match[1] ?? "");
|
|
205
210
|
const unit = match[2];
|
|
206
211
|
const bodyFontSize = window.getComputedStyle(document.body).fontSize;
|
|
207
212
|
const rootFontSize = parseFloat(bodyFontSize) || 16;
|
|
@@ -20,7 +20,7 @@ type __VLS_Slots = {} & {
|
|
|
20
20
|
} & {
|
|
21
21
|
default?: (props: typeof __VLS_37) => any;
|
|
22
22
|
};
|
|
23
|
-
declare const __VLS_component: import("vue").DefineComponent<MagicDrawerProps,
|
|
23
|
+
declare const __VLS_component: import("vue").DefineComponent<MagicDrawerProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<MagicDrawerProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
24
24
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
25
25
|
export default _default;
|
|
26
26
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -38,7 +38,9 @@ export function useDrawerDOM(args) {
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
function addScrollLockPadding() {
|
|
41
|
-
if (typeof window === "undefined")
|
|
41
|
+
if (typeof window === "undefined") {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
42
44
|
const exclude = new RegExp(/magic-drawer(__backdrop)?/);
|
|
43
45
|
document.body.style.setProperty(
|
|
44
46
|
"--scrollbar-width",
|
|
@@ -23,6 +23,7 @@ import {
|
|
|
23
23
|
import {
|
|
24
24
|
useMagicEmitter
|
|
25
25
|
} from "@maas/vue-equipment/plugins/MagicEmitter";
|
|
26
|
+
import { useMagicError } from "@maas/vue-equipment/plugins/MagicError";
|
|
26
27
|
import { useMagicDrawer } from "./../useMagicDrawer.mjs";
|
|
27
28
|
import { useDrawerSnap } from "./useDrawerSnap.mjs";
|
|
28
29
|
import { useDrawerGuards } from "./useDrawerGuards.mjs";
|
|
@@ -42,6 +43,10 @@ export function useDrawerDrag(args) {
|
|
|
42
43
|
preventDragClose,
|
|
43
44
|
disabled
|
|
44
45
|
} = args;
|
|
46
|
+
const { logWarning } = useMagicError({
|
|
47
|
+
prefix: "MagicDrawer",
|
|
48
|
+
source: "useDrawerDrag"
|
|
49
|
+
});
|
|
45
50
|
const { initializeState } = useDrawerState(toValue(id));
|
|
46
51
|
const state = initializeState();
|
|
47
52
|
const {
|
|
@@ -285,7 +290,7 @@ export function useDrawerDrag(args) {
|
|
|
285
290
|
function snapToCallback(payload) {
|
|
286
291
|
if (payload.id === toValue(id)) {
|
|
287
292
|
if (!toValue(isActive)) {
|
|
288
|
-
|
|
293
|
+
logWarning("Cannot snap to point when drawer is not open");
|
|
289
294
|
return;
|
|
290
295
|
} else {
|
|
291
296
|
snapTo({
|
|
@@ -36,13 +36,16 @@ export function useDrawerSnap(args) {
|
|
|
36
36
|
() => toValue(snapPoints),
|
|
37
37
|
() => {
|
|
38
38
|
const extended = toValue(preventDragClose) ? toValue(snapPoints) : [...toValue(snapPoints), 0];
|
|
39
|
-
const mapped = extended.reduce(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
const mapped = extended.reduce(
|
|
40
|
+
(acc, current) => {
|
|
41
|
+
const key = mapSnapPoint(current);
|
|
42
|
+
if (key || key === 0) {
|
|
43
|
+
acc[key] = current;
|
|
44
|
+
}
|
|
45
|
+
return acc;
|
|
46
|
+
},
|
|
47
|
+
{}
|
|
48
|
+
);
|
|
46
49
|
return mapped;
|
|
47
50
|
}
|
|
48
51
|
);
|
|
@@ -104,30 +107,54 @@ export function useDrawerSnap(args) {
|
|
|
104
107
|
switch (position) {
|
|
105
108
|
case "bottom": {
|
|
106
109
|
const rect = toValue(wrapperRect);
|
|
107
|
-
if (reversedSnapPoint === 1)
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
if (reversedSnapPoint === 1) {
|
|
111
|
+
return drawerHeight.value;
|
|
112
|
+
}
|
|
113
|
+
if (reversedSnapPoint === 0) {
|
|
114
|
+
return 0;
|
|
115
|
+
}
|
|
116
|
+
if (!rect) {
|
|
117
|
+
return 0;
|
|
118
|
+
}
|
|
110
119
|
return vh * reversedSnapPoint - rect.top;
|
|
111
120
|
}
|
|
112
121
|
case "top": {
|
|
113
122
|
const rect = toValue(wrapperRect);
|
|
114
|
-
if (reversedSnapPoint === 1)
|
|
115
|
-
|
|
116
|
-
|
|
123
|
+
if (reversedSnapPoint === 1) {
|
|
124
|
+
return drawerHeight.value * -1;
|
|
125
|
+
}
|
|
126
|
+
if (reversedSnapPoint === 0) {
|
|
127
|
+
return 0;
|
|
128
|
+
}
|
|
129
|
+
if (!rect) {
|
|
130
|
+
return 0;
|
|
131
|
+
}
|
|
117
132
|
return vh * reversedSnapPoint - rect.bottom;
|
|
118
133
|
}
|
|
119
134
|
case "right": {
|
|
120
135
|
const rect = toValue(wrapperRect);
|
|
121
|
-
if (reversedSnapPoint === 1)
|
|
122
|
-
|
|
123
|
-
|
|
136
|
+
if (reversedSnapPoint === 1) {
|
|
137
|
+
return drawerWidth.value;
|
|
138
|
+
}
|
|
139
|
+
if (reversedSnapPoint === 0) {
|
|
140
|
+
return 0;
|
|
141
|
+
}
|
|
142
|
+
if (!rect) {
|
|
143
|
+
return 0;
|
|
144
|
+
}
|
|
124
145
|
return vw * reversedSnapPoint - rect.left;
|
|
125
146
|
}
|
|
126
147
|
case "left": {
|
|
127
148
|
const rect = toValue(wrapperRect);
|
|
128
|
-
if (reversedSnapPoint === 1)
|
|
129
|
-
|
|
130
|
-
|
|
149
|
+
if (reversedSnapPoint === 1) {
|
|
150
|
+
return drawerWidth.value * -1;
|
|
151
|
+
}
|
|
152
|
+
if (reversedSnapPoint === 0) {
|
|
153
|
+
return 0;
|
|
154
|
+
}
|
|
155
|
+
if (!rect) {
|
|
156
|
+
return 0;
|
|
157
|
+
}
|
|
131
158
|
return vw * reversedSnapPoint - rect.right;
|
|
132
159
|
}
|
|
133
160
|
default:
|
|
@@ -159,7 +186,9 @@ export function useDrawerSnap(args) {
|
|
|
159
186
|
case "top":
|
|
160
187
|
case "bottom": {
|
|
161
188
|
const mappedSnapPointY = mapSnapPoint(snapPoint);
|
|
162
|
-
if (!mappedSnapPointY && mappedSnapPointY !== 0)
|
|
189
|
+
if (!mappedSnapPointY && mappedSnapPointY !== 0) {
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
163
192
|
const closestY = findClosestSnapPoint({
|
|
164
193
|
draggedX,
|
|
165
194
|
draggedY: mappedSnapPointY
|
|
@@ -176,7 +205,9 @@ export function useDrawerSnap(args) {
|
|
|
176
205
|
case "left":
|
|
177
206
|
case "right": {
|
|
178
207
|
const mappedSnapPointX = mapSnapPoint(toValue(snapPoint));
|
|
179
|
-
if (!mappedSnapPointX && mappedSnapPointX !== 0)
|
|
208
|
+
if (!mappedSnapPointX && mappedSnapPointX !== 0) {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
180
211
|
const closestX = findClosestSnapPoint({
|
|
181
212
|
draggedX: mappedSnapPointX,
|
|
182
213
|
draggedY
|
|
@@ -200,6 +231,9 @@ export function useDrawerSnap(args) {
|
|
|
200
231
|
easing
|
|
201
232
|
} = args2;
|
|
202
233
|
const snapPoint = snapPointsMap.value[to];
|
|
234
|
+
if (!snapPoint && snapPoint !== 0) {
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
203
237
|
emitter.emit("beforeSnap", { id: toValue(id), snapPoint });
|
|
204
238
|
switch (position) {
|
|
205
239
|
case "bottom":
|
|
@@ -38,7 +38,9 @@ export function useDrawerState(id) {
|
|
|
38
38
|
let state = drawerStateStore.value.find((entry) => {
|
|
39
39
|
return entry.id === id;
|
|
40
40
|
});
|
|
41
|
-
if (!state)
|
|
41
|
+
if (!state) {
|
|
42
|
+
state = addState(toValue(id));
|
|
43
|
+
}
|
|
42
44
|
return state;
|
|
43
45
|
}
|
|
44
46
|
function deleteState() {
|
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
export function useDrawerUtils() {
|
|
2
2
|
function clamp(value, from, to) {
|
|
3
3
|
if (from > to) {
|
|
4
|
-
if (value > from)
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
if (value > from) {
|
|
5
|
+
return value;
|
|
6
|
+
}
|
|
7
|
+
if (value < to) {
|
|
8
|
+
return to;
|
|
9
|
+
} else {
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
7
12
|
} else if (from < to) {
|
|
8
|
-
if (value < from)
|
|
9
|
-
|
|
10
|
-
|
|
13
|
+
if (value < from) {
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
if (value > to) {
|
|
17
|
+
return to;
|
|
18
|
+
} else {
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
11
21
|
} else {
|
|
12
|
-
if (value < to)
|
|
13
|
-
|
|
22
|
+
if (value < to) {
|
|
23
|
+
return to;
|
|
24
|
+
} else {
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
14
27
|
}
|
|
15
28
|
}
|
|
16
29
|
return {
|
|
@@ -5,9 +5,14 @@ import {
|
|
|
5
5
|
} from "vue";
|
|
6
6
|
import { unrefElement } from "@vueuse/core";
|
|
7
7
|
import WheelGestures, {} from "wheel-gestures";
|
|
8
|
+
import { useMagicError } from "@maas/vue-equipment/plugins/MagicError";
|
|
8
9
|
import { useDrawerState } from "./useDrawerState.mjs";
|
|
9
10
|
export function useDrawerWheel(args) {
|
|
10
11
|
const { id, elRef, position, disabled } = args;
|
|
12
|
+
const { logError } = useMagicError({
|
|
13
|
+
prefix: "MagicDrawer",
|
|
14
|
+
source: "useDrawerWheel"
|
|
15
|
+
});
|
|
11
16
|
const { initializeState } = useDrawerState(toValue(id));
|
|
12
17
|
const state = initializeState();
|
|
13
18
|
const { dragging, wheeling } = toRefs(state);
|
|
@@ -56,7 +61,7 @@ export function useDrawerWheel(args) {
|
|
|
56
61
|
dispatchEvent(startEvent);
|
|
57
62
|
wheeling.value = true;
|
|
58
63
|
} catch (e) {
|
|
59
|
-
|
|
64
|
+
logError(String(e));
|
|
60
65
|
return destroyWheelListener();
|
|
61
66
|
}
|
|
62
67
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { useMagicError } from './src/composables/useMagicError.js';
|
|
2
|
+
import { MagicError } from './src/class/MagicError.js';
|
|
3
|
+
import type { UseMagicErrorReturn } from './src/composables/useMagicError.js';
|
|
4
|
+
export { useMagicError, MagicError };
|
|
5
|
+
export type { UseMagicErrorReturn };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { defineNuxtModule, addImports } from "@nuxt/kit";
|
|
2
|
+
export default defineNuxtModule({
|
|
3
|
+
meta: {
|
|
4
|
+
name: "@maas/vue-equipment/nuxt/MagicError"
|
|
5
|
+
},
|
|
6
|
+
setup() {
|
|
7
|
+
addImports({
|
|
8
|
+
from: "@maas/vue-equipment/plugins/MagicError",
|
|
9
|
+
name: "useMagicError"
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@maas/magic-error",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Vue composable for centralized error handling with custom error classes",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"vue",
|
|
7
|
+
"composable",
|
|
8
|
+
"error",
|
|
9
|
+
"error-handling",
|
|
10
|
+
"typescript"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"import": "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"main": "./dist/index.js",
|
|
21
|
+
"module": "./dist/index.js",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"files": [
|
|
24
|
+
"dist"
|
|
25
|
+
],
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsup",
|
|
28
|
+
"build:types": "tsup --dts-only",
|
|
29
|
+
"dev": "tsup --watch",
|
|
30
|
+
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
|
|
31
|
+
"test": "vitest",
|
|
32
|
+
"test:coverage": "vitest --coverage"
|
|
33
|
+
},
|
|
34
|
+
"peerDependencies": {
|
|
35
|
+
"vue": "^3.0.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@vue/tsconfig": "^0.8.1"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export class MagicError extends Error {
|
|
2
|
+
errorCode;
|
|
3
|
+
timestamp;
|
|
4
|
+
source;
|
|
5
|
+
constructor(message, errorCode, source, options) {
|
|
6
|
+
super(message, options);
|
|
7
|
+
this.name = "MagicError";
|
|
8
|
+
this.errorCode = errorCode;
|
|
9
|
+
this.timestamp = Date.now();
|
|
10
|
+
this.source = source;
|
|
11
|
+
if (Error.captureStackTrace) {
|
|
12
|
+
Error.captureStackTrace(this, MagicError);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { MagicError } from '../class/MagicError.js';
|
|
2
|
+
export interface UseMagicErrorArgs {
|
|
3
|
+
prefix?: string;
|
|
4
|
+
source?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface ThrowErrorArgs {
|
|
7
|
+
message: string;
|
|
8
|
+
errorCode: string | number;
|
|
9
|
+
cause?: unknown;
|
|
10
|
+
}
|
|
11
|
+
export interface UseMagicErrorReturn {
|
|
12
|
+
assert<T>(value: T, args: ThrowErrorArgs): asserts value is NonNullable<T>;
|
|
13
|
+
throwError(args: ThrowErrorArgs): never;
|
|
14
|
+
logError(message: string): void;
|
|
15
|
+
logWarning(message: string): void;
|
|
16
|
+
MagicError: typeof MagicError;
|
|
17
|
+
}
|
|
18
|
+
export declare function useMagicError(args?: UseMagicErrorArgs): UseMagicErrorReturn;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { MagicError } from "../class/MagicError.mjs";
|
|
2
|
+
export function useMagicError(args = {}) {
|
|
3
|
+
const { prefix = "MagicError", source = "vue-equipment" } = args;
|
|
4
|
+
function logError(message) {
|
|
5
|
+
console.error(`[${prefix}]:`, message);
|
|
6
|
+
}
|
|
7
|
+
function logWarning(message) {
|
|
8
|
+
console.warn(`[${prefix}]:`, message);
|
|
9
|
+
}
|
|
10
|
+
function throwError(args2) {
|
|
11
|
+
const { message, errorCode, cause } = args2;
|
|
12
|
+
const mappedMessage = `[${prefix}]: ${message}`;
|
|
13
|
+
const error = new MagicError(mappedMessage, errorCode, source, {
|
|
14
|
+
cause
|
|
15
|
+
});
|
|
16
|
+
logError(message);
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
function assert(value, args2) {
|
|
20
|
+
if (value === void 0 || value === null) {
|
|
21
|
+
throwError(args2);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
assert,
|
|
26
|
+
throwError,
|
|
27
|
+
logError,
|
|
28
|
+
logWarning,
|
|
29
|
+
MagicError
|
|
30
|
+
};
|
|
31
|
+
}
|
|
@@ -10,7 +10,7 @@ type __VLS_Slots = {} & {
|
|
|
10
10
|
} & {
|
|
11
11
|
default?: (props: typeof __VLS_3) => any;
|
|
12
12
|
};
|
|
13
|
-
declare const __VLS_component: import("vue").DefineComponent<MagicMarqueeProps,
|
|
13
|
+
declare const __VLS_component: import("vue").DefineComponent<MagicMarqueeProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<MagicMarqueeProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
14
14
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
15
15
|
export default _default;
|
|
16
16
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
|
|
14
14
|
<script setup>
|
|
15
15
|
import { computed, inject, provide } from "vue";
|
|
16
|
+
import {
|
|
17
|
+
useMagicError
|
|
18
|
+
} from "@maas/vue-equipment/plugins/MagicError";
|
|
16
19
|
import { useMenuChannel } from "../composables/private/useMenuChannel";
|
|
17
20
|
import {
|
|
18
21
|
MagicMenuInstanceId,
|
|
@@ -26,23 +29,32 @@ const { transition, id } = defineProps({
|
|
|
26
29
|
id: { type: String, required: true },
|
|
27
30
|
transition: { type: String, required: false }
|
|
28
31
|
});
|
|
32
|
+
const magicError = useMagicError({
|
|
33
|
+
prefix: "MagicMenu",
|
|
34
|
+
source: "MagicMenu"
|
|
35
|
+
});
|
|
29
36
|
const instanceId = inject(MagicMenuInstanceId, void 0);
|
|
30
37
|
const viewId = inject(MagicMenuViewId, void 0);
|
|
31
38
|
const contentId = inject(MagicMenuContentId, void 0);
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
magicError.assert(instanceId, {
|
|
40
|
+
message: "MagicMenuChannel must be nested inside MagicMenuProvider",
|
|
41
|
+
errorCode: "missing_instance_id"
|
|
42
|
+
});
|
|
43
|
+
magicError.assert(viewId, {
|
|
44
|
+
message: "MagicMenuChannel must be nested inside MagicMenuView",
|
|
45
|
+
errorCode: "missing_view_id"
|
|
46
|
+
});
|
|
47
|
+
magicError.assert(id, {
|
|
48
|
+
message: "MagicMenuChannel requires an id",
|
|
49
|
+
errorCode: "id_required"
|
|
50
|
+
});
|
|
41
51
|
const { initializeState } = useMenuState(instanceId);
|
|
42
52
|
const state = initializeState();
|
|
43
53
|
if (!contentId) {
|
|
44
54
|
if (state.options.debug) {
|
|
45
|
-
|
|
55
|
+
magicError.logWarning(
|
|
56
|
+
"MagicMenuChannel is not nested inside MagicMenuContent"
|
|
57
|
+
);
|
|
46
58
|
}
|
|
47
59
|
}
|
|
48
60
|
const mappedId = computed(() => `magic-menu-channel-${id}`);
|
|
@@ -6,7 +6,7 @@ declare var __VLS_6: {};
|
|
|
6
6
|
type __VLS_Slots = {} & {
|
|
7
7
|
default?: (props: typeof __VLS_6) => any;
|
|
8
8
|
};
|
|
9
|
-
declare const __VLS_component: import("vue").DefineComponent<MagicMenuChannelProps,
|
|
9
|
+
declare const __VLS_component: import("vue").DefineComponent<MagicMenuChannelProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<MagicMenuChannelProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
10
10
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
11
11
|
export default _default;
|
|
12
12
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -70,6 +70,9 @@ import { useMenuState } from "../composables/private/useMenuState";
|
|
|
70
70
|
import { useMenuCallback } from "../composables/private/useMenuCallback";
|
|
71
71
|
import { useMenuDOM } from "../composables/private/useMenuDOM";
|
|
72
72
|
import { useMenuCursor } from "../composables/private/useMenuCursor";
|
|
73
|
+
import {
|
|
74
|
+
useMagicError
|
|
75
|
+
} from "@maas/vue-equipment/plugins/MagicError";
|
|
73
76
|
import { ModeTransitions } from "../utils/modeTransitionDefaults";
|
|
74
77
|
import { ModeDelayMouseleave } from "../utils/modeDelayDefaults";
|
|
75
78
|
import {
|
|
@@ -88,14 +91,20 @@ const { arrow = void 0, transition } = defineProps({
|
|
|
88
91
|
transition: { type: String, required: false },
|
|
89
92
|
referenceEl: { type: null, required: false }
|
|
90
93
|
});
|
|
94
|
+
const magicError = useMagicError({
|
|
95
|
+
prefix: "MagicMenu",
|
|
96
|
+
source: "MagicMenu"
|
|
97
|
+
});
|
|
91
98
|
const instanceId = inject(MagicMenuInstanceId, void 0);
|
|
92
99
|
const viewId = inject(MagicMenuViewId, void 0);
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
100
|
+
magicError.assert(instanceId, {
|
|
101
|
+
message: "MagicMenuContent must be nested inside MagicMenuProvider",
|
|
102
|
+
errorCode: "missing_instance_id"
|
|
103
|
+
});
|
|
104
|
+
magicError.assert(viewId, {
|
|
105
|
+
message: "MagicMenuContent must be nested inside MagicMenuView",
|
|
106
|
+
errorCode: "missing_view_id"
|
|
107
|
+
});
|
|
99
108
|
const { getView, unselectView } = useMenuView(instanceId);
|
|
100
109
|
const view = getView(viewId);
|
|
101
110
|
const { initializeState } = useMenuState(instanceId);
|
|
@@ -14,7 +14,7 @@ type __VLS_Slots = {} & {
|
|
|
14
14
|
} & {
|
|
15
15
|
default?: (props: typeof __VLS_28) => any;
|
|
16
16
|
};
|
|
17
|
-
declare const __VLS_component: import("vue").DefineComponent<MagicMenuContentProps,
|
|
17
|
+
declare const __VLS_component: import("vue").DefineComponent<MagicMenuContentProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<MagicMenuContentProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
18
18
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
19
19
|
export default _default;
|
|
20
20
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -41,7 +41,7 @@ import { useMenuView } from "../composables/private/useMenuView";
|
|
|
41
41
|
import { useMenuState } from "../composables/private/useMenuState";
|
|
42
42
|
import { ModeFloatingStrategy } from "../utils/modeFloatingStrategyDefaults";
|
|
43
43
|
const { placement, middleware, arrow, referenceEl } = defineProps({
|
|
44
|
-
placement: { type:
|
|
44
|
+
placement: { type: String, required: false },
|
|
45
45
|
middleware: { type: Array, required: false },
|
|
46
46
|
arrow: { type: Boolean, required: false },
|
|
47
47
|
referenceEl: { type: null, required: false }
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type MaybeRef, type ComponentPublicInstance } from 'vue';
|
|
2
|
-
import { type
|
|
2
|
+
import { type Middleware } from '@floating-ui/vue';
|
|
3
|
+
import type { MenuPlacement } from '../types/index.js';
|
|
3
4
|
interface MagicMenuFloatProps {
|
|
4
|
-
placement?:
|
|
5
|
+
placement?: MenuPlacement;
|
|
5
6
|
middleware?: Middleware[];
|
|
6
7
|
arrow?: boolean;
|
|
7
8
|
referenceEl?: MaybeRef<HTMLElement | ComponentPublicInstance>;
|
|
@@ -12,7 +13,7 @@ type __VLS_Slots = {} & {
|
|
|
12
13
|
} & {
|
|
13
14
|
default?: (props: typeof __VLS_3) => any;
|
|
14
15
|
};
|
|
15
|
-
declare const __VLS_component: import("vue").DefineComponent<MagicMenuFloatProps,
|
|
16
|
+
declare const __VLS_component: import("vue").DefineComponent<MagicMenuFloatProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<MagicMenuFloatProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
16
17
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
17
18
|
export default _default;
|
|
18
19
|
type __VLS_WithSlots<T, S> = T & {
|