@maas/vue-equipment 1.0.0-beta.41 → 1.0.0-beta.43
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/useScrollLockPadding/index.d.ts +9 -0
- package/dist/composables/useScrollLockPadding/index.js +56 -0
- package/dist/composables/useScrollLockPadding/index.js.map +1 -0
- package/dist/nuxt/module.json +1 -1
- package/dist/nuxt/module.mjs +9 -2
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionContent.vue +3 -3
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionProvider.vue +7 -3
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionTrigger.vue +3 -3
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionView.vue +3 -3
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionTrigger.d.ts +2 -2
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionTrigger.mjs +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.d.vue.ts +2 -2
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.vue.d.ts +2 -2
- package/dist/plugins/MagicCommand/src/components/MagicCommandProvider.vue +7 -3
- package/dist/plugins/MagicCommand/src/components/MagicCommandTrigger.vue +3 -3
- package/dist/plugins/MagicCommand/src/components/MagicCommandView.vue +1 -1
- package/dist/plugins/MagicCommand/src/composables/private/useCommandTrigger.d.ts +2 -2
- package/dist/plugins/MagicCommand/src/composables/private/useCommandTrigger.mjs +1 -1
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableDrag.mjs +5 -14
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableScrollLock.d.ts +2 -4
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableScrollLock.mjs +11 -51
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue +4 -16
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerCallback.d.ts +0 -4
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerCallback.mjs +8 -12
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDOM.d.ts +2 -4
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDOM.mjs +15 -58
- package/dist/plugins/MagicEmitter/src/composables/useMagicEmitter.d.ts +36 -36
- package/dist/plugins/MagicMenu/src/components/MagicMenuContent.vue +4 -12
- package/dist/plugins/MagicMenu/src/components/MagicMenuItem.d.vue.ts +2 -2
- package/dist/plugins/MagicMenu/src/components/MagicMenuItem.vue.d.ts +2 -2
- package/dist/plugins/MagicMenu/src/components/MagicMenuProvider.vue +3 -3
- package/dist/plugins/MagicMenu/src/components/MagicMenuRemote.vue +3 -3
- package/dist/plugins/MagicMenu/src/components/MagicMenuTrigger.vue +3 -3
- package/dist/plugins/MagicMenu/src/composables/private/useMenuCallback.d.ts +1 -4
- package/dist/plugins/MagicMenu/src/composables/private/useMenuCallback.mjs +7 -21
- package/dist/plugins/MagicMenu/src/composables/private/useMenuDOM.d.ts +2 -4
- package/dist/plugins/MagicMenu/src/composables/private/useMenuDOM.mjs +13 -51
- package/dist/plugins/MagicMenu/src/composables/private/useMenuTrigger.d.ts +2 -2
- package/dist/plugins/MagicMenu/src/composables/private/useMenuTrigger.mjs +1 -1
- package/dist/plugins/MagicModal/src/components/MagicModal.vue +4 -16
- package/dist/plugins/MagicModal/src/composables/private/useModalCallback.d.ts +0 -4
- package/dist/plugins/MagicModal/src/composables/private/useModalCallback.mjs +9 -19
- package/dist/plugins/MagicModal/src/composables/private/useModalDOM.d.ts +2 -4
- package/dist/plugins/MagicModal/src/composables/private/useModalDOM.mjs +15 -58
- package/dist/plugins/MagicToast/src/composables/private/useToastDrag.mjs +5 -14
- package/dist/plugins/MagicToast/src/composables/private/useToastScrollLock.d.ts +2 -4
- package/dist/plugins/MagicToast/src/composables/private/useToastScrollLock.mjs +11 -49
- package/package.json +2 -2
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { shallowRef } 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
|
-
matchClass,
|
|
7
|
-
scrollbarGutterSupport,
|
|
8
|
-
scrollbarWidth
|
|
9
|
-
} from "@maas/vue-equipment/utils";
|
|
5
|
+
import { useScrollLockPadding } from "@maas/vue-equipment/composables/useScrollLockPadding";
|
|
10
6
|
const defaultOptions = {
|
|
11
7
|
focusTrap: false,
|
|
12
|
-
focusTarget: void 0
|
|
13
|
-
scrollLock: true
|
|
8
|
+
focusTarget: void 0
|
|
14
9
|
};
|
|
15
10
|
const scrollLock = typeof window !== "undefined" ? useScrollLock(document?.documentElement) : shallowRef(false);
|
|
11
|
+
const { add, remove } = useScrollLockPadding({
|
|
12
|
+
exclude: /magic-drawer(__backdrop)?/
|
|
13
|
+
});
|
|
16
14
|
export function useDrawerDOM(args) {
|
|
17
|
-
const positionFixedElements = ref([]);
|
|
18
15
|
const mappedOptions = defu(args, defaultOptions);
|
|
19
16
|
const focusTrap = mappedOptions.focusTarget ? typeof mappedOptions.focusTrap === "boolean" ? useFocusTrap(mappedOptions.focusTarget) : useFocusTrap(mappedOptions.focusTarget, mappedOptions.focusTrap) : void 0;
|
|
20
17
|
function trapFocus() {
|
|
@@ -27,62 +24,22 @@ export function useDrawerDOM(args) {
|
|
|
27
24
|
focusTrap.deactivate();
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
|
-
function lockScroll() {
|
|
31
|
-
if (
|
|
32
|
-
|
|
27
|
+
function lockScroll(padding) {
|
|
28
|
+
if (padding) {
|
|
29
|
+
add();
|
|
33
30
|
}
|
|
31
|
+
scrollLock.value = true;
|
|
34
32
|
}
|
|
35
|
-
function unlockScroll() {
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
function unlockScroll(padding) {
|
|
34
|
+
scrollLock.value = false;
|
|
35
|
+
if (padding) {
|
|
36
|
+
remove();
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
|
-
function addScrollLockPadding() {
|
|
41
|
-
if (typeof window === "undefined") {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const exclude = new RegExp(/magic-drawer(__backdrop)?/);
|
|
45
|
-
document.body.style.setProperty(
|
|
46
|
-
"--scrollbar-width",
|
|
47
|
-
`${scrollbarWidth()}px`
|
|
48
|
-
);
|
|
49
|
-
positionFixedElements.value = [
|
|
50
|
-
...document.body.getElementsByTagName("*")
|
|
51
|
-
].filter(
|
|
52
|
-
(x) => getComputedStyle(x, null).getPropertyValue("position") === "fixed" && getComputedStyle(x, null).getPropertyValue("right") === "0px" && !matchClass(x, exclude)
|
|
53
|
-
);
|
|
54
|
-
switch (scrollbarGutterSupport()) {
|
|
55
|
-
case true:
|
|
56
|
-
document.documentElement.style.scrollbarGutter = "stable";
|
|
57
|
-
positionFixedElements.value.forEach((elem) => {
|
|
58
|
-
elem.style.scrollbarGutter = "stable";
|
|
59
|
-
elem.style.overflow = "auto";
|
|
60
|
-
});
|
|
61
|
-
break;
|
|
62
|
-
case false:
|
|
63
|
-
document.body.style.paddingRight = "var(--scrollbar-width)";
|
|
64
|
-
positionFixedElements.value.forEach(
|
|
65
|
-
(elem) => elem.style.paddingRight = "var(--scrollbar-width)"
|
|
66
|
-
);
|
|
67
|
-
break;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
function removeScrollLockPadding() {
|
|
71
|
-
document.documentElement.style.scrollbarGutter = "";
|
|
72
|
-
document.body.style.removeProperty("--scrollbar-width");
|
|
73
|
-
document.body.style.paddingRight = "";
|
|
74
|
-
positionFixedElements.value.forEach((elem) => {
|
|
75
|
-
elem.style.paddingRight = "";
|
|
76
|
-
elem.style.scrollbarGutter = "";
|
|
77
|
-
elem.style.overflow = "";
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
39
|
return {
|
|
81
40
|
trapFocus,
|
|
82
41
|
releaseFocus,
|
|
83
42
|
lockScroll,
|
|
84
|
-
unlockScroll
|
|
85
|
-
addScrollLockPadding,
|
|
86
|
-
removeScrollLockPadding
|
|
43
|
+
unlockScroll
|
|
87
44
|
};
|
|
88
45
|
}
|
|
@@ -74,26 +74,26 @@ export declare function useMagicEmitter(): {
|
|
|
74
74
|
} & Omit<{
|
|
75
75
|
beforeSnap: {
|
|
76
76
|
id: string;
|
|
77
|
-
snapPoint: import("../../../
|
|
77
|
+
snapPoint: import("../../../MagicDrawer/src/types/index.js").DrawerSnapPoint;
|
|
78
78
|
} | {
|
|
79
79
|
id: string;
|
|
80
|
-
snapPoint: import("../../../
|
|
80
|
+
snapPoint: import("../../../MagicDraggable/src/types/index.js").DraggableSnapPoint;
|
|
81
81
|
};
|
|
82
82
|
snapTo: {
|
|
83
83
|
id: string;
|
|
84
|
-
snapPoint: import("../../../
|
|
84
|
+
snapPoint: import("../../../MagicDrawer/src/types/index.js").DrawerSnapPoint;
|
|
85
85
|
duration?: number;
|
|
86
86
|
} | {
|
|
87
87
|
id: string;
|
|
88
|
-
snapPoint: import("../../../
|
|
88
|
+
snapPoint: import("../../../MagicDraggable/src/types/index.js").DraggableSnapPoint;
|
|
89
89
|
duration?: number;
|
|
90
90
|
};
|
|
91
91
|
afterSnap: {
|
|
92
92
|
id: string;
|
|
93
|
-
snapPoint: import("../../../
|
|
93
|
+
snapPoint: import("../../../MagicDrawer/src/types/index.js").DrawerSnapPoint;
|
|
94
94
|
} | {
|
|
95
95
|
id: string;
|
|
96
|
-
snapPoint: import("../../../
|
|
96
|
+
snapPoint: import("../../../MagicDraggable/src/types/index.js").DraggableSnapPoint;
|
|
97
97
|
};
|
|
98
98
|
beforeDrag: {
|
|
99
99
|
id: string;
|
|
@@ -341,26 +341,26 @@ export declare function useMagicEmitter(): {
|
|
|
341
341
|
} & Omit<{
|
|
342
342
|
beforeSnap: {
|
|
343
343
|
id: string;
|
|
344
|
-
snapPoint: import("../../../
|
|
344
|
+
snapPoint: import("../../../MagicDrawer/src/types/index.js").DrawerSnapPoint;
|
|
345
345
|
} | {
|
|
346
346
|
id: string;
|
|
347
|
-
snapPoint: import("../../../
|
|
347
|
+
snapPoint: import("../../../MagicDraggable/src/types/index.js").DraggableSnapPoint;
|
|
348
348
|
};
|
|
349
349
|
snapTo: {
|
|
350
350
|
id: string;
|
|
351
|
-
snapPoint: import("../../../
|
|
351
|
+
snapPoint: import("../../../MagicDrawer/src/types/index.js").DrawerSnapPoint;
|
|
352
352
|
duration?: number;
|
|
353
353
|
} | {
|
|
354
354
|
id: string;
|
|
355
|
-
snapPoint: import("../../../
|
|
355
|
+
snapPoint: import("../../../MagicDraggable/src/types/index.js").DraggableSnapPoint;
|
|
356
356
|
duration?: number;
|
|
357
357
|
};
|
|
358
358
|
afterSnap: {
|
|
359
359
|
id: string;
|
|
360
|
-
snapPoint: import("../../../
|
|
360
|
+
snapPoint: import("../../../MagicDrawer/src/types/index.js").DrawerSnapPoint;
|
|
361
361
|
} | {
|
|
362
362
|
id: string;
|
|
363
|
-
snapPoint: import("../../../
|
|
363
|
+
snapPoint: import("../../../MagicDraggable/src/types/index.js").DraggableSnapPoint;
|
|
364
364
|
};
|
|
365
365
|
beforeDrag: {
|
|
366
366
|
id: string;
|
|
@@ -610,26 +610,26 @@ export declare function useMagicEmitter(): {
|
|
|
610
610
|
} & Omit<{
|
|
611
611
|
beforeSnap: {
|
|
612
612
|
id: string;
|
|
613
|
-
snapPoint: import("../../../
|
|
613
|
+
snapPoint: import("../../../MagicDrawer/src/types/index.js").DrawerSnapPoint;
|
|
614
614
|
} | {
|
|
615
615
|
id: string;
|
|
616
|
-
snapPoint: import("../../../
|
|
616
|
+
snapPoint: import("../../../MagicDraggable/src/types/index.js").DraggableSnapPoint;
|
|
617
617
|
};
|
|
618
618
|
snapTo: {
|
|
619
619
|
id: string;
|
|
620
|
-
snapPoint: import("../../../
|
|
620
|
+
snapPoint: import("../../../MagicDrawer/src/types/index.js").DrawerSnapPoint;
|
|
621
621
|
duration?: number;
|
|
622
622
|
} | {
|
|
623
623
|
id: string;
|
|
624
|
-
snapPoint: import("../../../
|
|
624
|
+
snapPoint: import("../../../MagicDraggable/src/types/index.js").DraggableSnapPoint;
|
|
625
625
|
duration?: number;
|
|
626
626
|
};
|
|
627
627
|
afterSnap: {
|
|
628
628
|
id: string;
|
|
629
|
-
snapPoint: import("../../../
|
|
629
|
+
snapPoint: import("../../../MagicDrawer/src/types/index.js").DrawerSnapPoint;
|
|
630
630
|
} | {
|
|
631
631
|
id: string;
|
|
632
|
-
snapPoint: import("../../../
|
|
632
|
+
snapPoint: import("../../../MagicDraggable/src/types/index.js").DraggableSnapPoint;
|
|
633
633
|
};
|
|
634
634
|
beforeDrag: {
|
|
635
635
|
id: string;
|
|
@@ -877,26 +877,26 @@ export declare function useMagicEmitter(): {
|
|
|
877
877
|
} & Omit<{
|
|
878
878
|
beforeSnap: {
|
|
879
879
|
id: string;
|
|
880
|
-
snapPoint: import("../../../
|
|
880
|
+
snapPoint: import("../../../MagicDrawer/src/types/index.js").DrawerSnapPoint;
|
|
881
881
|
} | {
|
|
882
882
|
id: string;
|
|
883
|
-
snapPoint: import("../../../
|
|
883
|
+
snapPoint: import("../../../MagicDraggable/src/types/index.js").DraggableSnapPoint;
|
|
884
884
|
};
|
|
885
885
|
snapTo: {
|
|
886
886
|
id: string;
|
|
887
|
-
snapPoint: import("../../../
|
|
887
|
+
snapPoint: import("../../../MagicDrawer/src/types/index.js").DrawerSnapPoint;
|
|
888
888
|
duration?: number;
|
|
889
889
|
} | {
|
|
890
890
|
id: string;
|
|
891
|
-
snapPoint: import("../../../
|
|
891
|
+
snapPoint: import("../../../MagicDraggable/src/types/index.js").DraggableSnapPoint;
|
|
892
892
|
duration?: number;
|
|
893
893
|
};
|
|
894
894
|
afterSnap: {
|
|
895
895
|
id: string;
|
|
896
|
-
snapPoint: import("../../../
|
|
896
|
+
snapPoint: import("../../../MagicDrawer/src/types/index.js").DrawerSnapPoint;
|
|
897
897
|
} | {
|
|
898
898
|
id: string;
|
|
899
|
-
snapPoint: import("../../../
|
|
899
|
+
snapPoint: import("../../../MagicDraggable/src/types/index.js").DraggableSnapPoint;
|
|
900
900
|
};
|
|
901
901
|
beforeDrag: {
|
|
902
902
|
id: string;
|
|
@@ -1146,26 +1146,26 @@ export declare function useMagicEmitter(): {
|
|
|
1146
1146
|
} & Omit<{
|
|
1147
1147
|
beforeSnap: {
|
|
1148
1148
|
id: string;
|
|
1149
|
-
snapPoint: import("../../../
|
|
1149
|
+
snapPoint: import("../../../MagicDrawer/src/types/index.js").DrawerSnapPoint;
|
|
1150
1150
|
} | {
|
|
1151
1151
|
id: string;
|
|
1152
|
-
snapPoint: import("../../../
|
|
1152
|
+
snapPoint: import("../../../MagicDraggable/src/types/index.js").DraggableSnapPoint;
|
|
1153
1153
|
};
|
|
1154
1154
|
snapTo: {
|
|
1155
1155
|
id: string;
|
|
1156
|
-
snapPoint: import("../../../
|
|
1156
|
+
snapPoint: import("../../../MagicDrawer/src/types/index.js").DrawerSnapPoint;
|
|
1157
1157
|
duration?: number;
|
|
1158
1158
|
} | {
|
|
1159
1159
|
id: string;
|
|
1160
|
-
snapPoint: import("../../../
|
|
1160
|
+
snapPoint: import("../../../MagicDraggable/src/types/index.js").DraggableSnapPoint;
|
|
1161
1161
|
duration?: number;
|
|
1162
1162
|
};
|
|
1163
1163
|
afterSnap: {
|
|
1164
1164
|
id: string;
|
|
1165
|
-
snapPoint: import("../../../
|
|
1165
|
+
snapPoint: import("../../../MagicDrawer/src/types/index.js").DrawerSnapPoint;
|
|
1166
1166
|
} | {
|
|
1167
1167
|
id: string;
|
|
1168
|
-
snapPoint: import("../../../
|
|
1168
|
+
snapPoint: import("../../../MagicDraggable/src/types/index.js").DraggableSnapPoint;
|
|
1169
1169
|
};
|
|
1170
1170
|
beforeDrag: {
|
|
1171
1171
|
id: string;
|
|
@@ -1413,26 +1413,26 @@ export declare function useMagicEmitter(): {
|
|
|
1413
1413
|
} & Omit<{
|
|
1414
1414
|
beforeSnap: {
|
|
1415
1415
|
id: string;
|
|
1416
|
-
snapPoint: import("../../../
|
|
1416
|
+
snapPoint: import("../../../MagicDrawer/src/types/index.js").DrawerSnapPoint;
|
|
1417
1417
|
} | {
|
|
1418
1418
|
id: string;
|
|
1419
|
-
snapPoint: import("../../../
|
|
1419
|
+
snapPoint: import("../../../MagicDraggable/src/types/index.js").DraggableSnapPoint;
|
|
1420
1420
|
};
|
|
1421
1421
|
snapTo: {
|
|
1422
1422
|
id: string;
|
|
1423
|
-
snapPoint: import("../../../
|
|
1423
|
+
snapPoint: import("../../../MagicDrawer/src/types/index.js").DrawerSnapPoint;
|
|
1424
1424
|
duration?: number;
|
|
1425
1425
|
} | {
|
|
1426
1426
|
id: string;
|
|
1427
|
-
snapPoint: import("../../../
|
|
1427
|
+
snapPoint: import("../../../MagicDraggable/src/types/index.js").DraggableSnapPoint;
|
|
1428
1428
|
duration?: number;
|
|
1429
1429
|
};
|
|
1430
1430
|
afterSnap: {
|
|
1431
1431
|
id: string;
|
|
1432
|
-
snapPoint: import("../../../
|
|
1432
|
+
snapPoint: import("../../../MagicDrawer/src/types/index.js").DrawerSnapPoint;
|
|
1433
1433
|
} | {
|
|
1434
1434
|
id: string;
|
|
1435
|
-
snapPoint: import("../../../
|
|
1435
|
+
snapPoint: import("../../../MagicDraggable/src/types/index.js").DraggableSnapPoint;
|
|
1436
1436
|
};
|
|
1437
1437
|
beforeDrag: {
|
|
1438
1438
|
id: string;
|
|
@@ -68,7 +68,6 @@ import {
|
|
|
68
68
|
import { useMenuView } from "../composables/private/useMenuView";
|
|
69
69
|
import { useMenuState } from "../composables/private/useMenuState";
|
|
70
70
|
import { useMenuCallback } from "../composables/private/useMenuCallback";
|
|
71
|
-
import { useMenuDOM } from "../composables/private/useMenuDOM";
|
|
72
71
|
import { useMenuCursor } from "../composables/private/useMenuCursor";
|
|
73
72
|
import {
|
|
74
73
|
useMagicError
|
|
@@ -78,7 +77,8 @@ import { ModeDelayMouseleave } from "../utils/modeDelayDefaults";
|
|
|
78
77
|
import {
|
|
79
78
|
MagicMenuInstanceId,
|
|
80
79
|
MagicMenuViewId,
|
|
81
|
-
MagicMenuContentId
|
|
80
|
+
MagicMenuContentId,
|
|
81
|
+
MagicMenuParentTree
|
|
82
82
|
} from "../symbols";
|
|
83
83
|
import "@maas/vue-equipment/utils/css/keyframes/fade-in.css";
|
|
84
84
|
import "@maas/vue-equipment/utils/css/keyframes/fade-out.css";
|
|
@@ -95,6 +95,7 @@ const magicError = useMagicError({
|
|
|
95
95
|
prefix: "MagicMenu",
|
|
96
96
|
source: "MagicMenu"
|
|
97
97
|
});
|
|
98
|
+
const parentTree = inject(MagicMenuParentTree, []);
|
|
98
99
|
const instanceId = inject(MagicMenuInstanceId, void 0);
|
|
99
100
|
const viewId = inject(MagicMenuViewId, void 0);
|
|
100
101
|
magicError.assert(instanceId, {
|
|
@@ -124,12 +125,6 @@ const mappedTransition = computed(() => {
|
|
|
124
125
|
});
|
|
125
126
|
const innerActive = shallowRef(false);
|
|
126
127
|
const wrapperActive = shallowRef(false);
|
|
127
|
-
const {
|
|
128
|
-
lockScroll,
|
|
129
|
-
unlockScroll,
|
|
130
|
-
addScrollLockPadding,
|
|
131
|
-
removeScrollLockPadding
|
|
132
|
-
} = useMenuDOM();
|
|
133
128
|
const {
|
|
134
129
|
onBeforeEnter,
|
|
135
130
|
onEnter,
|
|
@@ -143,10 +138,7 @@ const {
|
|
|
143
138
|
viewId,
|
|
144
139
|
innerActive,
|
|
145
140
|
wrapperActive,
|
|
146
|
-
|
|
147
|
-
unlockScroll,
|
|
148
|
-
addScrollLockPadding,
|
|
149
|
-
removeScrollLockPadding
|
|
141
|
+
parentTree
|
|
150
142
|
});
|
|
151
143
|
async function onOpen() {
|
|
152
144
|
wrapperActive.value = true;
|
|
@@ -10,11 +10,11 @@ type __VLS_Slots = {} & {
|
|
|
10
10
|
default?: (props: typeof __VLS_1) => any;
|
|
11
11
|
};
|
|
12
12
|
declare const __VLS_base: import("vue").DefineComponent<MagicMenuItemProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
13
|
-
click: (event: MouseEvent) => any;
|
|
14
13
|
enter: () => any;
|
|
14
|
+
click: (event: MouseEvent) => any;
|
|
15
15
|
}, string, import("vue").PublicProps, Readonly<MagicMenuItemProps> & Readonly<{
|
|
16
|
-
onClick?: ((event: MouseEvent) => any) | undefined;
|
|
17
16
|
onEnter?: (() => any) | undefined;
|
|
17
|
+
onClick?: ((event: MouseEvent) => any) | undefined;
|
|
18
18
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
19
19
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
20
20
|
declare const _default: typeof __VLS_export;
|
|
@@ -10,11 +10,11 @@ type __VLS_Slots = {} & {
|
|
|
10
10
|
default?: (props: typeof __VLS_1) => any;
|
|
11
11
|
};
|
|
12
12
|
declare const __VLS_base: import("vue").DefineComponent<MagicMenuItemProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
13
|
-
click: (event: MouseEvent) => any;
|
|
14
13
|
enter: () => any;
|
|
14
|
+
click: (event: MouseEvent) => any;
|
|
15
15
|
}, string, import("vue").PublicProps, Readonly<MagicMenuItemProps> & Readonly<{
|
|
16
|
-
onClick?: ((event: MouseEvent) => any) | undefined;
|
|
17
16
|
onEnter?: (() => any) | undefined;
|
|
17
|
+
onClick?: ((event: MouseEvent) => any) | undefined;
|
|
18
18
|
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
19
19
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
20
20
|
declare const _default: typeof __VLS_export;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<primitive
|
|
2
|
+
<vue-primitive
|
|
3
3
|
ref="el"
|
|
4
4
|
:as-child="asChild"
|
|
5
5
|
:data-id="id"
|
|
6
6
|
class="magic-menu-provider"
|
|
7
7
|
>
|
|
8
8
|
<slot />
|
|
9
|
-
</primitive>
|
|
9
|
+
</vue-primitive>
|
|
10
10
|
</template>
|
|
11
11
|
|
|
12
12
|
<script setup>
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
onBeforeUnmount
|
|
20
20
|
} from "vue";
|
|
21
21
|
import { onClickOutside, onKeyStroke, usePointer } from "@vueuse/core";
|
|
22
|
-
import {
|
|
22
|
+
import { VuePrimitive } from "@maas/vue-primitive";
|
|
23
23
|
import { defu } from "defu";
|
|
24
24
|
import { useMenuState } from "../composables/private/useMenuState";
|
|
25
25
|
import { useMenuView } from "../composables/private/useMenuView";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<primitive
|
|
2
|
+
<vue-primitive
|
|
3
3
|
class="magic-menu-remote"
|
|
4
4
|
:data-id="`${channelId}-remote`"
|
|
5
5
|
:data-disabled="disabled"
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
@mouseenter="onMouseenter"
|
|
10
10
|
>
|
|
11
11
|
<slot :channel-active="channel?.active" :remote-disabled="disabled" />
|
|
12
|
-
</primitive>
|
|
12
|
+
</vue-primitive>
|
|
13
13
|
</template>
|
|
14
14
|
|
|
15
15
|
<script setup>
|
|
16
16
|
import { computed, inject, watch } from "vue";
|
|
17
|
-
import {
|
|
17
|
+
import { VuePrimitive } from "@maas/vue-primitive";
|
|
18
18
|
import {
|
|
19
19
|
useMagicError
|
|
20
20
|
} from "@maas/vue-equipment/plugins/MagicError";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<primitive
|
|
2
|
+
<vue-primitive
|
|
3
3
|
ref="el"
|
|
4
4
|
:data-id="`${mappedViewId}-trigger`"
|
|
5
5
|
:data-active="view?.active"
|
|
@@ -12,12 +12,12 @@
|
|
|
12
12
|
@mouseenter="onMouseenter"
|
|
13
13
|
>
|
|
14
14
|
<slot :view-active="view?.active" :trigger-disabled="mappedDisabled" />
|
|
15
|
-
</primitive>
|
|
15
|
+
</vue-primitive>
|
|
16
16
|
</template>
|
|
17
17
|
|
|
18
18
|
<script setup>
|
|
19
19
|
import { computed, inject, useTemplateRef, toValue, watch } from "vue";
|
|
20
|
-
import {
|
|
20
|
+
import { VuePrimitive } from "@maas/vue-primitive";
|
|
21
21
|
import {
|
|
22
22
|
useMagicError
|
|
23
23
|
} from "@maas/vue-equipment/plugins/MagicError";
|
|
@@ -6,10 +6,7 @@ type UseMenuCallbackArgs = {
|
|
|
6
6
|
viewId: string;
|
|
7
7
|
innerActive: Ref<boolean>;
|
|
8
8
|
wrapperActive: Ref<boolean>;
|
|
9
|
-
|
|
10
|
-
unlockScroll: () => void;
|
|
11
|
-
addScrollLockPadding: () => void;
|
|
12
|
-
removeScrollLockPadding: () => void;
|
|
9
|
+
parentTree: string[];
|
|
13
10
|
};
|
|
14
11
|
export declare function useMenuCallback(args: UseMenuCallbackArgs): {
|
|
15
12
|
onBeforeEnter: () => void;
|
|
@@ -1,19 +1,11 @@
|
|
|
1
1
|
import { toValue } from "vue";
|
|
2
2
|
import { useMagicEmitter } from "@maas/vue-equipment/plugins/MagicEmitter";
|
|
3
|
+
import { useMenuDOM } from "./useMenuDOM.mjs";
|
|
3
4
|
import { ModeScrollLock } from "../../utils/modeScrollLockDefaults.mjs";
|
|
4
5
|
export function useMenuCallback(args) {
|
|
5
|
-
const {
|
|
6
|
-
state,
|
|
7
|
-
instanceId,
|
|
8
|
-
viewId,
|
|
9
|
-
innerActive,
|
|
10
|
-
wrapperActive,
|
|
11
|
-
lockScroll,
|
|
12
|
-
unlockScroll,
|
|
13
|
-
addScrollLockPadding,
|
|
14
|
-
removeScrollLockPadding
|
|
15
|
-
} = args;
|
|
6
|
+
const { state, instanceId, viewId, innerActive, wrapperActive, parentTree } = args;
|
|
16
7
|
const emitter = useMagicEmitter();
|
|
8
|
+
const { lockScroll, unlockScroll } = useMenuDOM();
|
|
17
9
|
function onBeforeEnter() {
|
|
18
10
|
emitter.emit("beforeEnter", { id: toValue(instanceId), viewId });
|
|
19
11
|
}
|
|
@@ -23,11 +15,8 @@ export function useMenuCallback(args) {
|
|
|
23
15
|
function onAfterEnter() {
|
|
24
16
|
emitter.emit("afterEnter", { id: toValue(instanceId), viewId });
|
|
25
17
|
const scrollLock = state.options.scrollLock ?? ModeScrollLock[state.options.mode].value;
|
|
26
|
-
if (scrollLock) {
|
|
27
|
-
|
|
28
|
-
addScrollLockPadding();
|
|
29
|
-
}
|
|
30
|
-
lockScroll();
|
|
18
|
+
if (scrollLock && parentTree.length === 2) {
|
|
19
|
+
lockScroll(typeof scrollLock === "object" && scrollLock.padding);
|
|
31
20
|
}
|
|
32
21
|
}
|
|
33
22
|
function onBeforeLeave() {
|
|
@@ -39,11 +28,8 @@ export function useMenuCallback(args) {
|
|
|
39
28
|
function onAfterLeave() {
|
|
40
29
|
emitter.emit("afterLeave", { id: toValue(instanceId), viewId });
|
|
41
30
|
const scrollLock = state.options.scrollLock ?? ModeScrollLock[state.options.mode].value;
|
|
42
|
-
if (scrollLock) {
|
|
43
|
-
unlockScroll();
|
|
44
|
-
if (typeof scrollLock === "object" && scrollLock.padding) {
|
|
45
|
-
removeScrollLockPadding();
|
|
46
|
-
}
|
|
31
|
+
if (scrollLock && parentTree.length === 2) {
|
|
32
|
+
unlockScroll(typeof scrollLock === "object" && scrollLock.padding);
|
|
47
33
|
}
|
|
48
34
|
if (!innerActive.value) {
|
|
49
35
|
wrapperActive.value = false;
|
|
@@ -1,63 +1,25 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { shallowRef } from "vue";
|
|
2
2
|
import { useScrollLock } from "@vueuse/core";
|
|
3
|
-
import {
|
|
4
|
-
matchClass,
|
|
5
|
-
scrollbarGutterSupport,
|
|
6
|
-
scrollbarWidth
|
|
7
|
-
} from "@maas/vue-equipment/utils";
|
|
3
|
+
import { useScrollLockPadding } from "@maas/vue-equipment/composables/useScrollLockPadding";
|
|
8
4
|
const scrollLock = typeof window !== "undefined" ? useScrollLock(document?.documentElement) : shallowRef(false);
|
|
5
|
+
const { add, remove } = useScrollLockPadding({
|
|
6
|
+
exclude: /magic-menu/
|
|
7
|
+
});
|
|
9
8
|
export function useMenuDOM() {
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
function lockScroll(padding) {
|
|
10
|
+
if (padding) {
|
|
11
|
+
add();
|
|
12
|
+
}
|
|
12
13
|
scrollLock.value = true;
|
|
13
14
|
}
|
|
14
|
-
function unlockScroll() {
|
|
15
|
+
function unlockScroll(padding) {
|
|
15
16
|
scrollLock.value = false;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
if (typeof window === "undefined") {
|
|
19
|
-
return;
|
|
17
|
+
if (padding) {
|
|
18
|
+
remove();
|
|
20
19
|
}
|
|
21
|
-
const exclude = new RegExp(/magic-menu/);
|
|
22
|
-
document.body.style.setProperty(
|
|
23
|
-
"--scrollbar-width",
|
|
24
|
-
`${scrollbarWidth()}px`
|
|
25
|
-
);
|
|
26
|
-
positionFixedElements.value = [
|
|
27
|
-
...document.body.getElementsByTagName("*")
|
|
28
|
-
].filter(
|
|
29
|
-
(x) => getComputedStyle(x, null).getPropertyValue("position") === "fixed" && getComputedStyle(x, null).getPropertyValue("right") === "0px" && !matchClass(x, exclude)
|
|
30
|
-
);
|
|
31
|
-
switch (scrollbarGutterSupport()) {
|
|
32
|
-
case true:
|
|
33
|
-
document.documentElement.style.scrollbarGutter = "stable";
|
|
34
|
-
positionFixedElements.value.forEach((elem) => {
|
|
35
|
-
elem.style.scrollbarGutter = "stable";
|
|
36
|
-
elem.style.overflow = "auto";
|
|
37
|
-
});
|
|
38
|
-
break;
|
|
39
|
-
case false:
|
|
40
|
-
document.body.style.paddingRight = "var(--scrollbar-width)";
|
|
41
|
-
positionFixedElements.value.forEach(
|
|
42
|
-
(elem) => elem.style.paddingRight = "var(--scrollbar-width)"
|
|
43
|
-
);
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
function removeScrollLockPadding() {
|
|
48
|
-
document.documentElement.style.scrollbarGutter = "";
|
|
49
|
-
document.body.style.removeProperty("--scrollbar-width");
|
|
50
|
-
document.body.style.paddingRight = "";
|
|
51
|
-
positionFixedElements.value.forEach((elem) => {
|
|
52
|
-
elem.style.paddingRight = "";
|
|
53
|
-
elem.style.scrollbarGutter = "";
|
|
54
|
-
elem.style.overflow = "";
|
|
55
|
-
});
|
|
56
20
|
}
|
|
57
21
|
return {
|
|
58
22
|
lockScroll,
|
|
59
|
-
unlockScroll
|
|
60
|
-
addScrollLockPadding,
|
|
61
|
-
removeScrollLockPadding
|
|
23
|
+
unlockScroll
|
|
62
24
|
};
|
|
63
25
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ComputedRef, type MaybeRef, type Ref } from 'vue';
|
|
2
|
-
import {
|
|
2
|
+
import { VuePrimitive } from '@maas/vue-primitive';
|
|
3
3
|
import type { Interaction } from '../../types/index.js';
|
|
4
4
|
type UseMenuTriggerArgs = {
|
|
5
5
|
instanceId: MaybeRef<string>;
|
|
@@ -7,7 +7,7 @@ type UseMenuTriggerArgs = {
|
|
|
7
7
|
itemId?: string;
|
|
8
8
|
mappedDisabled: ComputedRef<boolean>;
|
|
9
9
|
mappedTrigger: ComputedRef<Interaction[]>;
|
|
10
|
-
elRef: Ref<InstanceType<typeof
|
|
10
|
+
elRef: Ref<InstanceType<typeof VuePrimitive> | null>;
|
|
11
11
|
};
|
|
12
12
|
export declare function useMenuTrigger(args: UseMenuTriggerArgs): {
|
|
13
13
|
onMouseenter: () => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {} from "vue";
|
|
2
|
-
import {
|
|
2
|
+
import { VuePrimitive } from "@maas/vue-primitive";
|
|
3
3
|
import { useMagicKeys, useFocus } from "@vueuse/core";
|
|
4
4
|
import { useMenuView } from "./useMenuView.mjs";
|
|
5
5
|
import { useMenuState } from "./useMenuState.mjs";
|