@maas/vue-equipment 1.0.0-beta.42 → 1.0.0-beta.44
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 +57 -0
- package/dist/composables/useScrollLockPadding/index.js.map +1 -0
- package/dist/nuxt/module.json +1 -1
- package/dist/nuxt/module.mjs +7 -0
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionProvider.vue +2 -5
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionState.d.ts +2 -3
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionState.mjs +38 -11
- package/dist/plugins/MagicAccordion/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicCommand/src/components/MagicCommandProvider.vue +2 -5
- package/dist/plugins/MagicCommand/src/components/MagicCommandRenderer.vue +1 -0
- package/dist/plugins/MagicCommand/src/components/MagicCommandView.vue +1 -1
- package/dist/plugins/MagicCommand/src/composables/private/useCommandState.d.ts +2 -3
- package/dist/plugins/MagicCommand/src/composables/private/useCommandState.mjs +36 -11
- package/dist/plugins/MagicCommand/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicCookie/src/composables/private/useCookieState.d.ts +2 -3
- package/dist/plugins/MagicCookie/src/composables/private/useCookieState.mjs +35 -12
- package/dist/plugins/MagicCookie/src/composables/useMagicCookie.mjs +6 -1
- package/dist/plugins/MagicCookie/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableDrag.mjs +33 -25
- 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/MagicDraggable/src/composables/private/useDraggableSnap.mjs +11 -1
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableState.d.ts +1 -1
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableState.mjs +41 -11
- package/dist/plugins/MagicDraggable/src/composables/useMagicDraggable.mjs +2 -1
- package/dist/plugins/MagicDraggable/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.d.vue.ts +2 -2
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue +15 -19
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue.d.ts +2 -2
- 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/MagicDrawer/src/composables/private/useDrawerDrag.d.ts +2 -0
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDrag.mjs +184 -29
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.d.ts +2 -3
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.mjs +35 -10
- package/dist/plugins/MagicDrawer/src/composables/useMagicDrawer.mjs +2 -1
- package/dist/plugins/MagicDrawer/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicEmitter/src/composables/useMagicEmitter.mjs +10 -5
- package/dist/plugins/MagicMarquee/src/components/MagicMarquee.vue +2 -5
- package/dist/plugins/MagicMarquee/src/composables/private/useMarqueeState.d.ts +2 -3
- package/dist/plugins/MagicMarquee/src/composables/private/useMarqueeState.mjs +36 -11
- package/dist/plugins/MagicMarquee/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicMenu/src/components/MagicMenuContent.vue +4 -12
- package/dist/plugins/MagicMenu/src/components/MagicMenuProvider.vue +2 -6
- 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/useMenuCursor.mjs +13 -1
- 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/useMenuState.d.ts +2 -3
- package/dist/plugins/MagicMenu/src/composables/private/useMenuState.mjs +32 -12
- package/dist/plugins/MagicMenu/src/composables/private/useMenuTrigger.mjs +1 -1
- package/dist/plugins/MagicMenu/src/types/index.d.ts +1 -0
- 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/MagicModal/src/composables/private/useModalState.d.ts +6 -0
- package/dist/plugins/MagicModal/src/composables/private/useModalState.mjs +58 -0
- package/dist/plugins/MagicModal/src/composables/private/useModalStore.d.ts +1 -5
- package/dist/plugins/MagicModal/src/composables/private/useModalStore.mjs +1 -15
- package/dist/plugins/MagicModal/src/composables/useMagicModal.mjs +7 -6
- package/dist/plugins/MagicModal/src/types/index.d.ts +5 -0
- package/dist/plugins/MagicNoise/src/components/MagicNoise.vue +14 -2
- package/dist/plugins/MagicPie/src/components/MagicPie.vue +12 -6
- package/dist/plugins/MagicPie/src/composables/private/usePieState.d.ts +1 -1
- package/dist/plugins/MagicPie/src/composables/private/usePieState.mjs +33 -12
- package/dist/plugins/MagicPie/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudio.vue +9 -6
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudioControls.vue +4 -8
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerMuxPopover.vue +8 -1
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerProvider.vue +2 -11
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideo.vue +10 -6
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideoControls.vue +4 -8
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerControlsApi.d.ts +0 -1
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerControlsApi.mjs +20 -9
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerEmitter.mjs +124 -75
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerMediaApi.mjs +100 -32
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerRuntime.d.ts +0 -1
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerRuntime.mjs +33 -13
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerState.d.ts +2 -3
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerState.mjs +35 -10
- package/dist/plugins/MagicPlayer/src/composables/useMagicPlayer.d.ts +0 -2
- package/dist/plugins/MagicPlayer/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicScroll/src/components/MagicScrollCollision.vue +2 -2
- package/dist/plugins/MagicScroll/src/components/MagicScrollMotion.vue +13 -1
- package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue +9 -5
- package/dist/plugins/MagicScroll/src/composables/private/useCollisionDetection.mjs +2 -1
- package/dist/plugins/MagicToast/src/components/MagicToastProvider.vue +2 -11
- package/dist/plugins/MagicToast/src/components/MagicToastView.vue +1 -0
- package/dist/plugins/MagicToast/src/composables/private/useToastDrag.mjs +18 -15
- package/dist/plugins/MagicToast/src/composables/private/useToastScrollLock.d.ts +2 -4
- package/dist/plugins/MagicToast/src/composables/private/useToastScrollLock.mjs +11 -49
- package/dist/plugins/MagicToast/src/composables/private/useToastState.d.ts +2 -3
- package/dist/plugins/MagicToast/src/composables/private/useToastState.mjs +35 -12
- package/dist/plugins/MagicToast/src/types/index.d.ts +1 -0
- package/dist/utils/index.d.ts +8 -1
- package/dist/utils/index.js +56497 -0
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/plugins/MagicError/src/MagicError.d.ts +0 -0
- package/dist/plugins/MagicError/src/MagicError.mjs +0 -0
|
@@ -2,10 +2,11 @@ import {
|
|
|
2
2
|
computed,
|
|
3
3
|
onMounted,
|
|
4
4
|
watch,
|
|
5
|
-
onBeforeUnmount,
|
|
6
5
|
toValue,
|
|
7
6
|
toRefs,
|
|
8
|
-
nextTick
|
|
7
|
+
nextTick,
|
|
8
|
+
onScopeDispose,
|
|
9
|
+
markRaw
|
|
9
10
|
} from "vue";
|
|
10
11
|
import {
|
|
11
12
|
useEventListener,
|
|
@@ -17,6 +18,7 @@ import {
|
|
|
17
18
|
import {
|
|
18
19
|
guardedReleasePointerCapture,
|
|
19
20
|
guardedSetPointerCapture,
|
|
21
|
+
isAndroid,
|
|
20
22
|
isIOS,
|
|
21
23
|
isWithinRange
|
|
22
24
|
} from "@maas/vue-equipment/utils";
|
|
@@ -72,8 +74,12 @@ export function useDrawerDrag(args) {
|
|
|
72
74
|
let pointerdownTarget = void 0;
|
|
73
75
|
let cancelPointerup = void 0;
|
|
74
76
|
let cancelPointermove = void 0;
|
|
77
|
+
let cancelPointercancel = void 0;
|
|
78
|
+
let cancelTouchmove = void 0;
|
|
75
79
|
let cancelTouchend = void 0;
|
|
80
|
+
let cancelTouchcancel = void 0;
|
|
76
81
|
let scrollLock = void 0;
|
|
82
|
+
let resizeObserverEl = null;
|
|
77
83
|
const hasDragged = computed(() => {
|
|
78
84
|
const hasDraggedX = !isWithinRange({
|
|
79
85
|
input: draggedX.value,
|
|
@@ -121,8 +127,10 @@ export function useDrawerDrag(args) {
|
|
|
121
127
|
const { clamp } = useDrawerUtils();
|
|
122
128
|
const emitter = useMagicEmitter();
|
|
123
129
|
async function getSizes() {
|
|
124
|
-
|
|
125
|
-
|
|
130
|
+
const el = unrefElement(elRef);
|
|
131
|
+
const wrapper = unrefElement(wrapperRef);
|
|
132
|
+
elRect.value = el ? markRaw(el.getBoundingClientRect()) : void 0;
|
|
133
|
+
wrapperRect.value = wrapper ? markRaw(wrapper.getBoundingClientRect()) : void 0;
|
|
126
134
|
await nextTick();
|
|
127
135
|
}
|
|
128
136
|
function checkPosition() {
|
|
@@ -252,13 +260,13 @@ export function useDrawerDrag(args) {
|
|
|
252
260
|
break;
|
|
253
261
|
}
|
|
254
262
|
}
|
|
255
|
-
function
|
|
256
|
-
|
|
257
|
-
shouldClose.value = false;
|
|
258
|
-
interpolateTo.value = void 0;
|
|
263
|
+
function resetListeners() {
|
|
264
|
+
cancelTouchmove?.();
|
|
259
265
|
cancelTouchend?.();
|
|
266
|
+
cancelTouchcancel?.();
|
|
260
267
|
cancelPointerup?.();
|
|
261
268
|
cancelPointermove?.();
|
|
269
|
+
cancelPointercancel?.();
|
|
262
270
|
}
|
|
263
271
|
function resetScrollLock() {
|
|
264
272
|
if (scrollLock?.value) {
|
|
@@ -266,7 +274,12 @@ export function useDrawerDrag(args) {
|
|
|
266
274
|
}
|
|
267
275
|
scrollLock = void 0;
|
|
268
276
|
}
|
|
269
|
-
function
|
|
277
|
+
function resetDragState() {
|
|
278
|
+
dragging.value = false;
|
|
279
|
+
shouldClose.value = false;
|
|
280
|
+
interpolateTo.value = void 0;
|
|
281
|
+
}
|
|
282
|
+
function resetCalcState() {
|
|
270
283
|
draggedX.value = 0;
|
|
271
284
|
draggedY.value = 0;
|
|
272
285
|
lastDraggedX.value = 0;
|
|
@@ -276,15 +289,15 @@ export function useDrawerDrag(args) {
|
|
|
276
289
|
elRect.value = void 0;
|
|
277
290
|
wrapperRect.value = void 0;
|
|
278
291
|
}
|
|
279
|
-
function
|
|
292
|
+
function resetSnapState() {
|
|
280
293
|
snappedX.value = 0;
|
|
281
294
|
snappedY.value = 0;
|
|
282
295
|
activeSnapPoint.value = void 0;
|
|
283
296
|
}
|
|
284
297
|
function afterLeaveCallback(payload) {
|
|
285
298
|
if (payload === toValue(id)) {
|
|
286
|
-
|
|
287
|
-
|
|
299
|
+
resetCalcState();
|
|
300
|
+
resetSnapState();
|
|
288
301
|
}
|
|
289
302
|
}
|
|
290
303
|
function snapToCallback(payload) {
|
|
@@ -309,6 +322,9 @@ export function useDrawerDrag(args) {
|
|
|
309
322
|
function destroy() {
|
|
310
323
|
emitter.off("snapTo", snapToCallback);
|
|
311
324
|
emitter.off("afterLeave", afterLeaveCallback);
|
|
325
|
+
resizeObserverEl?.stop();
|
|
326
|
+
resetDragState();
|
|
327
|
+
resetListeners();
|
|
312
328
|
}
|
|
313
329
|
function onCancel() {
|
|
314
330
|
switch (position) {
|
|
@@ -325,9 +341,41 @@ export function useDrawerDrag(args) {
|
|
|
325
341
|
});
|
|
326
342
|
break;
|
|
327
343
|
}
|
|
328
|
-
|
|
344
|
+
resetDragState();
|
|
345
|
+
resetListeners();
|
|
329
346
|
resetScrollLock();
|
|
330
347
|
}
|
|
348
|
+
function onPointermove(e) {
|
|
349
|
+
if (e.isTrusted && wheeling.value) {
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
if (e.isTrusted && !e.isPrimary) {
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
e.stopImmediatePropagation();
|
|
356
|
+
e.stopPropagation();
|
|
357
|
+
shouldClose.value = false;
|
|
358
|
+
checkDirection({ x: e.screenX, y: e.screenY });
|
|
359
|
+
if (!scrollLock) {
|
|
360
|
+
const scrollLockTarget = lockScroll(e.target);
|
|
361
|
+
if (scrollLockTarget) {
|
|
362
|
+
scrollLock = useScrollLock(scrollLockTarget);
|
|
363
|
+
scrollLock.value = true;
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
const dragTarget = pointerdownTarget ?? e.target;
|
|
367
|
+
if (!canDrag(dragTarget)) {
|
|
368
|
+
return;
|
|
369
|
+
}
|
|
370
|
+
setDragged({ x: e.screenX, y: e.screenY });
|
|
371
|
+
checkMomentum();
|
|
372
|
+
checkPosition();
|
|
373
|
+
emitter.emit("drag", {
|
|
374
|
+
id: toValue(id),
|
|
375
|
+
x: draggedX.value,
|
|
376
|
+
y: draggedY.value
|
|
377
|
+
});
|
|
378
|
+
}
|
|
331
379
|
function onPointerup(e) {
|
|
332
380
|
if (shouldClose.value) {
|
|
333
381
|
close();
|
|
@@ -369,35 +417,40 @@ export function useDrawerDrag(args) {
|
|
|
369
417
|
x: draggedX.value,
|
|
370
418
|
y: draggedY.value
|
|
371
419
|
});
|
|
372
|
-
|
|
420
|
+
resetDragState();
|
|
421
|
+
resetListeners();
|
|
373
422
|
resetScrollLock();
|
|
374
423
|
if (hasDragged.value) {
|
|
375
424
|
e.preventDefault();
|
|
376
425
|
}
|
|
377
426
|
guardedReleasePointerCapture({ event: e, element: pointerdownTarget });
|
|
378
427
|
}
|
|
379
|
-
function
|
|
380
|
-
if (e.isTrusted && wheeling.value) {
|
|
381
|
-
return;
|
|
382
|
-
}
|
|
383
|
-
if (e.isTrusted && !e.isPrimary) {
|
|
384
|
-
return;
|
|
385
|
-
}
|
|
428
|
+
function onTouchmove(e) {
|
|
386
429
|
e.stopImmediatePropagation();
|
|
387
430
|
e.stopPropagation();
|
|
388
431
|
shouldClose.value = false;
|
|
389
|
-
|
|
432
|
+
const firstTouch = e.touches[0];
|
|
433
|
+
if (!firstTouch) {
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
checkDirection({ x: firstTouch.screenX, y: firstTouch.screenY });
|
|
437
|
+
shouldClose.value = false;
|
|
438
|
+
checkDirection({ x: firstTouch.screenX, y: firstTouch.screenY });
|
|
390
439
|
if (!scrollLock) {
|
|
391
|
-
const scrollLockTarget = lockScroll(
|
|
440
|
+
const scrollLockTarget = lockScroll(firstTouch.target);
|
|
392
441
|
if (scrollLockTarget) {
|
|
393
442
|
scrollLock = useScrollLock(scrollLockTarget);
|
|
394
443
|
scrollLock.value = true;
|
|
395
444
|
}
|
|
396
445
|
}
|
|
397
|
-
|
|
446
|
+
const dragTarget = pointerdownTarget ?? e.target;
|
|
447
|
+
if (!canDrag(dragTarget)) {
|
|
398
448
|
return;
|
|
399
449
|
}
|
|
400
|
-
|
|
450
|
+
if (hasDragged.value) {
|
|
451
|
+
e.preventDefault();
|
|
452
|
+
}
|
|
453
|
+
setDragged({ x: firstTouch.screenX, y: firstTouch.screenY });
|
|
401
454
|
checkMomentum();
|
|
402
455
|
checkPosition();
|
|
403
456
|
emitter.emit("drag", {
|
|
@@ -406,6 +459,54 @@ export function useDrawerDrag(args) {
|
|
|
406
459
|
y: draggedY.value
|
|
407
460
|
});
|
|
408
461
|
}
|
|
462
|
+
function onTouchend(e) {
|
|
463
|
+
if (shouldClose.value) {
|
|
464
|
+
close();
|
|
465
|
+
} else if (interpolateTo.value || interpolateTo.value === 0) {
|
|
466
|
+
if (scrollLock && scrollLock.value || canInterpolate(e.target)) {
|
|
467
|
+
interpolateDragged({
|
|
468
|
+
to: interpolateTo.value
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
activeSnapPoint.value = snapPointsMap.value[interpolateTo.value];
|
|
472
|
+
switch (position) {
|
|
473
|
+
case "bottom":
|
|
474
|
+
case "top":
|
|
475
|
+
snappedY.value = interpolateTo.value;
|
|
476
|
+
break;
|
|
477
|
+
case "right":
|
|
478
|
+
case "left":
|
|
479
|
+
snappedX.value = interpolateTo.value;
|
|
480
|
+
break;
|
|
481
|
+
}
|
|
482
|
+
} else {
|
|
483
|
+
switch (position) {
|
|
484
|
+
case "bottom":
|
|
485
|
+
case "top":
|
|
486
|
+
interpolateDragged({
|
|
487
|
+
to: snappedY.value
|
|
488
|
+
});
|
|
489
|
+
break;
|
|
490
|
+
case "right":
|
|
491
|
+
case "left":
|
|
492
|
+
interpolateDragged({
|
|
493
|
+
to: snappedX.value
|
|
494
|
+
});
|
|
495
|
+
break;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
emitter.emit("afterDrag", {
|
|
499
|
+
id: toValue(id),
|
|
500
|
+
x: draggedX.value,
|
|
501
|
+
y: draggedY.value
|
|
502
|
+
});
|
|
503
|
+
resetDragState();
|
|
504
|
+
resetListeners();
|
|
505
|
+
resetScrollLock();
|
|
506
|
+
if (hasDragged.value) {
|
|
507
|
+
e.preventDefault();
|
|
508
|
+
}
|
|
509
|
+
}
|
|
409
510
|
function onPointerdown(e) {
|
|
410
511
|
if (dragging.value) {
|
|
411
512
|
return;
|
|
@@ -420,7 +521,7 @@ export function useDrawerDrag(args) {
|
|
|
420
521
|
pointerdownTarget = e.target;
|
|
421
522
|
guardedSetPointerCapture({
|
|
422
523
|
event: e,
|
|
423
|
-
element:
|
|
524
|
+
element: pointerdownTarget
|
|
424
525
|
});
|
|
425
526
|
emitter.emit("beforeDrag", {
|
|
426
527
|
id: toValue(id),
|
|
@@ -430,19 +531,71 @@ export function useDrawerDrag(args) {
|
|
|
430
531
|
}
|
|
431
532
|
lastDraggedX.value = draggedX.value;
|
|
432
533
|
lastDraggedY.value = draggedY.value;
|
|
534
|
+
resetListeners();
|
|
433
535
|
cancelPointerup = useEventListener(document, "pointerup", onPointerup);
|
|
536
|
+
cancelPointercancel = useEventListener(
|
|
537
|
+
document,
|
|
538
|
+
"pointercancel",
|
|
539
|
+
onPointerup
|
|
540
|
+
);
|
|
434
541
|
cancelPointermove = useEventListener(
|
|
435
542
|
document,
|
|
436
543
|
"pointermove",
|
|
437
544
|
onPointermove,
|
|
438
545
|
{ passive: false }
|
|
439
546
|
);
|
|
440
|
-
|
|
547
|
+
cancelTouchmove = isAndroid() ? useEventListener(document, "touchmove", onTouchmove, {
|
|
548
|
+
passive: false
|
|
549
|
+
}) : void 0;
|
|
550
|
+
cancelTouchend = isIOS() || isAndroid() ? useEventListener(document, "touchend", onTouchend) : void 0;
|
|
551
|
+
cancelTouchcancel = isIOS() || isAndroid() ? useEventListener(document, "touchcancel", onTouchend) : void 0;
|
|
441
552
|
originX.value = e.screenX - draggedX.value;
|
|
442
553
|
originY.value = e.screenY - draggedY.value;
|
|
443
554
|
dragStart.value = /* @__PURE__ */ new Date();
|
|
444
555
|
onPointermove(e);
|
|
445
556
|
}
|
|
557
|
+
function onTouchstart(e) {
|
|
558
|
+
if (!isAndroid()) {
|
|
559
|
+
return;
|
|
560
|
+
}
|
|
561
|
+
if (dragging.value) {
|
|
562
|
+
return;
|
|
563
|
+
} else {
|
|
564
|
+
const isSelect = ["SELECT", "OPTION"].includes(
|
|
565
|
+
e.target.tagName
|
|
566
|
+
);
|
|
567
|
+
if (isSelect) {
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
e.stopImmediatePropagation();
|
|
571
|
+
e.stopPropagation();
|
|
572
|
+
dragging.value = true;
|
|
573
|
+
pointerdownTarget = e.target;
|
|
574
|
+
emitter.emit("beforeDrag", {
|
|
575
|
+
id: toValue(id),
|
|
576
|
+
x: draggedX.value,
|
|
577
|
+
y: draggedY.value
|
|
578
|
+
});
|
|
579
|
+
}
|
|
580
|
+
cancelTouchmove?.();
|
|
581
|
+
cancelTouchmove = useEventListener(document, "touchmove", onTouchmove, {
|
|
582
|
+
passive: false
|
|
583
|
+
});
|
|
584
|
+
cancelTouchend?.();
|
|
585
|
+
cancelTouchend = useEventListener(document, "touchend", onTouchend, {
|
|
586
|
+
passive: false
|
|
587
|
+
});
|
|
588
|
+
cancelTouchcancel?.();
|
|
589
|
+
cancelTouchcancel = useEventListener(document, "touchcancel", onTouchend);
|
|
590
|
+
const firstTouch = e.touches[0];
|
|
591
|
+
if (!firstTouch) {
|
|
592
|
+
return;
|
|
593
|
+
}
|
|
594
|
+
originX.value = firstTouch.screenX - draggedX.value;
|
|
595
|
+
originY.value = firstTouch.screenY - draggedY.value;
|
|
596
|
+
dragStart.value = /* @__PURE__ */ new Date();
|
|
597
|
+
onTouchmove(e);
|
|
598
|
+
}
|
|
446
599
|
function onClick(e) {
|
|
447
600
|
if (hasDragged.value) {
|
|
448
601
|
e.preventDefault();
|
|
@@ -473,7 +626,7 @@ export function useDrawerDrag(args) {
|
|
|
473
626
|
}
|
|
474
627
|
}
|
|
475
628
|
);
|
|
476
|
-
useResizeObserver(elRef, async () => {
|
|
629
|
+
resizeObserverEl = useResizeObserver(elRef, async () => {
|
|
477
630
|
useThrottleFn(async () => {
|
|
478
631
|
await getSizes();
|
|
479
632
|
if (activeSnapPoint.value) {
|
|
@@ -482,11 +635,13 @@ export function useDrawerDrag(args) {
|
|
|
482
635
|
}
|
|
483
636
|
}, 100)();
|
|
484
637
|
});
|
|
485
|
-
|
|
638
|
+
onScopeDispose(() => {
|
|
486
639
|
destroy();
|
|
487
640
|
});
|
|
488
641
|
return {
|
|
489
642
|
onPointerdown,
|
|
643
|
+
onTouchstart,
|
|
644
|
+
onTouchmove,
|
|
490
645
|
onClick,
|
|
491
646
|
style,
|
|
492
647
|
hasDragged
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type MaybeRef } from 'vue';
|
|
2
2
|
import type { DrawerState } from '../../types/index.js';
|
|
3
3
|
export declare function useDrawerState(id: MaybeRef<string>): {
|
|
4
4
|
initializeState: () => DrawerState;
|
|
5
|
-
|
|
6
|
-
drawerStateStore: Ref<DrawerState[], DrawerState[]>;
|
|
5
|
+
drawerStateStore: import("vue").Ref<DrawerState[], DrawerState[]>;
|
|
7
6
|
};
|
|
@@ -1,9 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { reactive, toValue, onScopeDispose } from "vue";
|
|
2
|
+
import { createStateStore } from "@maas/vue-equipment/utils";
|
|
3
|
+
const getDrawerStateStore = createStateStore(
|
|
4
|
+
"MagicDrawer",
|
|
5
|
+
() => []
|
|
6
|
+
);
|
|
3
7
|
export function useDrawerState(id) {
|
|
8
|
+
const drawerStateStore = getDrawerStateStore();
|
|
9
|
+
let scopeCounted = false;
|
|
4
10
|
function createState(id2) {
|
|
5
11
|
const state = {
|
|
6
12
|
id: id2,
|
|
13
|
+
refCount: 0,
|
|
7
14
|
active: false,
|
|
8
15
|
dragStart: void 0,
|
|
9
16
|
dragging: false,
|
|
@@ -34,21 +41,39 @@ export function useDrawerState(id) {
|
|
|
34
41
|
drawerStateStore.value = [...drawerStateStore.value, state];
|
|
35
42
|
return state;
|
|
36
43
|
}
|
|
44
|
+
function deleteState() {
|
|
45
|
+
const currentId = toValue(id);
|
|
46
|
+
drawerStateStore.value = drawerStateStore.value.filter(
|
|
47
|
+
(x) => x.id !== currentId
|
|
48
|
+
);
|
|
49
|
+
}
|
|
37
50
|
function initializeState() {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
});
|
|
51
|
+
const currentId = toValue(id);
|
|
52
|
+
let state = drawerStateStore.value.find((entry) => entry.id === currentId);
|
|
41
53
|
if (!state) {
|
|
42
|
-
state = addState(
|
|
54
|
+
state = addState(currentId);
|
|
55
|
+
}
|
|
56
|
+
if (!scopeCounted) {
|
|
57
|
+
state.refCount++;
|
|
58
|
+
scopeCounted = true;
|
|
43
59
|
}
|
|
44
60
|
return state;
|
|
45
61
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
62
|
+
onScopeDispose(() => {
|
|
63
|
+
if (!scopeCounted) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const currentId = toValue(id);
|
|
67
|
+
const state = drawerStateStore.value.find((entry) => entry.id === currentId);
|
|
68
|
+
if (state) {
|
|
69
|
+
state.refCount--;
|
|
70
|
+
if (state.refCount <= 0) {
|
|
71
|
+
deleteState();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
49
75
|
return {
|
|
50
76
|
initializeState,
|
|
51
|
-
deleteState,
|
|
52
77
|
drawerStateStore
|
|
53
78
|
};
|
|
54
79
|
}
|
|
@@ -5,6 +5,7 @@ export function useMagicDrawer(id) {
|
|
|
5
5
|
const { initializeState } = useDrawerState(toValue(id));
|
|
6
6
|
const state = initializeState();
|
|
7
7
|
const { progress, active } = toRefs(state);
|
|
8
|
+
const emitter = useMagicEmitter();
|
|
8
9
|
const isActive = computed(() => active.value);
|
|
9
10
|
function open() {
|
|
10
11
|
active.value = true;
|
|
@@ -13,7 +14,7 @@ export function useMagicDrawer(id) {
|
|
|
13
14
|
active.value = false;
|
|
14
15
|
}
|
|
15
16
|
function snapTo(snapPoint, duration) {
|
|
16
|
-
|
|
17
|
+
emitter.emit("snapTo", {
|
|
17
18
|
id: toValue(id),
|
|
18
19
|
snapPoint,
|
|
19
20
|
duration
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
import mitt from "mitt";
|
|
2
|
-
|
|
1
|
+
import mitt, {} from "mitt";
|
|
2
|
+
import { createStateStore } from "@maas/vue-equipment/utils";
|
|
3
|
+
const getEmitter = createStateStore(
|
|
4
|
+
"MagicEmitter",
|
|
5
|
+
() => mitt()
|
|
6
|
+
);
|
|
3
7
|
export function useMagicEmitter() {
|
|
8
|
+
const emitter = getEmitter();
|
|
4
9
|
return {
|
|
5
|
-
on: emitter.on,
|
|
6
|
-
off: emitter.off,
|
|
7
|
-
emit: emitter.emit
|
|
10
|
+
on: emitter.value.on,
|
|
11
|
+
off: emitter.value.off,
|
|
12
|
+
emit: emitter.value.emit
|
|
8
13
|
};
|
|
9
14
|
}
|
|
@@ -17,14 +17,14 @@
|
|
|
17
17
|
</template>
|
|
18
18
|
|
|
19
19
|
<script setup>
|
|
20
|
-
import { useTemplateRef, onMounted
|
|
20
|
+
import { useTemplateRef, onMounted } from "vue";
|
|
21
21
|
import { useMarqueeApi } from "../composables/private/useMarqueeApi";
|
|
22
22
|
import { useMarqueeState } from "../composables/private/useMarqueeState";
|
|
23
23
|
const { id, options } = defineProps({
|
|
24
24
|
id: { type: null, required: true },
|
|
25
25
|
options: { type: Object, required: false }
|
|
26
26
|
});
|
|
27
|
-
const {
|
|
27
|
+
const { initializeState } = useMarqueeState(id);
|
|
28
28
|
initializeState(options);
|
|
29
29
|
const parentRef = useTemplateRef("parent");
|
|
30
30
|
const childRef = useTemplateRef("child");
|
|
@@ -36,9 +36,6 @@ const { duplicates, initialize } = useMarqueeApi({
|
|
|
36
36
|
onMounted(() => {
|
|
37
37
|
initialize();
|
|
38
38
|
});
|
|
39
|
-
onBeforeUnmount(() => {
|
|
40
|
-
deleteState();
|
|
41
|
-
});
|
|
42
39
|
</script>
|
|
43
40
|
|
|
44
41
|
<style>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type MaybeRef } from 'vue';
|
|
2
2
|
import type { MarqueeState, MagicMarqueeOptions } from '../../types/index.js';
|
|
3
3
|
export declare function useMarqueeState(instanceId: MaybeRef<string>): {
|
|
4
4
|
initializeState: (options?: MagicMarqueeOptions) => MarqueeState;
|
|
5
|
-
|
|
6
|
-
marqueeStateStore: Ref<MarqueeState[], MarqueeState[]>;
|
|
5
|
+
marqueeStateStore: import("vue").Ref<MarqueeState[], MarqueeState[]>;
|
|
7
6
|
};
|
|
@@ -1,11 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { reactive, toValue, onScopeDispose } from "vue";
|
|
2
2
|
import { defu } from "defu";
|
|
3
|
+
import { createStateStore } from "@maas/vue-equipment/utils";
|
|
3
4
|
import { defaultOptions } from "../../utils/defaultOptions.mjs";
|
|
4
|
-
const
|
|
5
|
+
const getMarqueeStateStore = createStateStore(
|
|
6
|
+
"MagicMarquee",
|
|
7
|
+
() => []
|
|
8
|
+
);
|
|
5
9
|
export function useMarqueeState(instanceId) {
|
|
10
|
+
const marqueeStateStore = getMarqueeStateStore();
|
|
11
|
+
let scopeCounted = false;
|
|
6
12
|
function createState(id) {
|
|
7
13
|
const state = {
|
|
8
14
|
id,
|
|
15
|
+
refCount: 0,
|
|
9
16
|
options: { ...defaultOptions },
|
|
10
17
|
playing: true
|
|
11
18
|
};
|
|
@@ -16,12 +23,21 @@ export function useMarqueeState(instanceId) {
|
|
|
16
23
|
marqueeStateStore.value = [...marqueeStateStore.value, state];
|
|
17
24
|
return state;
|
|
18
25
|
}
|
|
26
|
+
function deleteState() {
|
|
27
|
+
const currentId = toValue(instanceId);
|
|
28
|
+
marqueeStateStore.value = marqueeStateStore.value.filter(
|
|
29
|
+
(x) => x.id !== currentId
|
|
30
|
+
);
|
|
31
|
+
}
|
|
19
32
|
function initializeState(options) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
});
|
|
33
|
+
const currentId = toValue(instanceId);
|
|
34
|
+
let state = marqueeStateStore.value.find((entry) => entry.id === currentId);
|
|
23
35
|
if (!state) {
|
|
24
|
-
state = addState(
|
|
36
|
+
state = addState(currentId);
|
|
37
|
+
}
|
|
38
|
+
if (!scopeCounted) {
|
|
39
|
+
state.refCount++;
|
|
40
|
+
scopeCounted = true;
|
|
25
41
|
}
|
|
26
42
|
if (options) {
|
|
27
43
|
const mappedOptions = defu(options, defaultOptions);
|
|
@@ -29,14 +45,23 @@ export function useMarqueeState(instanceId) {
|
|
|
29
45
|
}
|
|
30
46
|
return state;
|
|
31
47
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
48
|
+
onScopeDispose(() => {
|
|
49
|
+
if (!scopeCounted) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const currentId = toValue(instanceId);
|
|
53
|
+
const state = marqueeStateStore.value.find(
|
|
54
|
+
(entry) => entry.id === currentId
|
|
35
55
|
);
|
|
36
|
-
|
|
56
|
+
if (state) {
|
|
57
|
+
state.refCount--;
|
|
58
|
+
if (state.refCount <= 0) {
|
|
59
|
+
deleteState();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
});
|
|
37
63
|
return {
|
|
38
64
|
initializeState,
|
|
39
|
-
deleteState,
|
|
40
65
|
marqueeStateStore
|
|
41
66
|
};
|
|
42
67
|
}
|
|
@@ -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;
|
|
@@ -15,8 +15,7 @@ import {
|
|
|
15
15
|
shallowRef,
|
|
16
16
|
provide,
|
|
17
17
|
watch,
|
|
18
|
-
toValue
|
|
19
|
-
onBeforeUnmount
|
|
18
|
+
toValue
|
|
20
19
|
} from "vue";
|
|
21
20
|
import { onClickOutside, onKeyStroke, usePointer } from "@vueuse/core";
|
|
22
21
|
import { VuePrimitive } from "@maas/vue-primitive";
|
|
@@ -33,7 +32,7 @@ const { id, options } = defineProps({
|
|
|
33
32
|
});
|
|
34
33
|
const elRef = useTemplateRef("el");
|
|
35
34
|
const mappedOptions = defu(options, defaultOptions);
|
|
36
|
-
const { initializeState
|
|
35
|
+
const { initializeState } = useMenuState(id);
|
|
37
36
|
const state = initializeState(mappedOptions);
|
|
38
37
|
const lastX = shallowRef(0);
|
|
39
38
|
const lastY = shallowRef(0);
|
|
@@ -87,9 +86,6 @@ onClickOutside(
|
|
|
87
86
|
]
|
|
88
87
|
}
|
|
89
88
|
);
|
|
90
|
-
onBeforeUnmount(() => {
|
|
91
|
-
deleteState();
|
|
92
|
-
});
|
|
93
89
|
provide(MagicMenuInstanceId, id);
|
|
94
90
|
</script>
|
|
95
91
|
|