@maas/vue-equipment 1.0.0-beta.13 → 1.0.0-beta.14
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/nuxt/module.json +1 -1
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionContent.vue +65 -82
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionContent.vue.d.ts +2 -2
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionProvider.vue +24 -30
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionTrigger.vue +65 -61
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionTrigger.vue.d.ts +1 -1
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionView.vue +41 -45
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionView.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandContent.vue +137 -150
- package/dist/plugins/MagicCommand/src/components/MagicCommandContent.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandDrawer.vue +45 -52
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.vue +80 -82
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandModal.vue +40 -47
- package/dist/plugins/MagicCommand/src/components/MagicCommandProvider.vue +68 -74
- package/dist/plugins/MagicCommand/src/components/MagicCommandRenderer.vue +22 -38
- package/dist/plugins/MagicCommand/src/components/MagicCommandTrigger.vue +95 -85
- package/dist/plugins/MagicCommand/src/components/MagicCommandTrigger.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandView.vue +41 -47
- package/dist/plugins/MagicCommand/src/components/MagicCommandView.vue.d.ts +1 -1
- package/dist/plugins/MagicCookie/src/components/MagicCookieItem.vue +41 -39
- package/dist/plugins/MagicCookie/src/components/MagicCookieItem.vue.d.ts +2 -2
- package/dist/plugins/MagicCookie/src/components/MagicCookieProvider.vue +23 -34
- package/dist/plugins/MagicCookie/src/components/MagicCookieView.vue +40 -73
- package/dist/plugins/MagicCookie/src/components/MagicCookieView.vue.d.ts +1 -1
- package/dist/plugins/MagicDraggable/src/components/MagicDraggable.vue +70 -87
- package/dist/plugins/MagicDraggable/src/components/MagicDraggable.vue.d.ts +7 -7
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue +262 -304
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue.d.ts +12 -12
- package/dist/plugins/MagicEmitter/src/composables/useMagicEmitter.d.ts +100 -100
- package/dist/plugins/MagicMarquee/src/components/MagicMarquee.vue +41 -69
- package/dist/plugins/MagicMarquee/src/composables/useMagicMarquee.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuChannel.vue +54 -59
- package/dist/plugins/MagicMenu/src/components/MagicMenuChannel.vue.d.ts +2 -2
- package/dist/plugins/MagicMenu/src/components/MagicMenuContent.vue +188 -208
- package/dist/plugins/MagicMenu/src/components/MagicMenuContent.vue.d.ts +3 -3
- package/dist/plugins/MagicMenu/src/components/MagicMenuFloat.vue +181 -194
- package/dist/plugins/MagicMenu/src/components/MagicMenuItem.vue +91 -100
- package/dist/plugins/MagicMenu/src/components/MagicMenuItem.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuProvider.vue +83 -85
- package/dist/plugins/MagicMenu/src/components/MagicMenuRemote.vue +79 -75
- package/dist/plugins/MagicMenu/src/components/MagicMenuRemote.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuTrigger.vue +106 -105
- package/dist/plugins/MagicMenu/src/components/MagicMenuTrigger.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuView.vue +54 -60
- package/dist/plugins/MagicMenu/src/components/MagicMenuView.vue.d.ts +1 -1
- package/dist/plugins/MagicModal/src/components/MagicModal.vue +136 -164
- package/dist/plugins/MagicModal/src/components/MagicModal.vue.d.ts +1 -1
- package/dist/plugins/MagicNoise/src/components/MagicNoise.vue +53 -78
- package/dist/plugins/MagicPie/src/components/MagicPie.vue +147 -175
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudio.vue +49 -65
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudioControls.vue +87 -129
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerDisplayTime.vue +33 -41
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerMuxPopover.vue +99 -109
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerOverlay.vue +47 -75
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerPoster.vue +16 -31
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerProvider.vue +43 -44
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerTimeline.vue +52 -109
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideo.vue +65 -72
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideoControls.vue +154 -225
- package/dist/plugins/MagicPlayer/src/composables/useMagicPlayer.d.ts +1 -1
- package/dist/plugins/MagicScroll/src/components/MagicScrollCollision.vue +49 -59
- package/dist/plugins/MagicScroll/src/components/MagicScrollMotion.vue +63 -70
- package/dist/plugins/MagicScroll/src/components/MagicScrollProvider.vue +29 -33
- package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue +59 -69
- package/dist/plugins/MagicToast/src/components/MagicToastProvider.vue +80 -95
- package/dist/plugins/MagicToast/src/components/MagicToastView.vue +52 -70
- package/dist/plugins/MagicToast/src/components/MagicToastView.vue.d.ts +2 -2
- package/package.json +1 -1
- package/dist/plugins/MagicAccordion/demo/data/footer.json +0 -117
- package/dist/plugins/MagicCommand/demo/data/about.json +0 -3
- package/dist/plugins/MagicCommand/demo/data/search.json +0 -594
|
@@ -9,8 +9,8 @@ interface MagicMenuContentProps {
|
|
|
9
9
|
referenceEl?: MaybeRef<HTMLElement | ComponentPublicInstance>;
|
|
10
10
|
}
|
|
11
11
|
declare const viewId: string | undefined;
|
|
12
|
-
declare const view: import("../types").MenuView | undefined;
|
|
13
|
-
declare const state: import("../types").MenuState;
|
|
12
|
+
declare const view: import("../types/index.js").MenuView | undefined;
|
|
13
|
+
declare const state: import("../types/index.js").MenuState;
|
|
14
14
|
declare const pointerDisabled: import("vue").ComputedRef<boolean>;
|
|
15
15
|
declare const mappedTransition: import("vue").ComputedRef<string>;
|
|
16
16
|
declare const innerActive: import("vue").ShallowRef<boolean, boolean>;
|
|
@@ -19,7 +19,7 @@ declare const onBeforeEnter: () => void, onEnter: () => void, onAfterEnter: () =
|
|
|
19
19
|
declare const coords: import("vue").Ref<{
|
|
20
20
|
x: number;
|
|
21
21
|
y: number;
|
|
22
|
-
}[], import("../types").Coordinates[] | {
|
|
22
|
+
}[], import("../types/index.js").Coordinates[] | {
|
|
23
23
|
x: number;
|
|
24
24
|
y: number;
|
|
25
25
|
}[]>;
|
|
@@ -1,11 +1,27 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
ref="el"
|
|
4
|
+
class="magic-menu-float"
|
|
5
|
+
:style="floatingStyles"
|
|
6
|
+
:class="placementClasses"
|
|
7
|
+
>
|
|
8
|
+
<div
|
|
9
|
+
v-if="hasArrow"
|
|
10
|
+
ref="arrow"
|
|
11
|
+
class="magic-menu-float__arrow"
|
|
12
|
+
:style="arrowStyles"
|
|
13
|
+
>
|
|
14
|
+
<slot name="arrow">
|
|
15
|
+
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
|
|
16
|
+
<polygon :points="polygonPoints" fill="currentColor" />
|
|
17
|
+
</svg>
|
|
18
|
+
</slot>
|
|
19
|
+
</div>
|
|
20
|
+
<slot />
|
|
21
|
+
</div>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<script setup>
|
|
9
25
|
import {
|
|
10
26
|
useTemplateRef,
|
|
11
27
|
computed,
|
|
@@ -24,199 +40,170 @@ import { MagicMenuInstanceId, MagicMenuViewId } from "../symbols";
|
|
|
24
40
|
import { useMenuView } from "../composables/private/useMenuView";
|
|
25
41
|
import { useMenuState } from "../composables/private/useMenuState";
|
|
26
42
|
import { ModeFloatingStrategy } from "../utils/modeFloatingStrategyDefaults";
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
middleware: { type: Array, required: false },
|
|
32
|
-
arrow: { type: Boolean, required: false },
|
|
33
|
-
referenceEl: { type: null, required: false }
|
|
43
|
+
const { placement, middleware, arrow, referenceEl } = defineProps({
|
|
44
|
+
placement: {
|
|
45
|
+
type: null,
|
|
46
|
+
required: false
|
|
34
47
|
},
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
48
|
+
middleware: {
|
|
49
|
+
type: Array,
|
|
50
|
+
required: false
|
|
51
|
+
},
|
|
52
|
+
arrow: {
|
|
53
|
+
type: Boolean,
|
|
54
|
+
required: false
|
|
55
|
+
},
|
|
56
|
+
referenceEl: {
|
|
57
|
+
type: null,
|
|
58
|
+
required: false
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
const elRef = useTemplateRef("el");
|
|
62
|
+
const arrowRef = useTemplateRef("arrow");
|
|
63
|
+
const instanceId = inject(MagicMenuInstanceId, void 0);
|
|
64
|
+
const viewId = inject(MagicMenuViewId, void 0);
|
|
65
|
+
const { initializeState } = useMenuState(instanceId ?? "");
|
|
66
|
+
const state = initializeState();
|
|
67
|
+
const { getView } = useMenuView(instanceId ?? "");
|
|
68
|
+
const view = getView(viewId ?? "");
|
|
69
|
+
const mappedPlacement = computed(() => {
|
|
70
|
+
if (placement) {
|
|
71
|
+
return placement;
|
|
72
|
+
}
|
|
73
|
+
switch (state.options.mode) {
|
|
74
|
+
case "menubar":
|
|
75
|
+
return !view?.parent.item ? "bottom-start" : "right-start";
|
|
76
|
+
case "dropdown":
|
|
77
|
+
return !view?.parent.item ? "bottom" : "right-start";
|
|
78
|
+
case "context":
|
|
79
|
+
return "right-start";
|
|
80
|
+
default:
|
|
81
|
+
return void 0;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
const hasArrow = computed(
|
|
85
|
+
() => arrow ?? (state.options.mode === "dropdown" && !view?.parent.item)
|
|
86
|
+
);
|
|
87
|
+
const mappedMiddleware = computed(() => {
|
|
88
|
+
const combined = [];
|
|
89
|
+
if (middleware) {
|
|
90
|
+
combined.push(...middleware);
|
|
91
|
+
}
|
|
92
|
+
switch (state.options.mode) {
|
|
93
|
+
case "menubar":
|
|
94
|
+
if (!view?.parent.item) {
|
|
95
|
+
combined.push(
|
|
96
|
+
flip({
|
|
97
|
+
crossAxis: true
|
|
98
|
+
})
|
|
99
|
+
);
|
|
100
|
+
} else if (!!view?.parent.item) {
|
|
101
|
+
combined.push(
|
|
102
|
+
flip({
|
|
103
|
+
crossAxis: false
|
|
104
|
+
})
|
|
105
|
+
);
|
|
106
|
+
combined.push(
|
|
107
|
+
shift({
|
|
108
|
+
crossAxis: true,
|
|
109
|
+
limiter: limitShift()
|
|
110
|
+
})
|
|
111
|
+
);
|
|
66
112
|
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
break;
|
|
89
|
-
case "dropdown":
|
|
90
|
-
combined.push(
|
|
91
|
-
flip({
|
|
92
|
-
mainAxis: true,
|
|
93
|
-
crossAxis: false
|
|
94
|
-
})
|
|
95
|
-
);
|
|
96
|
-
combined.push(
|
|
97
|
-
shift({
|
|
98
|
-
mainAxis: true,
|
|
99
|
-
crossAxis: false,
|
|
100
|
-
limiter: limitShift()
|
|
101
|
-
})
|
|
102
|
-
);
|
|
103
|
-
if (hasArrow.value) {
|
|
104
|
-
combined.push(
|
|
105
|
-
floatingArrow({
|
|
106
|
-
element: arrowRef.value
|
|
107
|
-
})
|
|
108
|
-
);
|
|
109
|
-
}
|
|
110
|
-
break;
|
|
111
|
-
case "context":
|
|
112
|
-
combined.push(
|
|
113
|
-
flip({
|
|
114
|
-
mainAxis: true,
|
|
115
|
-
crossAxis: true
|
|
116
|
-
})
|
|
117
|
-
);
|
|
118
|
-
break;
|
|
113
|
+
break;
|
|
114
|
+
case "dropdown":
|
|
115
|
+
combined.push(
|
|
116
|
+
flip({
|
|
117
|
+
mainAxis: true,
|
|
118
|
+
crossAxis: false
|
|
119
|
+
})
|
|
120
|
+
);
|
|
121
|
+
combined.push(
|
|
122
|
+
shift({
|
|
123
|
+
mainAxis: true,
|
|
124
|
+
crossAxis: false,
|
|
125
|
+
limiter: limitShift()
|
|
126
|
+
})
|
|
127
|
+
);
|
|
128
|
+
if (hasArrow.value) {
|
|
129
|
+
combined.push(
|
|
130
|
+
floatingArrow({
|
|
131
|
+
element: arrowRef.value
|
|
132
|
+
})
|
|
133
|
+
);
|
|
119
134
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
135
|
+
break;
|
|
136
|
+
case "context":
|
|
137
|
+
combined.push(
|
|
138
|
+
flip({
|
|
139
|
+
mainAxis: true,
|
|
140
|
+
crossAxis: true
|
|
141
|
+
})
|
|
142
|
+
);
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
return combined;
|
|
146
|
+
});
|
|
147
|
+
const mappedReferenceEl = computed(() => {
|
|
148
|
+
if (referenceEl) {
|
|
149
|
+
return toValue(referenceEl);
|
|
150
|
+
} else if (view?.state.clicked) {
|
|
151
|
+
return {
|
|
152
|
+
getBoundingClientRect() {
|
|
126
153
|
return {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
right: view.state.clicked.x,
|
|
136
|
-
bottom: view.state.clicked.y
|
|
137
|
-
};
|
|
138
|
-
}
|
|
154
|
+
width: 0,
|
|
155
|
+
height: 0,
|
|
156
|
+
x: view.state.clicked.x,
|
|
157
|
+
y: view.state.clicked.y,
|
|
158
|
+
top: view.state.clicked.y,
|
|
159
|
+
left: view.state.clicked.x,
|
|
160
|
+
right: view.state.clicked.x,
|
|
161
|
+
bottom: view.state.clicked.y
|
|
139
162
|
};
|
|
140
|
-
} else {
|
|
141
|
-
return document.querySelector(`[data-id="${viewId}-trigger"]`);
|
|
142
|
-
}
|
|
143
|
-
});
|
|
144
|
-
const mappedStrategy = computed(() => {
|
|
145
|
-
return state.options.floating?.strategy ?? ModeFloatingStrategy[state.options.mode];
|
|
146
|
-
});
|
|
147
|
-
const {
|
|
148
|
-
floatingStyles,
|
|
149
|
-
placement: floatingPlacement,
|
|
150
|
-
middlewareData
|
|
151
|
-
} = useFloating(mappedReferenceEl, elRef, {
|
|
152
|
-
placement: mappedPlacement,
|
|
153
|
-
strategy: mappedStrategy,
|
|
154
|
-
whileElementsMounted: autoUpdate,
|
|
155
|
-
middleware: mappedMiddleware
|
|
156
|
-
});
|
|
157
|
-
const arrowStyles = computed(() => {
|
|
158
|
-
if (!hasArrow.value) {
|
|
159
|
-
return {};
|
|
160
163
|
}
|
|
161
|
-
const translate = `translate3d(${middlewareData.value.arrow?.x ? `${middlewareData.value.arrow.x}px` : "0"}, ${middlewareData.value.arrow?.y ? `${middlewareData.value.arrow.y}px` : "0"}, 0)`;
|
|
162
|
-
return {
|
|
163
|
-
transform: translate
|
|
164
|
-
};
|
|
165
|
-
});
|
|
166
|
-
const placementClasses = computed(() => {
|
|
167
|
-
return floatingPlacement.value.split("-").map((value) => `-${value}`).join(" ");
|
|
168
|
-
});
|
|
169
|
-
const polygonPoints = computed(() => {
|
|
170
|
-
const position = floatingPlacement.value.split("-")[0];
|
|
171
|
-
switch (position) {
|
|
172
|
-
case "bottom":
|
|
173
|
-
return "50,50 100,100 0,100";
|
|
174
|
-
case "top":
|
|
175
|
-
return "50,50 100,0 0,0";
|
|
176
|
-
case "right":
|
|
177
|
-
return "50,50 100,100 100,0";
|
|
178
|
-
case "left":
|
|
179
|
-
return "50,50 0,100 0,0";
|
|
180
|
-
default:
|
|
181
|
-
return void 0;
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
return (_ctx, _cache) => {
|
|
185
|
-
return _openBlock(), _createElementBlock(
|
|
186
|
-
"div",
|
|
187
|
-
{
|
|
188
|
-
ref: "el",
|
|
189
|
-
class: _normalizeClass(["magic-menu-float", placementClasses.value]),
|
|
190
|
-
style: _normalizeStyle(_unref(floatingStyles))
|
|
191
|
-
},
|
|
192
|
-
[
|
|
193
|
-
hasArrow.value ? (_openBlock(), _createElementBlock(
|
|
194
|
-
"div",
|
|
195
|
-
{
|
|
196
|
-
key: 0,
|
|
197
|
-
ref: "arrow",
|
|
198
|
-
class: "magic-menu-float__arrow",
|
|
199
|
-
style: _normalizeStyle(arrowStyles.value)
|
|
200
|
-
},
|
|
201
|
-
[
|
|
202
|
-
_renderSlot(_ctx.$slots, "arrow", {}, () => [
|
|
203
|
-
(_openBlock(), _createElementBlock("svg", _hoisted_1, [
|
|
204
|
-
_createElementVNode("polygon", {
|
|
205
|
-
points: polygonPoints.value,
|
|
206
|
-
fill: "currentColor"
|
|
207
|
-
}, null, 8, _hoisted_2)
|
|
208
|
-
]))
|
|
209
|
-
])
|
|
210
|
-
],
|
|
211
|
-
4
|
|
212
|
-
/* STYLE */
|
|
213
|
-
)) : _createCommentVNode("v-if", true),
|
|
214
|
-
_renderSlot(_ctx.$slots, "default")
|
|
215
|
-
],
|
|
216
|
-
6
|
|
217
|
-
/* CLASS, STYLE */
|
|
218
|
-
);
|
|
219
164
|
};
|
|
165
|
+
} else {
|
|
166
|
+
return document.querySelector(`[data-id="${viewId}-trigger"]`);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
const mappedStrategy = computed(() => {
|
|
170
|
+
return state.options.floating?.strategy ?? ModeFloatingStrategy[state.options.mode];
|
|
171
|
+
});
|
|
172
|
+
const {
|
|
173
|
+
floatingStyles,
|
|
174
|
+
placement: floatingPlacement,
|
|
175
|
+
middlewareData
|
|
176
|
+
} = useFloating(mappedReferenceEl, elRef, {
|
|
177
|
+
placement: mappedPlacement,
|
|
178
|
+
strategy: mappedStrategy,
|
|
179
|
+
whileElementsMounted: autoUpdate,
|
|
180
|
+
middleware: mappedMiddleware
|
|
181
|
+
});
|
|
182
|
+
const arrowStyles = computed(() => {
|
|
183
|
+
if (!hasArrow.value) {
|
|
184
|
+
return {};
|
|
185
|
+
}
|
|
186
|
+
const translate = `translate3d(${middlewareData.value.arrow?.x ? `${middlewareData.value.arrow.x}px` : "0"}, ${middlewareData.value.arrow?.y ? `${middlewareData.value.arrow.y}px` : "0"}, 0)`;
|
|
187
|
+
return {
|
|
188
|
+
transform: translate
|
|
189
|
+
};
|
|
190
|
+
});
|
|
191
|
+
const placementClasses = computed(() => {
|
|
192
|
+
return floatingPlacement.value.split("-").map((value) => `-${value}`).join(" ");
|
|
193
|
+
});
|
|
194
|
+
const polygonPoints = computed(() => {
|
|
195
|
+
const position = floatingPlacement.value.split("-")[0];
|
|
196
|
+
switch (position) {
|
|
197
|
+
case "bottom":
|
|
198
|
+
return "50,50 100,100 0,100";
|
|
199
|
+
case "top":
|
|
200
|
+
return "50,50 100,0 0,0";
|
|
201
|
+
case "right":
|
|
202
|
+
return "50,50 100,100 100,0";
|
|
203
|
+
case "left":
|
|
204
|
+
return "50,50 0,100 0,0";
|
|
205
|
+
default:
|
|
206
|
+
return void 0;
|
|
220
207
|
}
|
|
221
208
|
});
|
|
222
209
|
</script>
|
|
@@ -1,11 +1,22 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="magic-menu-item"
|
|
4
|
+
:data-id="mappedId"
|
|
5
|
+
:data-disabled="disabled"
|
|
6
|
+
:data-active="item.active"
|
|
7
|
+
:data-pointer-disabled="pointerDisabled"
|
|
8
|
+
@mouseenter="guardedSelect"
|
|
9
|
+
@mousemove="guardedSelect"
|
|
10
|
+
@touchstart.passive="guardedSelect"
|
|
11
|
+
@mouseleave="guardedUnselect"
|
|
12
|
+
@click="onClick"
|
|
13
|
+
>
|
|
14
|
+
<slot :item-active="item.active" :item-disabled="disabled" />
|
|
15
|
+
<div v-if="pointerDisabled" class="magic-menu-item__pointer-guard" />
|
|
16
|
+
</div>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script setup>
|
|
9
20
|
import { computed, inject, provide, onBeforeUnmount, watch, useId } from "vue";
|
|
10
21
|
import { useMenuItem } from "../composables/private/useMenuItem";
|
|
11
22
|
import { useMenuState } from "../composables/private/useMenuState";
|
|
@@ -17,100 +28,80 @@ import {
|
|
|
17
28
|
MagicMenuItemId,
|
|
18
29
|
MagicMenuItemActive
|
|
19
30
|
} from "../symbols";
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
disabled: { type: Boolean, required: false }
|
|
31
|
+
const { id, disabled } = defineProps({
|
|
32
|
+
id: {
|
|
33
|
+
type: String,
|
|
34
|
+
required: false
|
|
25
35
|
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
emit("click", event);
|
|
78
|
-
state.input.type = "pointer";
|
|
79
|
-
state.input.disabled = [];
|
|
80
|
-
if (!item.disabled && !item.active) {
|
|
81
|
-
selectItem(mappedId.value);
|
|
82
|
-
}
|
|
83
|
-
if (!nestedView.value) {
|
|
84
|
-
state.active = false;
|
|
85
|
-
unselectAllViews();
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
provide(MagicMenuItemId, mappedId.value);
|
|
89
|
-
provide(MagicMenuItemActive, mappedActive);
|
|
90
|
-
onBeforeUnmount(() => {
|
|
91
|
-
deleteItem(mappedId.value);
|
|
92
|
-
});
|
|
93
|
-
return (_ctx, _cache) => {
|
|
94
|
-
return _openBlock(), _createElementBlock("div", {
|
|
95
|
-
class: "magic-menu-item",
|
|
96
|
-
"data-id": mappedId.value,
|
|
97
|
-
"data-disabled": _ctx.disabled,
|
|
98
|
-
"data-active": _unref(item).active,
|
|
99
|
-
"data-pointer-disabled": pointerDisabled.value,
|
|
100
|
-
onMouseenter: guardedSelect,
|
|
101
|
-
onMousemove: guardedSelect,
|
|
102
|
-
onTouchstartPassive: guardedSelect,
|
|
103
|
-
onMouseleave: guardedUnselect,
|
|
104
|
-
onClick
|
|
105
|
-
}, [
|
|
106
|
-
_renderSlot(_ctx.$slots, "default", {
|
|
107
|
-
itemActive: _unref(item).active,
|
|
108
|
-
itemDisabled: _ctx.disabled
|
|
109
|
-
}),
|
|
110
|
-
pointerDisabled.value ? (_openBlock(), _createElementBlock("div", _hoisted_2)) : _createCommentVNode("v-if", true)
|
|
111
|
-
], 40, _hoisted_1);
|
|
112
|
-
};
|
|
36
|
+
disabled: {
|
|
37
|
+
type: Boolean,
|
|
38
|
+
required: false
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
const emit = defineEmits(["click"]);
|
|
42
|
+
const instanceId = inject(MagicMenuInstanceId, void 0);
|
|
43
|
+
const viewId = inject(MagicMenuViewId, void 0);
|
|
44
|
+
const contentId = inject(MagicMenuContentId, void 0);
|
|
45
|
+
if (!instanceId) {
|
|
46
|
+
throw new Error("MagicMenuItem must be nested inside MagicMenuProvider");
|
|
47
|
+
}
|
|
48
|
+
if (!viewId) {
|
|
49
|
+
throw new Error("MagicMenuItem must be nested inside MagicMenuView");
|
|
50
|
+
}
|
|
51
|
+
if (!contentId) {
|
|
52
|
+
throw new Error("MagicMenuItem must be nested inside MagicMenuContent");
|
|
53
|
+
}
|
|
54
|
+
const mappedId = computed(() => id ?? `magic-menu-item-${useId()}`);
|
|
55
|
+
const mappedActive = computed(() => item.active);
|
|
56
|
+
const { initializeItem, deleteItem, selectItem, unselectItem } = useMenuItem({
|
|
57
|
+
instanceId,
|
|
58
|
+
viewId
|
|
59
|
+
});
|
|
60
|
+
const { initializeState } = useMenuState(instanceId);
|
|
61
|
+
const state = initializeState();
|
|
62
|
+
const item = initializeItem({
|
|
63
|
+
id: mappedId.value,
|
|
64
|
+
disabled: disabled ?? false
|
|
65
|
+
});
|
|
66
|
+
const pointerDisabled = computed(() => state.input.disabled.includes("pointer"));
|
|
67
|
+
function guardedSelect() {
|
|
68
|
+
if (state.input.type === "pointer" && !state.input.disabled.includes("pointer") && !item.active && !item.disabled) {
|
|
69
|
+
selectItem(mappedId.value);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
const { getNestedView, unselectAllViews } = useMenuView(instanceId);
|
|
73
|
+
const nestedView = computed(() => getNestedView(mappedId.value));
|
|
74
|
+
function guardedUnselect() {
|
|
75
|
+
if (!nestedView.value || !nestedView.value.active) {
|
|
76
|
+
unselectItem(mappedId.value);
|
|
77
|
+
} else {
|
|
78
|
+
watch(
|
|
79
|
+
() => nestedView.value?.active,
|
|
80
|
+
(value) => {
|
|
81
|
+
if (!value) {
|
|
82
|
+
unselectItem(mappedId.value);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
{ once: true }
|
|
86
|
+
);
|
|
113
87
|
}
|
|
88
|
+
}
|
|
89
|
+
function onClick(event) {
|
|
90
|
+
emit("click", event);
|
|
91
|
+
state.input.type = "pointer";
|
|
92
|
+
state.input.disabled = [];
|
|
93
|
+
if (!item.disabled && !item.active) {
|
|
94
|
+
selectItem(mappedId.value);
|
|
95
|
+
}
|
|
96
|
+
if (!nestedView.value) {
|
|
97
|
+
state.active = false;
|
|
98
|
+
unselectAllViews();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
provide(MagicMenuItemId, mappedId.value);
|
|
102
|
+
provide(MagicMenuItemActive, mappedActive);
|
|
103
|
+
onBeforeUnmount(() => {
|
|
104
|
+
deleteItem(mappedId.value);
|
|
114
105
|
});
|
|
115
106
|
</script>
|
|
116
107
|
|
|
@@ -3,7 +3,7 @@ interface MagicMenuItemProps {
|
|
|
3
3
|
disabled?: boolean;
|
|
4
4
|
}
|
|
5
5
|
declare const mappedId: import("vue").ComputedRef<string>;
|
|
6
|
-
declare const item: import("../types").MenuItem;
|
|
6
|
+
declare const item: import("../types/index.js").MenuItem;
|
|
7
7
|
declare const pointerDisabled: import("vue").ComputedRef<boolean>;
|
|
8
8
|
declare function guardedSelect(): void;
|
|
9
9
|
declare function guardedUnselect(): void;
|