@maas/vue-equipment 1.0.0-beta.76 → 1.0.0-beta.78
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/nuxt/module.mjs +3 -3
- package/dist/plugins/MagicDrawer/index.d.ts +2 -2
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDrag.mjs +23 -0
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerGuards.d.ts +2 -2
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerSnap.d.ts +4 -4
- package/dist/plugins/MagicDrawer/src/composables/useMagicDrawer.d.ts +2 -2
- package/dist/plugins/MagicDrawer/src/types/index.d.ts +11 -6
- package/dist/plugins/MagicEmitter/src/composables/useMagicEmitter.d.ts +268 -226
- package/dist/plugins/MagicMenu/src/composables/private/useMenuCursor.d.ts +1 -7
- package/dist/plugins/MagicMenu/src/composables/private/useMenuCursor.mjs +2 -2
- package/dist/plugins/MagicScroll/src/components/MagicScrollMotion.vue +2 -2
- package/dist/plugins/MagicToast/index.d.ts +2 -2
- package/dist/plugins/MagicToast/src/components/MagicToastProvider.vue +1 -1
- package/dist/plugins/MagicToast/src/components/MagicToastView.vue +5 -5
- package/dist/plugins/MagicToast/src/composables/private/useToastCallback.mjs +2 -2
- package/dist/plugins/MagicToast/src/composables/private/useToastDrag.d.ts +1 -0
- package/dist/plugins/MagicToast/src/composables/private/useToastDrag.mjs +58 -28
- package/dist/plugins/MagicToast/src/composables/private/useToastListener.mjs +2 -2
- package/dist/plugins/MagicToast/src/composables/private/useToastState.mjs +1 -1
- package/dist/plugins/MagicToast/src/composables/private/useToastView.d.ts +1 -1
- package/dist/plugins/MagicToast/src/composables/private/useToastView.mjs +6 -4
- package/dist/plugins/MagicToast/src/composables/useMagicToast.d.ts +5 -2
- package/dist/plugins/MagicToast/src/composables/useMagicToast.mjs +45 -5
- package/dist/plugins/MagicToast/src/types/index.d.ts +20 -2
- package/dist/plugins/MagicToast/src/utils/defaultOptions.mjs +4 -1
- package/dist/plugins/MagicTray/index.d.ts +2 -2
- package/dist/plugins/MagicTray/src/components/MagicTray.d.vue.ts +1 -1
- package/dist/plugins/MagicTray/src/components/MagicTray.vue.d.ts +1 -1
- package/dist/plugins/MagicTray/src/components/MagicTrayContent.d.vue.ts +4 -4
- package/dist/plugins/MagicTray/src/components/MagicTrayContent.vue +3 -1
- package/dist/plugins/MagicTray/src/components/MagicTrayContent.vue.d.ts +4 -4
- package/dist/plugins/MagicTray/src/components/MagicTrayHandle.d.vue.ts +3 -3
- package/dist/plugins/MagicTray/src/components/MagicTrayHandle.vue.d.ts +3 -3
- package/dist/plugins/MagicTray/src/components/MagicTrayTransform.d.vue.ts +2 -2
- package/dist/plugins/MagicTray/src/components/MagicTrayTransform.vue.d.ts +2 -2
- package/dist/plugins/MagicTray/src/composables/private/useTrayDrag.d.ts +7 -6
- package/dist/plugins/MagicTray/src/composables/private/useTrayDrag.mjs +23 -27
- package/dist/plugins/MagicTray/src/composables/private/useTrayMagnetism.d.ts +2 -2
- package/dist/plugins/MagicTray/src/composables/private/useTraySnap.d.ts +12 -12
- package/dist/plugins/MagicTray/src/composables/private/useTrayUtils.d.ts +3 -3
- package/dist/plugins/MagicTray/src/composables/useMagicTray.d.ts +3 -3
- package/dist/plugins/MagicTray/src/types/index.d.ts +35 -34
- package/dist/plugins/MagicTray/src/utils/defaultOptions.mjs +4 -2
- package/package.json +1 -1
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
import type { Coordinates, MenuView } from '../../types/index.js';
|
|
2
2
|
export declare function useMenuCursor(view: MenuView, debug?: boolean): {
|
|
3
|
-
coords: import("vue").
|
|
4
|
-
x: number;
|
|
5
|
-
y: number;
|
|
6
|
-
}[], Coordinates[] | {
|
|
7
|
-
x: number;
|
|
8
|
-
y: number;
|
|
9
|
-
}[]>;
|
|
3
|
+
coords: import("vue").ShallowRef<Coordinates[], Coordinates[]>;
|
|
10
4
|
isInsideFrom: import("vue").ShallowRef<boolean, boolean>;
|
|
11
5
|
isInsideTo: import("vue").ShallowRef<boolean, boolean>;
|
|
12
6
|
isInsideTriangle: import("vue").ShallowRef<boolean, boolean>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { onScopeDispose,
|
|
1
|
+
import { onScopeDispose, shallowRef } from "vue";
|
|
2
2
|
import { useEventListener } from "@vueuse/core";
|
|
3
3
|
export function useMenuCursor(view, debug = false) {
|
|
4
4
|
let cancelListener = new AbortController();
|
|
5
|
-
const coords =
|
|
5
|
+
const coords = shallowRef([
|
|
6
6
|
{ x: 0, y: 0 },
|
|
7
7
|
{ x: 0, y: 0 },
|
|
8
8
|
{ x: 0, y: 0 }
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
<script setup>
|
|
8
8
|
import {
|
|
9
|
-
|
|
9
|
+
shallowRef,
|
|
10
10
|
inject,
|
|
11
11
|
computed,
|
|
12
12
|
onMounted,
|
|
@@ -26,7 +26,7 @@ const { progress, sequence, sequenceOptions } = defineProps({
|
|
|
26
26
|
sequenceOptions: { type: Object, required: false },
|
|
27
27
|
progress: { type: Number, required: false }
|
|
28
28
|
});
|
|
29
|
-
const animation =
|
|
29
|
+
const animation = shallowRef(void 0);
|
|
30
30
|
const elRef = useTemplateRef("el");
|
|
31
31
|
const injectedProgress = inject(
|
|
32
32
|
MagicScrollProgress,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMagicToast } from './src/composables/useMagicToast.js';
|
|
2
2
|
import type { Plugin } from 'vue';
|
|
3
|
-
import type { MagicToastOptions } from './src/types/index.js';
|
|
3
|
+
import type { MagicToastOptions, MagicToastAddOptions, MagicToastDragPayload } from './src/types/index.js';
|
|
4
4
|
declare const MagicToastPlugin: Plugin;
|
|
5
5
|
export { MagicToastPlugin, useMagicToast };
|
|
6
|
-
export type { MagicToastOptions };
|
|
6
|
+
export type { MagicToastOptions, MagicToastAddOptions, MagicToastDragPayload };
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
:data-id="id"
|
|
5
5
|
:data-expanded="state.expanded"
|
|
6
6
|
:data-dragging="view?.dragging"
|
|
7
|
-
:data-draggable="
|
|
7
|
+
:data-draggable="draggable"
|
|
8
8
|
:data-position="state.options.position"
|
|
9
9
|
:data-debug="state.options.debug"
|
|
10
10
|
:style="{
|
|
@@ -48,8 +48,8 @@ magicError.assert(instanceId, {
|
|
|
48
48
|
});
|
|
49
49
|
const { initializeState } = useToastState(instanceId);
|
|
50
50
|
const state = initializeState();
|
|
51
|
-
const count = computed(() => state.views.length);
|
|
52
|
-
const view = computed(() => state.views[index]);
|
|
51
|
+
const count = computed(() => state.views.visible.length);
|
|
52
|
+
const view = computed(() => state.views.visible[index]);
|
|
53
53
|
const reversedIndex = computed(() => count.value - index - 1);
|
|
54
54
|
magicError.assert(view.value, {
|
|
55
55
|
message: "MagicToastView could not be registered",
|
|
@@ -57,10 +57,10 @@ magicError.assert(view.value, {
|
|
|
57
57
|
});
|
|
58
58
|
const height = computed(() => `${view.value?.dimensions?.height}px`);
|
|
59
59
|
const offset = computed(() => {
|
|
60
|
-
const mapped = state.views.slice(index + 1).reduce((acc, view2) => acc + (view2.dimensions?.height ?? 0), 0);
|
|
60
|
+
const mapped = state.views.visible.slice(index + 1).reduce((acc, view2) => acc + (view2.dimensions?.height ?? 0), 0);
|
|
61
61
|
return `${mapped}px`;
|
|
62
62
|
});
|
|
63
|
-
const { style, onPointerdown, onClick } = useToastDrag({
|
|
63
|
+
const { style, onPointerdown, onClick, draggable } = useToastDrag({
|
|
64
64
|
view: view.value,
|
|
65
65
|
instanceId
|
|
66
66
|
});
|
|
@@ -27,8 +27,8 @@ export function useToastCallback(instanceId) {
|
|
|
27
27
|
view.dimensions = dimensions;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
if (state.views.length && state.views[0] && state.options.layout?.max && state.views.length > state.options.layout.max) {
|
|
31
|
-
deleteView(state.views[0].id);
|
|
30
|
+
if (state.views.visible.length && state.views.visible[0] && state.options.layout?.max && state.views.visible.length > state.options.layout.max) {
|
|
31
|
+
deleteView(state.views.visible[0].id);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
function onAfterEnter() {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { computed, onScopeDispose, toRefs, toValue } from "vue";
|
|
2
|
+
import { defu } from "defu";
|
|
2
3
|
import { useEventListener } from "@vueuse/core";
|
|
3
4
|
import {
|
|
4
5
|
guardedReleasePointerCapture,
|
|
@@ -15,8 +16,22 @@ export function useToastDrag(args) {
|
|
|
15
16
|
const { instanceId, view } = args;
|
|
16
17
|
const { initializeState } = useToastState(instanceId);
|
|
17
18
|
const state = initializeState();
|
|
18
|
-
const {
|
|
19
|
-
|
|
19
|
+
const {
|
|
20
|
+
threshold,
|
|
21
|
+
animation,
|
|
22
|
+
position: anchorPosition,
|
|
23
|
+
scrollLock,
|
|
24
|
+
drag
|
|
25
|
+
} = defu(view.options ?? {}, state.options);
|
|
26
|
+
const isDraggable = computed(() => !drag.disabled);
|
|
27
|
+
const directions = drag.direction === "auto" ? [] : [].concat(drag.direction);
|
|
28
|
+
const allowLeft = directions.includes("left");
|
|
29
|
+
const allowRight = directions.includes("right");
|
|
30
|
+
const allowUp = directions.includes("up");
|
|
31
|
+
const allowDown = directions.includes("down");
|
|
32
|
+
const isHorizontalOverride = allowLeft || allowRight;
|
|
33
|
+
const isVerticalOverride = allowUp || allowDown;
|
|
34
|
+
const position = isHorizontalOverride ? "left" : isVerticalOverride ? "top" : anchorPosition;
|
|
20
35
|
const { deleteView } = useToastView(instanceId);
|
|
21
36
|
const {
|
|
22
37
|
dragStart,
|
|
@@ -146,38 +161,52 @@ export function useToastDrag(args) {
|
|
|
146
161
|
}
|
|
147
162
|
}
|
|
148
163
|
function setDragged({ x, y }) {
|
|
149
|
-
|
|
164
|
+
if (isHorizontalOverride) {
|
|
165
|
+
const raw = x - originX.value;
|
|
166
|
+
switch (true) {
|
|
167
|
+
case (allowLeft && allowRight):
|
|
168
|
+
draggedX.value = raw;
|
|
169
|
+
break;
|
|
170
|
+
case allowLeft:
|
|
171
|
+
draggedX.value = Math.min(raw, 0);
|
|
172
|
+
break;
|
|
173
|
+
default:
|
|
174
|
+
draggedX.value = Math.max(raw, 0);
|
|
175
|
+
break;
|
|
176
|
+
}
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
if (isVerticalOverride) {
|
|
180
|
+
const raw = y - originY.value;
|
|
181
|
+
switch (true) {
|
|
182
|
+
case (allowUp && allowDown):
|
|
183
|
+
draggedY.value = raw;
|
|
184
|
+
break;
|
|
185
|
+
case allowUp:
|
|
186
|
+
draggedY.value = Math.min(raw, 0);
|
|
187
|
+
break;
|
|
188
|
+
default:
|
|
189
|
+
draggedY.value = Math.max(raw, 0);
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
switch (anchorPosition) {
|
|
150
195
|
case "top":
|
|
151
|
-
const newDraggedTC = Math.min(y - originY.value, 0);
|
|
152
|
-
draggedY.value = newDraggedTC;
|
|
153
|
-
break;
|
|
154
196
|
case "top-left":
|
|
155
|
-
const newDraggedTL = Math.min(y - originY.value, 0);
|
|
156
|
-
draggedY.value = newDraggedTL;
|
|
157
|
-
break;
|
|
158
197
|
case "top-right":
|
|
159
|
-
|
|
160
|
-
draggedY.value = newDraggedTR;
|
|
198
|
+
draggedY.value = Math.min(y - originY.value, 0);
|
|
161
199
|
break;
|
|
162
200
|
case "bottom":
|
|
163
|
-
const newDraggedBC = Math.max(y - originY.value, 0);
|
|
164
|
-
draggedY.value = newDraggedBC;
|
|
165
|
-
break;
|
|
166
201
|
case "bottom-left":
|
|
167
|
-
const newDraggedBL = Math.max(y - originY.value, 0);
|
|
168
|
-
draggedY.value = newDraggedBL;
|
|
169
|
-
break;
|
|
170
202
|
case "bottom-right":
|
|
171
|
-
|
|
172
|
-
draggedY.value = newDraggedBR;
|
|
203
|
+
draggedY.value = Math.max(y - originY.value, 0);
|
|
173
204
|
break;
|
|
174
205
|
case "left":
|
|
175
|
-
|
|
176
|
-
draggedX.value = newDraggedCL;
|
|
206
|
+
draggedX.value = Math.min(x - originX.value, 0);
|
|
177
207
|
break;
|
|
178
208
|
case "right":
|
|
179
|
-
|
|
180
|
-
draggedX.value = newDraggedCR;
|
|
209
|
+
draggedX.value = Math.max(x - originX.value, 0);
|
|
181
210
|
break;
|
|
182
211
|
}
|
|
183
212
|
}
|
|
@@ -230,7 +259,7 @@ export function useToastDrag(args) {
|
|
|
230
259
|
);
|
|
231
260
|
}
|
|
232
261
|
if (state.options.layout?.expand !== "hover" && state.expanded) {
|
|
233
|
-
state.views.forEach((view2) => {
|
|
262
|
+
state.views.visible.forEach((view2) => {
|
|
234
263
|
view2.timeout?.play();
|
|
235
264
|
});
|
|
236
265
|
}
|
|
@@ -262,7 +291,7 @@ export function useToastDrag(args) {
|
|
|
262
291
|
cancelTouchcancel?.();
|
|
263
292
|
}
|
|
264
293
|
function onPointerdown(e) {
|
|
265
|
-
if (!
|
|
294
|
+
if (!isDraggable.value) {
|
|
266
295
|
return;
|
|
267
296
|
}
|
|
268
297
|
const scrollLockValue = toValue(scrollLock);
|
|
@@ -273,7 +302,7 @@ export function useToastDrag(args) {
|
|
|
273
302
|
return;
|
|
274
303
|
} else {
|
|
275
304
|
dragging.value = true;
|
|
276
|
-
state.views.forEach((view2) => {
|
|
305
|
+
state.views.visible.forEach((view2) => {
|
|
277
306
|
view2.timeout?.pause();
|
|
278
307
|
});
|
|
279
308
|
pointerdownTarget = e.target;
|
|
@@ -308,7 +337,7 @@ export function useToastDrag(args) {
|
|
|
308
337
|
e.preventDefault();
|
|
309
338
|
return;
|
|
310
339
|
}
|
|
311
|
-
if (
|
|
340
|
+
if (anchorPosition === "left" || anchorPosition === "right") {
|
|
312
341
|
return;
|
|
313
342
|
}
|
|
314
343
|
if (state.options.layout?.expand === "click") {
|
|
@@ -321,6 +350,7 @@ export function useToastDrag(args) {
|
|
|
321
350
|
return {
|
|
322
351
|
onPointerdown,
|
|
323
352
|
onClick,
|
|
324
|
-
style
|
|
353
|
+
style,
|
|
354
|
+
draggable: isDraggable
|
|
325
355
|
};
|
|
326
356
|
}
|
|
@@ -6,7 +6,7 @@ export function useToastListener(instanceId) {
|
|
|
6
6
|
function onMouseenter() {
|
|
7
7
|
if (state.options.layout?.expand === "hover") {
|
|
8
8
|
state.expanded = true;
|
|
9
|
-
state.views.forEach((view) => {
|
|
9
|
+
state.views.visible.forEach((view) => {
|
|
10
10
|
view.timeout?.pause();
|
|
11
11
|
});
|
|
12
12
|
}
|
|
@@ -14,7 +14,7 @@ export function useToastListener(instanceId) {
|
|
|
14
14
|
function onMouseleave() {
|
|
15
15
|
if (state.options.layout?.expand === "hover") {
|
|
16
16
|
state.expanded = false;
|
|
17
|
-
state.views.forEach((view) => {
|
|
17
|
+
state.views.visible.forEach((view) => {
|
|
18
18
|
view.timeout?.play();
|
|
19
19
|
});
|
|
20
20
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type MaybeRef } from 'vue';
|
|
2
2
|
import { type ToastView } from '../../types/index.js';
|
|
3
|
-
export type AddViewArgs = Pick<ToastView, 'component' | 'props' | 'slots'> & {
|
|
3
|
+
export type AddViewArgs = Pick<ToastView, 'component' | 'props' | 'slots' | 'options'> & {
|
|
4
4
|
id?: string;
|
|
5
5
|
};
|
|
6
6
|
type InitializeViewArgs = AddViewArgs;
|
|
@@ -8,11 +8,12 @@ export function useToastView(instanceId) {
|
|
|
8
8
|
return Math.random().toString(36).slice(2, 11);
|
|
9
9
|
}
|
|
10
10
|
function createView(args) {
|
|
11
|
-
const { id = uuid(), props, slots, component } = args;
|
|
11
|
+
const { id = uuid(), props, slots, component, options } = args;
|
|
12
12
|
const view = {
|
|
13
13
|
component: markRaw(component),
|
|
14
14
|
props,
|
|
15
15
|
slots,
|
|
16
|
+
options,
|
|
16
17
|
id,
|
|
17
18
|
dragStart: void 0,
|
|
18
19
|
dragging: false,
|
|
@@ -32,7 +33,7 @@ export function useToastView(instanceId) {
|
|
|
32
33
|
}
|
|
33
34
|
function addView(args) {
|
|
34
35
|
const view = createView(args);
|
|
35
|
-
state.views = [...state.views, view];
|
|
36
|
+
state.views.visible = [...state.views.visible, view];
|
|
36
37
|
return view;
|
|
37
38
|
}
|
|
38
39
|
function initializeView(args) {
|
|
@@ -41,10 +42,11 @@ export function useToastView(instanceId) {
|
|
|
41
42
|
return view;
|
|
42
43
|
}
|
|
43
44
|
function deleteView(id) {
|
|
44
|
-
state.views = state.views?.filter((view) => view.id !== id);
|
|
45
|
+
state.views.visible = state.views.visible?.filter((view) => view.id !== id);
|
|
46
|
+
state.views.hidden = state.views.hidden?.filter((view) => view.id !== id);
|
|
45
47
|
}
|
|
46
48
|
function getView(id) {
|
|
47
|
-
return state.views?.find((view) => view.id === id);
|
|
49
|
+
return state.views.visible?.find((view) => view.id === id);
|
|
48
50
|
}
|
|
49
51
|
return {
|
|
50
52
|
initializeView,
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
import { type MaybeRef } from 'vue';
|
|
2
|
-
import type { ToastView } from '../types/index.js';
|
|
2
|
+
import type { ToastView, MagicToastAddOptions } from '../types/index.js';
|
|
3
3
|
export interface AddArgs {
|
|
4
4
|
component: ToastView['component'];
|
|
5
5
|
props?: ToastView['props'];
|
|
6
6
|
slots?: ToastView['slots'];
|
|
7
|
-
|
|
7
|
+
options?: MagicToastAddOptions;
|
|
8
8
|
id?: string;
|
|
9
9
|
}
|
|
10
10
|
export declare function useMagicToast(id: MaybeRef<string>): {
|
|
11
11
|
toasts: import("vue").ComputedRef<ToastView[]>;
|
|
12
12
|
count: import("vue").ComputedRef<number>;
|
|
13
|
+
hidden: import("vue").ComputedRef<number>;
|
|
13
14
|
add: (args: AddArgs) => string;
|
|
14
15
|
remove: (id: string) => void;
|
|
15
16
|
clear: (transition?: string) => Promise<void>;
|
|
17
|
+
hide: (transition?: string) => Promise<void>;
|
|
18
|
+
show: (transition?: string) => Promise<void>;
|
|
16
19
|
expand: () => void;
|
|
17
20
|
collapse: () => void;
|
|
18
21
|
};
|
|
@@ -6,12 +6,20 @@ export function useMagicToast(id) {
|
|
|
6
6
|
const { initializeState } = useToastState(toValue(id));
|
|
7
7
|
const state = initializeState();
|
|
8
8
|
const { initializeView, deleteView } = useToastView(id);
|
|
9
|
-
const toasts = computed(() => state.views);
|
|
9
|
+
const toasts = computed(() => state.views.visible);
|
|
10
10
|
const count = computed(() => toasts.value?.length);
|
|
11
|
+
const hidden = computed(() => state.views.hidden?.length);
|
|
11
12
|
function add(args) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
if (state.views.hidden.length > 0) {
|
|
14
|
+
state.views.visible = state.views.hidden;
|
|
15
|
+
state.views.hidden = [];
|
|
16
|
+
state.views.visible.forEach((view2) => {
|
|
17
|
+
view2.timeout?.play();
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
const { id: id2, component, props, slots, options } = args;
|
|
21
|
+
const view = initializeView({ id: id2, component, props, slots, options });
|
|
22
|
+
const mappedDuration = options?.duration ?? state.options.duration;
|
|
15
23
|
if (mappedDuration > 0) {
|
|
16
24
|
view.timeout = useToastTimeout(() => deleteView(view.id), {
|
|
17
25
|
delay: mappedDuration,
|
|
@@ -26,8 +34,37 @@ export function useMagicToast(id) {
|
|
|
26
34
|
async function clear(transition) {
|
|
27
35
|
const lastTransition = state.options.transition;
|
|
28
36
|
state.options.transition = transition ?? "";
|
|
29
|
-
state.views = [];
|
|
37
|
+
state.views.visible = [];
|
|
38
|
+
state.views.hidden = [];
|
|
39
|
+
await nextTick();
|
|
40
|
+
state.options.transition = lastTransition;
|
|
41
|
+
}
|
|
42
|
+
async function hide(transition) {
|
|
43
|
+
if (state.views.visible.length === 0) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
const lastTransition = state.options.transition;
|
|
47
|
+
state.options.transition = transition ?? "";
|
|
48
|
+
state.views.visible.forEach((view) => {
|
|
49
|
+
view.timeout?.pause();
|
|
50
|
+
});
|
|
51
|
+
state.views.hidden = state.views.visible;
|
|
52
|
+
state.views.visible = [];
|
|
53
|
+
await nextTick();
|
|
54
|
+
state.options.transition = lastTransition;
|
|
55
|
+
}
|
|
56
|
+
async function show(transition) {
|
|
57
|
+
if (state.views.hidden.length === 0) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const lastTransition = state.options.transition;
|
|
61
|
+
state.options.transition = transition ?? "";
|
|
62
|
+
state.views.visible = state.views.hidden;
|
|
63
|
+
state.views.hidden = [];
|
|
30
64
|
await nextTick();
|
|
65
|
+
state.views.visible.forEach((view) => {
|
|
66
|
+
view.timeout?.play();
|
|
67
|
+
});
|
|
31
68
|
state.options.transition = lastTransition;
|
|
32
69
|
}
|
|
33
70
|
function expand() {
|
|
@@ -39,9 +76,12 @@ export function useMagicToast(id) {
|
|
|
39
76
|
return {
|
|
40
77
|
toasts,
|
|
41
78
|
count,
|
|
79
|
+
hidden,
|
|
42
80
|
add,
|
|
43
81
|
remove,
|
|
44
82
|
clear,
|
|
83
|
+
hide,
|
|
84
|
+
show,
|
|
45
85
|
expand,
|
|
46
86
|
collapse
|
|
47
87
|
};
|
|
@@ -2,11 +2,13 @@ import type { MaybeRef, Slots } from 'vue';
|
|
|
2
2
|
import type { RequireAllNested } from '@maas/vue-equipment/utils';
|
|
3
3
|
import type { UseToastTimeout } from '../composables/private/useToastTimeout.js';
|
|
4
4
|
type Position = 'top-left' | 'top' | 'top-right' | 'left' | 'right' | 'bottom-left' | 'bottom' | 'bottom-right';
|
|
5
|
+
export type DragDirection = 'left' | 'right' | 'up' | 'down';
|
|
5
6
|
export interface ToastView {
|
|
6
7
|
id: string;
|
|
7
8
|
component: object;
|
|
8
9
|
props?: MaybeRef<Record<string, unknown>>;
|
|
9
10
|
slots?: Slots;
|
|
11
|
+
options?: MagicToastAddOptions;
|
|
10
12
|
dimensions?: {
|
|
11
13
|
height: number;
|
|
12
14
|
padding: {
|
|
@@ -28,10 +30,14 @@ export interface ToastView {
|
|
|
28
30
|
draggedY: number;
|
|
29
31
|
timeout: UseToastTimeout | undefined;
|
|
30
32
|
}
|
|
33
|
+
export interface ToastViews {
|
|
34
|
+
visible: ToastView[];
|
|
35
|
+
hidden: ToastView[];
|
|
36
|
+
}
|
|
31
37
|
export interface ToastState {
|
|
32
38
|
id: string;
|
|
33
39
|
refCount: number;
|
|
34
|
-
views:
|
|
40
|
+
views: ToastViews;
|
|
35
41
|
expanded: boolean;
|
|
36
42
|
animating: boolean;
|
|
37
43
|
options: RequiredMagicToastOptions;
|
|
@@ -44,6 +50,11 @@ export interface ActiveToast {
|
|
|
44
50
|
bottom: number;
|
|
45
51
|
};
|
|
46
52
|
}
|
|
53
|
+
export interface MagicToastDragPayload {
|
|
54
|
+
id: string;
|
|
55
|
+
x: number;
|
|
56
|
+
y: number;
|
|
57
|
+
}
|
|
47
58
|
export interface ToastEvents {
|
|
48
59
|
beforeEnter: string;
|
|
49
60
|
enter: string;
|
|
@@ -51,12 +62,18 @@ export interface ToastEvents {
|
|
|
51
62
|
beforeLeave: string;
|
|
52
63
|
leave: string;
|
|
53
64
|
afterLeave: string;
|
|
65
|
+
beforeDrag: MagicToastDragPayload;
|
|
66
|
+
drag: MagicToastDragPayload;
|
|
67
|
+
afterDrag: MagicToastDragPayload;
|
|
54
68
|
}
|
|
55
69
|
export interface MagicToastOptions {
|
|
56
70
|
debug?: boolean;
|
|
57
71
|
position?: Position;
|
|
58
72
|
duration?: number;
|
|
59
|
-
|
|
73
|
+
drag?: {
|
|
74
|
+
disabled?: boolean;
|
|
75
|
+
direction?: 'auto' | DragDirection | DragDirection[];
|
|
76
|
+
};
|
|
60
77
|
scrollLock?: boolean | {
|
|
61
78
|
padding: boolean;
|
|
62
79
|
};
|
|
@@ -84,5 +101,6 @@ export interface MagicToastOptions {
|
|
|
84
101
|
momentum?: number;
|
|
85
102
|
};
|
|
86
103
|
}
|
|
104
|
+
export type MagicToastAddOptions = Pick<MagicToastOptions, 'duration' | 'drag' | 'threshold' | 'animation'>;
|
|
87
105
|
export type RequiredMagicToastOptions = RequireAllNested<MagicToastOptions>;
|
|
88
106
|
export {};
|
|
@@ -5,7 +5,7 @@ import MagicTrayHandle from './src/components/MagicTrayHandle.vue.js';
|
|
|
5
5
|
import MagicTrayTransform from './src/components/MagicTrayTransform.vue.js';
|
|
6
6
|
import { useMagicTray } from './src/composables/useMagicTray.js';
|
|
7
7
|
import type { Plugin } from 'vue';
|
|
8
|
-
import type { MagicTrayOptions,
|
|
8
|
+
import type { MagicTrayOptions, MagicTraySide, MagicTraySidePayload, MagicTraySnapMode, MagicTrayDragMode, MagicTraySnapPoint, MagicTraySnapPointPayload, MagicTrayTransformAxis, MagicTrayWillSnapToPayload } from './src/types/index.js';
|
|
9
9
|
declare const MagicTrayPlugin: Plugin;
|
|
10
10
|
export { MagicTrayPlugin, MagicTray, MagicTrayProvider, MagicTrayContent, MagicTrayHandle, MagicTrayTransform, useMagicTray, };
|
|
11
|
-
export type { MagicTrayOptions,
|
|
11
|
+
export type { MagicTrayOptions, MagicTraySide, MagicTraySidePayload, MagicTraySnapMode, MagicTrayDragMode, MagicTraySnapPoint, MagicTraySnapPointPayload, MagicTrayWillSnapToPayload, MagicTrayTransformAxis, };
|
|
@@ -5,7 +5,7 @@ interface MagicTrayProps {
|
|
|
5
5
|
options?: MagicTrayOptions;
|
|
6
6
|
}
|
|
7
7
|
declare var __VLS_11: {}, __VLS_13: {}, __VLS_16: {
|
|
8
|
-
side: import("../types/index.js").
|
|
8
|
+
side: import("../types/index.js").MagicTraySide;
|
|
9
9
|
};
|
|
10
10
|
type __VLS_Slots = {} & {
|
|
11
11
|
background?: (props: typeof __VLS_11) => any;
|
|
@@ -5,7 +5,7 @@ interface MagicTrayProps {
|
|
|
5
5
|
options?: MagicTrayOptions;
|
|
6
6
|
}
|
|
7
7
|
declare var __VLS_11: {}, __VLS_13: {}, __VLS_16: {
|
|
8
|
-
side: import("../types/index.js").
|
|
8
|
+
side: import("../types/index.js").MagicTraySide;
|
|
9
9
|
};
|
|
10
10
|
type __VLS_Slots = {} & {
|
|
11
11
|
background?: (props: typeof __VLS_11) => any;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
declare var __VLS_8: {}, __VLS_10: {},
|
|
3
|
-
side:
|
|
1
|
+
import type { MagicTraySide } from '../types/index.js';
|
|
2
|
+
declare var __VLS_8: {}, __VLS_10: {}, __VLS_23: "handle-right" | "handle-top" | "handle-bottom" | "handle-left" | "handle", __VLS_24: {
|
|
3
|
+
side: MagicTraySide;
|
|
4
4
|
};
|
|
5
5
|
type __VLS_Slots = {} & {
|
|
6
|
-
[K in NonNullable<typeof
|
|
6
|
+
[K in NonNullable<typeof __VLS_23>]?: (props: typeof __VLS_24) => any;
|
|
7
7
|
} & {
|
|
8
8
|
background?: (props: typeof __VLS_8) => any;
|
|
9
9
|
} & {
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
:style="handleStyle(side)"
|
|
41
41
|
@pointerdown="guardedPointerdown(side, $event)"
|
|
42
42
|
@touchstart="guardedTouchstart(side, $event)"
|
|
43
|
+
@click.capture="onHandleClick"
|
|
43
44
|
>
|
|
44
45
|
<template
|
|
45
46
|
v-if="slots[`handle-${side}`] || slots.handle"
|
|
@@ -106,7 +107,8 @@ const {
|
|
|
106
107
|
handleStyle,
|
|
107
108
|
hasDragged,
|
|
108
109
|
onHandlePointerdown,
|
|
109
|
-
onHandleTouchstart
|
|
110
|
+
onHandleTouchstart,
|
|
111
|
+
onHandleClick
|
|
110
112
|
} = useTrayDrag({
|
|
111
113
|
id: instanceId,
|
|
112
114
|
elRef
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
declare var __VLS_8: {}, __VLS_10: {},
|
|
3
|
-
side:
|
|
1
|
+
import type { MagicTraySide } from '../types/index.js';
|
|
2
|
+
declare var __VLS_8: {}, __VLS_10: {}, __VLS_23: "handle-right" | "handle-top" | "handle-bottom" | "handle-left" | "handle", __VLS_24: {
|
|
3
|
+
side: MagicTraySide;
|
|
4
4
|
};
|
|
5
5
|
type __VLS_Slots = {} & {
|
|
6
|
-
[K in NonNullable<typeof
|
|
6
|
+
[K in NonNullable<typeof __VLS_23>]?: (props: typeof __VLS_24) => any;
|
|
7
7
|
} & {
|
|
8
8
|
background?: (props: typeof __VLS_8) => any;
|
|
9
9
|
} & {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MagicTraySide } from '../types/index.js';
|
|
2
2
|
interface MagicTrayHandleProps {
|
|
3
|
-
side:
|
|
3
|
+
side: MagicTraySide;
|
|
4
4
|
}
|
|
5
5
|
declare var __VLS_1: {
|
|
6
|
-
side:
|
|
6
|
+
side: MagicTraySide;
|
|
7
7
|
};
|
|
8
8
|
type __VLS_Slots = {} & {
|
|
9
9
|
default?: (props: typeof __VLS_1) => any;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MagicTraySide } from '../types/index.js';
|
|
2
2
|
interface MagicTrayHandleProps {
|
|
3
|
-
side:
|
|
3
|
+
side: MagicTraySide;
|
|
4
4
|
}
|
|
5
5
|
declare var __VLS_1: {
|
|
6
|
-
side:
|
|
6
|
+
side: MagicTraySide;
|
|
7
7
|
};
|
|
8
8
|
type __VLS_Slots = {} & {
|
|
9
9
|
default?: (props: typeof __VLS_1) => any;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MagicTrayTransformAxis } from '../types/index.js';
|
|
2
2
|
interface MagicTrayTransformProps {
|
|
3
|
-
axis?:
|
|
3
|
+
axis?: MagicTrayTransformAxis;
|
|
4
4
|
factor?: number;
|
|
5
5
|
disabled?: boolean;
|
|
6
6
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { MagicTrayTransformAxis } from '../types/index.js';
|
|
2
2
|
interface MagicTrayTransformProps {
|
|
3
|
-
axis?:
|
|
3
|
+
axis?: MagicTrayTransformAxis;
|
|
4
4
|
factor?: number;
|
|
5
5
|
disabled?: boolean;
|
|
6
6
|
}
|