@maas/vue-equipment 1.1.0 → 1.3.0
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 +4 -3
- package/dist/plugins/MagicCarousel/src/utils/defaultOptions.mjs +1 -1
- package/dist/plugins/MagicDotMatrix/index.d.ts +14 -0
- package/dist/plugins/MagicDotMatrix/index.mjs +20 -0
- package/dist/plugins/MagicDotMatrix/nuxt.d.ts +0 -0
- package/dist/plugins/MagicDotMatrix/nuxt.mjs +29 -0
- package/dist/plugins/MagicDotMatrix/src/components/MagicDotMatrix.d.vue.ts +10 -0
- package/dist/plugins/MagicDotMatrix/src/components/MagicDotMatrix.vue +103 -0
- package/dist/plugins/MagicDotMatrix/src/components/MagicDotMatrix.vue.d.ts +10 -0
- package/dist/plugins/MagicDotMatrix/src/composables/private/useDotMatrixApi.d.ts +10 -0
- package/dist/plugins/MagicDotMatrix/src/composables/private/useDotMatrixApi.mjs +82 -0
- package/dist/plugins/MagicDotMatrix/src/composables/private/useDotMatrixState.d.ts +6 -0
- package/dist/plugins/MagicDotMatrix/src/composables/private/useDotMatrixState.mjs +71 -0
- package/dist/plugins/MagicDotMatrix/src/composables/useMagicDotMatrix.d.ts +10 -0
- package/dist/plugins/MagicDotMatrix/src/composables/useMagicDotMatrix.mjs +27 -0
- package/dist/plugins/MagicDotMatrix/src/composables/useMagicDotMatrixEmoji.d.ts +19 -0
- package/dist/plugins/MagicDotMatrix/src/composables/useMagicDotMatrixEmoji.mjs +50 -0
- package/dist/plugins/MagicDotMatrix/src/types/index.d.ts +40 -0
- package/dist/plugins/MagicDotMatrix/src/types/index.mjs +0 -0
- package/dist/plugins/MagicDotMatrix/src/utils/defaultOptions.d.ts +4 -0
- package/dist/plugins/MagicDotMatrix/src/utils/defaultOptions.mjs +14 -0
- package/dist/plugins/MagicDotMatrix/src/utils/emoji/animateEmoji.d.ts +5 -0
- package/dist/plugins/MagicDotMatrix/src/utils/emoji/animateEmoji.mjs +296 -0
- package/dist/plugins/MagicDotMatrix/src/utils/emoji/motions.d.ts +382 -0
- package/dist/plugins/MagicDotMatrix/src/utils/emoji/motions.mjs +420 -0
- package/dist/plugins/MagicDotMatrix/src/utils/emoji/pickMotion.d.ts +7 -0
- package/dist/plugins/MagicDotMatrix/src/utils/emoji/pickMotion.mjs +153 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/bounce.d.ts +2 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/bounce.mjs +8 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/checkerboard.d.ts +2 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/checkerboard.mjs +18 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/comet.d.ts +2 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/comet.mjs +5 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/drift.d.ts +2 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/drift.mjs +38 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/equalizer.d.ts +2 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/equalizer.mjs +14 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/fill.d.ts +2 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/fill.mjs +10 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/focus.d.ts +2 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/focus.mjs +5 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/index.d.ts +12 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/index.mjs +12 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/orbit.d.ts +2 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/orbit.mjs +8 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/pulse.d.ts +2 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/pulse.mjs +7 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/ripple.d.ts +2 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/ripple.mjs +5 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/scan.d.ts +2 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/scan.mjs +6 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/spiral.d.ts +2 -0
- package/dist/plugins/MagicDotMatrix/src/utils/presets/spiral.mjs +34 -0
- package/dist/plugins/MagicDotMatrix/src/utils/sequence/equalizerFrame.d.ts +7 -0
- package/dist/plugins/MagicDotMatrix/src/utils/sequence/equalizerFrame.mjs +12 -0
- package/dist/plugins/MagicDotMatrix/src/utils/sequence/getRings.d.ts +2 -0
- package/dist/plugins/MagicDotMatrix/src/utils/sequence/getRings.mjs +24 -0
- package/dist/plugins/MagicDotMatrix/src/utils/sequence/ringPath.d.ts +7 -0
- package/dist/plugins/MagicDotMatrix/src/utils/sequence/ringPath.mjs +35 -0
- package/dist/plugins/MagicDotMatrix/src/utils/sequence/toIndex.d.ts +6 -0
- package/dist/plugins/MagicDotMatrix/src/utils/sequence/toIndex.mjs +3 -0
- package/dist/plugins/MagicDotMatrix/src/utils/sequence/withTrail.d.ts +6 -0
- package/dist/plugins/MagicDotMatrix/src/utils/sequence/withTrail.mjs +17 -0
- package/dist/plugins/MagicDraggable/src/utils/defaultOptions.mjs +1 -1
- package/dist/plugins/MagicDrawer/src/components/MagicDrawerContent.vue +4 -0
- package/dist/plugins/MagicDrawer/src/components/MagicDrawerTrigger.d.vue.ts +1 -1
- package/dist/plugins/MagicDrawer/src/components/MagicDrawerTrigger.vue +5 -1
- package/dist/plugins/MagicDrawer/src/components/MagicDrawerTrigger.vue.d.ts +1 -1
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDrag.mjs +1 -2
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerProgress.mjs +57 -77
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerSnap.mjs +2 -5
- package/dist/plugins/MagicDrawer/src/utils/defaultOptions.mjs +1 -1
- package/dist/plugins/MagicEmitter/src/types/index.d.ts +2 -0
- package/dist/plugins/MagicMenu/src/components/MagicMenuTrigger.vue +13 -3
- package/dist/plugins/MagicTray/index.d.ts +2 -1
- package/dist/plugins/MagicTray/index.mjs +3 -0
- package/dist/plugins/MagicTray/src/components/MagicTrayContent.d.vue.ts +2 -2
- package/dist/plugins/MagicTray/src/components/MagicTrayContent.vue +17 -16
- package/dist/plugins/MagicTray/src/components/MagicTrayContent.vue.d.ts +2 -2
- package/dist/plugins/MagicTray/src/components/MagicTrayTrigger.d.vue.ts +25 -0
- package/dist/plugins/MagicTray/src/components/MagicTrayTrigger.vue +96 -0
- package/dist/plugins/MagicTray/src/components/MagicTrayTrigger.vue.d.ts +25 -0
- package/dist/plugins/MagicTray/src/composables/private/useTrayDrag.d.ts +0 -4
- package/dist/plugins/MagicTray/src/composables/private/useTrayDrag.mjs +9 -415
- package/dist/plugins/MagicTray/src/composables/private/useTrayGesture.d.ts +16 -0
- package/dist/plugins/MagicTray/src/composables/private/useTrayGesture.mjs +426 -0
- package/dist/plugins/MagicTray/src/composables/private/useTrayMagnetism.mjs +9 -37
- package/dist/plugins/MagicTray/src/composables/private/useTrayProgress.mjs +1 -1
- package/dist/plugins/MagicTray/src/composables/private/useTraySnap.mjs +2 -4
- package/dist/plugins/MagicTray/src/composables/private/useTrayUtils.d.ts +8 -1
- package/dist/plugins/MagicTray/src/composables/private/useTrayUtils.mjs +7 -1
- package/dist/plugins/MagicTray/src/utils/defaultOptions.mjs +1 -1
- package/package.json +3 -4
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { createBounce } from './bounce.js';
|
|
2
|
+
export { createCheckerboard } from './checkerboard.js';
|
|
3
|
+
export { createComet } from './comet.js';
|
|
4
|
+
export { createDrift } from './drift.js';
|
|
5
|
+
export { createEqualizer } from './equalizer.js';
|
|
6
|
+
export { createFill } from './fill.js';
|
|
7
|
+
export { createFocus } from './focus.js';
|
|
8
|
+
export { createOrbit } from './orbit.js';
|
|
9
|
+
export { createPulse } from './pulse.js';
|
|
10
|
+
export { createRipple } from './ripple.js';
|
|
11
|
+
export { createScan } from './scan.js';
|
|
12
|
+
export { createSpiral } from './spiral.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { createBounce } from "./bounce.mjs";
|
|
2
|
+
export { createCheckerboard } from "./checkerboard.mjs";
|
|
3
|
+
export { createComet } from "./comet.mjs";
|
|
4
|
+
export { createDrift } from "./drift.mjs";
|
|
5
|
+
export { createEqualizer } from "./equalizer.mjs";
|
|
6
|
+
export { createFill } from "./fill.mjs";
|
|
7
|
+
export { createFocus } from "./focus.mjs";
|
|
8
|
+
export { createOrbit } from "./orbit.mjs";
|
|
9
|
+
export { createPulse } from "./pulse.mjs";
|
|
10
|
+
export { createRipple } from "./ripple.mjs";
|
|
11
|
+
export { createScan } from "./scan.mjs";
|
|
12
|
+
export { createSpiral } from "./spiral.mjs";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { getRings } from "../sequence/getRings.mjs";
|
|
2
|
+
export function createPulse(grid) {
|
|
3
|
+
const rings = getRings(grid);
|
|
4
|
+
const expand = rings.map((_, index) => rings.slice(0, index + 1).flat());
|
|
5
|
+
const contract = rings.map((_, index) => rings.slice(0, rings.length - index - 1).flat()).slice(1);
|
|
6
|
+
return [...expand, ...contract, []];
|
|
7
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
function spiralOrder({ cols, rows }) {
|
|
2
|
+
const result = [];
|
|
3
|
+
let top = 0;
|
|
4
|
+
let bottom = rows - 1;
|
|
5
|
+
let left = 0;
|
|
6
|
+
let right = cols - 1;
|
|
7
|
+
while (top <= bottom && left <= right) {
|
|
8
|
+
for (let col = left; col <= right; col++) {
|
|
9
|
+
result.push(top * cols + col);
|
|
10
|
+
}
|
|
11
|
+
top++;
|
|
12
|
+
for (let row = top; row <= bottom; row++) {
|
|
13
|
+
result.push(row * cols + right);
|
|
14
|
+
}
|
|
15
|
+
right--;
|
|
16
|
+
if (top <= bottom) {
|
|
17
|
+
for (let col = right; col >= left; col--) {
|
|
18
|
+
result.push(bottom * cols + col);
|
|
19
|
+
}
|
|
20
|
+
bottom--;
|
|
21
|
+
}
|
|
22
|
+
if (left <= right) {
|
|
23
|
+
for (let row = bottom; row >= top; row--) {
|
|
24
|
+
result.push(row * cols + left);
|
|
25
|
+
}
|
|
26
|
+
left++;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
export function createSpiral(grid) {
|
|
32
|
+
const order = spiralOrder(grid);
|
|
33
|
+
return [...order.map((_, index) => order.slice(0, index + 1)), []];
|
|
34
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { toIndex } from "./toIndex.mjs";
|
|
2
|
+
export function getRings({ cols, rows }) {
|
|
3
|
+
const centerCol = (cols - 1) / 2;
|
|
4
|
+
const centerRow = (rows - 1) / 2;
|
|
5
|
+
const maxRing = Math.max(
|
|
6
|
+
Math.ceil(Math.max(centerCol, cols - 1 - centerCol)),
|
|
7
|
+
Math.ceil(Math.max(centerRow, rows - 1 - centerRow))
|
|
8
|
+
);
|
|
9
|
+
return Array.from({ length: maxRing + 1 }, (_, ring) => {
|
|
10
|
+
const indices = [];
|
|
11
|
+
for (let row = 0; row < rows; row++) {
|
|
12
|
+
for (let col = 0; col < cols; col++) {
|
|
13
|
+
const distance = Math.max(
|
|
14
|
+
Math.abs(col - centerCol),
|
|
15
|
+
Math.abs(row - centerRow)
|
|
16
|
+
);
|
|
17
|
+
if (Math.floor(distance + 0.5) === ring) {
|
|
18
|
+
indices.push(toIndex({ col, row, cols }));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return indices;
|
|
23
|
+
}).filter((frame) => frame.length > 0);
|
|
24
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { toIndex } from "./toIndex.mjs";
|
|
2
|
+
export function ringPath({
|
|
3
|
+
cols,
|
|
4
|
+
rows,
|
|
5
|
+
inset = 0
|
|
6
|
+
}) {
|
|
7
|
+
const left = inset;
|
|
8
|
+
const top = inset;
|
|
9
|
+
const right = cols - 1 - inset;
|
|
10
|
+
const bottom = rows - 1 - inset;
|
|
11
|
+
if (left > right || top > bottom) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
if (left === right && top === bottom) {
|
|
15
|
+
return [toIndex({ col: left, row: top, cols })];
|
|
16
|
+
}
|
|
17
|
+
const path = [];
|
|
18
|
+
for (let col = left; col <= right; col++) {
|
|
19
|
+
path.push(toIndex({ col, row: top, cols }));
|
|
20
|
+
}
|
|
21
|
+
for (let row = top + 1; row <= bottom; row++) {
|
|
22
|
+
path.push(toIndex({ col: right, row, cols }));
|
|
23
|
+
}
|
|
24
|
+
if (bottom > top) {
|
|
25
|
+
for (let col = right - 1; col >= left; col--) {
|
|
26
|
+
path.push(toIndex({ col, row: bottom, cols }));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
if (right > left) {
|
|
30
|
+
for (let row = bottom - 1; row > top; row--) {
|
|
31
|
+
path.push(toIndex({ col: left, row, cols }));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return path;
|
|
35
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export function withTrail({
|
|
2
|
+
path,
|
|
3
|
+
length = 3
|
|
4
|
+
}) {
|
|
5
|
+
if (path.length === 0) {
|
|
6
|
+
return [[]];
|
|
7
|
+
}
|
|
8
|
+
const trail = Math.max(1, Math.min(length, path.length));
|
|
9
|
+
return path.map((_, index) => [
|
|
10
|
+
...new Set(
|
|
11
|
+
Array.from(
|
|
12
|
+
{ length: trail },
|
|
13
|
+
(__, offset) => path[(index + offset) % path.length]
|
|
14
|
+
)
|
|
15
|
+
)
|
|
16
|
+
]);
|
|
17
|
+
}
|
|
@@ -367,6 +367,10 @@ dialog.magic-drawer-content__drag::backdrop {
|
|
|
367
367
|
user-select: none;
|
|
368
368
|
}
|
|
369
369
|
|
|
370
|
+
.magic-drawer-content[data-dragging='true'] .magic-drawer-content__drag * {
|
|
371
|
+
-webkit-user-drag: none;
|
|
372
|
+
}
|
|
373
|
+
|
|
370
374
|
.magic-drawer-content[data-wheeling='true'] .magic-drawer-content__drag {
|
|
371
375
|
cursor: auto;
|
|
372
376
|
}
|
|
@@ -18,7 +18,11 @@ import { useMagicError } from "@maas/vue-equipment/plugins/MagicError";
|
|
|
18
18
|
import { useMagicDrawer } from "../composables/useMagicDrawer";
|
|
19
19
|
import { useDrawerState } from "../composables/private/useDrawerState";
|
|
20
20
|
import { MagicDrawerInstanceId } from "../symbols";
|
|
21
|
-
const {
|
|
21
|
+
const {
|
|
22
|
+
id,
|
|
23
|
+
disabled = void 0,
|
|
24
|
+
asChild
|
|
25
|
+
} = defineProps({
|
|
22
26
|
id: { type: null, required: false },
|
|
23
27
|
disabled: { type: Boolean, required: false },
|
|
24
28
|
asChild: { type: Boolean, required: false }
|
|
@@ -456,8 +456,6 @@ export function useDrawerDrag(args) {
|
|
|
456
456
|
return;
|
|
457
457
|
}
|
|
458
458
|
checkDirection({ x: firstTouch.clientX, y: firstTouch.clientY });
|
|
459
|
-
shouldClose.value = false;
|
|
460
|
-
checkDirection({ x: firstTouch.clientX, y: firstTouch.clientY });
|
|
461
459
|
if (!scrollLock) {
|
|
462
460
|
const scrollLockTarget = lockScroll(firstTouch.target);
|
|
463
461
|
if (scrollLockTarget) {
|
|
@@ -611,6 +609,7 @@ export function useDrawerDrag(args) {
|
|
|
611
609
|
await getSizes();
|
|
612
610
|
const snapPoint = toValue(initial)?.snapPoint;
|
|
613
611
|
if (!snapPoint) {
|
|
612
|
+
activeSnapPoint.value = snapPointAt(0);
|
|
614
613
|
return;
|
|
615
614
|
}
|
|
616
615
|
if (isUnknownSnapPoint(snapPoint)) {
|
|
@@ -14,6 +14,10 @@ import { useDrawerState } from "./useDrawerState.mjs";
|
|
|
14
14
|
export function useDrawerProgress(args) {
|
|
15
15
|
const { id, drawerRef, elRef, position, overshoot } = args;
|
|
16
16
|
const { initializeState } = useDrawerState(id);
|
|
17
|
+
const emitter = useMagicEmitter();
|
|
18
|
+
const state = initializeState();
|
|
19
|
+
const { draggedX, draggedY, wrapperRect } = toRefs(state);
|
|
20
|
+
let transitioning = false;
|
|
17
21
|
const drawerRect = useElementBounding(drawerRef);
|
|
18
22
|
const elRect = useElementBounding(elRef);
|
|
19
23
|
const maxX = computed(
|
|
@@ -22,27 +26,38 @@ export function useDrawerProgress(args) {
|
|
|
22
26
|
const maxY = computed(
|
|
23
27
|
() => drawerRect.height.value - elRect.height.value + toValue(overshoot)
|
|
24
28
|
);
|
|
25
|
-
const state = initializeState();
|
|
26
29
|
const { progress } = toRefs(state);
|
|
27
|
-
function
|
|
30
|
+
function setProgress(x, y) {
|
|
31
|
+
progress.value = {
|
|
32
|
+
x: clampValue(x, 0, 1) || 0,
|
|
33
|
+
y: clampValue(y, 0, 1) || 0
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function calculate() {
|
|
37
|
+
const rect = wrapperRect.value;
|
|
38
|
+
if (!rect) {
|
|
39
|
+
setProgress(0, 0);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const extentX = rect.width - toValue(overshoot);
|
|
43
|
+
const extentY = rect.height - toValue(overshoot);
|
|
44
|
+
switch (toValue(position)) {
|
|
45
|
+
case "top":
|
|
46
|
+
case "bottom":
|
|
47
|
+
setProgress(0, extentY ? 1 - Math.abs(draggedY.value) / extentY : 0);
|
|
48
|
+
break;
|
|
49
|
+
case "left":
|
|
50
|
+
case "right":
|
|
51
|
+
setProgress(extentX ? 1 - Math.abs(draggedX.value) / extentX : 0, 0);
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
function measure() {
|
|
28
56
|
drawerRect.update();
|
|
29
57
|
elRect.update();
|
|
30
|
-
calculateProgress();
|
|
31
|
-
}
|
|
32
|
-
const emitter = useMagicEmitter();
|
|
33
|
-
const { pause: snapPause, resume: snapResume } = useRafFn(rafCallback, {
|
|
34
|
-
immediate: false
|
|
35
|
-
});
|
|
36
|
-
const { pause: dragPause, resume: dragResume } = useRafFn(rafCallback, {
|
|
37
|
-
immediate: false
|
|
38
|
-
});
|
|
39
|
-
const { pause, resume } = useRafFn(rafCallback, {
|
|
40
|
-
immediate: false
|
|
41
|
-
});
|
|
42
|
-
function calculateProgress() {
|
|
43
58
|
let rawX = 0;
|
|
44
59
|
let rawY = 0;
|
|
45
|
-
switch (position) {
|
|
60
|
+
switch (toValue(position)) {
|
|
46
61
|
case "bottom":
|
|
47
62
|
rawY = mapValue(
|
|
48
63
|
elRect.top.value,
|
|
@@ -80,81 +95,46 @@ export function useDrawerProgress(args) {
|
|
|
80
95
|
);
|
|
81
96
|
break;
|
|
82
97
|
}
|
|
83
|
-
|
|
84
|
-
rawX = 0;
|
|
85
|
-
}
|
|
86
|
-
if (Object.is(rawY, -0)) {
|
|
87
|
-
rawY = 0;
|
|
88
|
-
}
|
|
89
|
-
const x = clampValue(rawX, 0, 1);
|
|
90
|
-
const y = clampValue(rawY, 0, 1);
|
|
91
|
-
progress.value = { x, y };
|
|
98
|
+
setProgress(rawX, rawY);
|
|
92
99
|
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
id: toValue(id),
|
|
96
|
-
x,
|
|
97
|
-
y
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
function beforeCallback(payload) {
|
|
100
|
+
const { pause, resume } = useRafFn(measure, { immediate: false });
|
|
101
|
+
function beforeTransition(payload) {
|
|
101
102
|
if (payload === toValue(id)) {
|
|
103
|
+
transitioning = true;
|
|
102
104
|
resume();
|
|
103
105
|
}
|
|
104
106
|
}
|
|
105
|
-
function
|
|
106
|
-
if (payload.id === toValue(id)) {
|
|
107
|
-
snapResume();
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
function beforeDragCallback(payload) {
|
|
111
|
-
if (payload.id === toValue(id)) {
|
|
112
|
-
dragResume();
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
async function afterCallback(payload) {
|
|
107
|
+
async function afterTransition(payload) {
|
|
116
108
|
await nextTick();
|
|
117
109
|
if (payload === toValue(id)) {
|
|
118
110
|
pause();
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
async function afterSnapCallback(payload) {
|
|
124
|
-
await nextTick();
|
|
125
|
-
if (payload.id === toValue(id)) {
|
|
126
|
-
snapPause();
|
|
127
|
-
await nextTick();
|
|
128
|
-
rafCallback();
|
|
111
|
+
transitioning = false;
|
|
112
|
+
calculate();
|
|
129
113
|
}
|
|
130
114
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
dragPause();
|
|
135
|
-
await nextTick();
|
|
136
|
-
rafCallback();
|
|
115
|
+
watch([draggedX, draggedY, wrapperRect, () => toValue(overshoot)], () => {
|
|
116
|
+
if (!transitioning) {
|
|
117
|
+
calculate();
|
|
137
118
|
}
|
|
138
|
-
}
|
|
119
|
+
});
|
|
120
|
+
watch([() => progress.value.x, () => progress.value.y], ([x, y]) => {
|
|
121
|
+
emitter.emit("progress", {
|
|
122
|
+
id: toValue(id),
|
|
123
|
+
x,
|
|
124
|
+
y
|
|
125
|
+
});
|
|
126
|
+
});
|
|
139
127
|
onMounted(() => {
|
|
140
|
-
emitter.on("beforeEnter",
|
|
141
|
-
emitter.on("afterEnter",
|
|
142
|
-
emitter.on("
|
|
143
|
-
emitter.on("
|
|
144
|
-
emitter.on("beforeSnap", beforeSnapCallback);
|
|
145
|
-
emitter.on("afterSnap", afterSnapCallback);
|
|
146
|
-
emitter.on("beforeLeave", beforeCallback);
|
|
147
|
-
emitter.on("afterLeave", afterCallback);
|
|
128
|
+
emitter.on("beforeEnter", beforeTransition);
|
|
129
|
+
emitter.on("afterEnter", afterTransition);
|
|
130
|
+
emitter.on("beforeLeave", beforeTransition);
|
|
131
|
+
emitter.on("afterLeave", afterTransition);
|
|
148
132
|
});
|
|
149
133
|
onBeforeUnmount(() => {
|
|
150
|
-
emitter.off("beforeEnter",
|
|
151
|
-
emitter.off("afterEnter",
|
|
152
|
-
emitter.off("
|
|
153
|
-
emitter.off("
|
|
154
|
-
emitter.off("beforeSnap", beforeSnapCallback);
|
|
155
|
-
emitter.off("afterSnap", afterSnapCallback);
|
|
156
|
-
emitter.off("beforeLeave", beforeCallback);
|
|
157
|
-
emitter.off("afterLeave", afterCallback);
|
|
134
|
+
emitter.off("beforeEnter", beforeTransition);
|
|
135
|
+
emitter.off("afterEnter", afterTransition);
|
|
136
|
+
emitter.off("beforeLeave", beforeTransition);
|
|
137
|
+
emitter.off("afterLeave", afterTransition);
|
|
158
138
|
});
|
|
159
139
|
return { progress };
|
|
160
140
|
}
|
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
} from "@maas/vue-equipment/utils";
|
|
9
9
|
import { useMagicEmitter } from "@maas/vue-equipment/plugins/MagicEmitter";
|
|
10
10
|
import { useDrawerUtils } from "./useDrawerUtils.mjs";
|
|
11
|
-
const SNAP_TOLERANCE = 0.01;
|
|
12
11
|
function isMapped(value) {
|
|
13
12
|
return value !== void 0 && !Number.isNaN(value);
|
|
14
13
|
}
|
|
@@ -193,7 +192,7 @@ export function useDrawerSnap(args) {
|
|
|
193
192
|
function configuredPointAt(offset) {
|
|
194
193
|
return configuredPoints.value.find((snapPoint) => {
|
|
195
194
|
const mapped = mapSnapPoint(snapPoint);
|
|
196
|
-
return
|
|
195
|
+
return mapped === offset;
|
|
197
196
|
});
|
|
198
197
|
}
|
|
199
198
|
function draggedOnAxis() {
|
|
@@ -242,9 +241,7 @@ export function useDrawerSnap(args) {
|
|
|
242
241
|
if (!isMapped(mapped)) {
|
|
243
242
|
return false;
|
|
244
243
|
}
|
|
245
|
-
return !!rangeAt(mapped) || mappedSnapPoints.value.
|
|
246
|
-
(point) => Math.abs(point - mapped) < SNAP_TOLERANCE
|
|
247
|
-
);
|
|
244
|
+
return !!rangeAt(mapped) || mappedSnapPoints.value.includes(mapped);
|
|
248
245
|
}
|
|
249
246
|
function findSnapTarget(offset) {
|
|
250
247
|
const target = snapTargetAt({
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AccordionEvents } from '../../../MagicAccordion/src/types/index.js';
|
|
2
2
|
import type { CarouselEvents } from '../../../MagicCarousel/src/types/index.js';
|
|
3
3
|
import type { CookieEvents } from '../../../MagicCookie/src/types/index.js';
|
|
4
|
+
import type { DotMatrixEvents } from '../../../MagicDotMatrix/src/types/index.js';
|
|
4
5
|
import type { DraggableEvents } from '../../../MagicDraggable/src/types/index.js';
|
|
5
6
|
import type { DrawerEvents } from '../../../MagicDrawer/src/types/index.js';
|
|
6
7
|
import type { ModalEvents } from '../../../MagicModal/src/types/index.js';
|
|
@@ -17,6 +18,7 @@ export type MagicEmitterEvents = Merge<[
|
|
|
17
18
|
AccordionEvents,
|
|
18
19
|
CarouselEvents,
|
|
19
20
|
CookieEvents,
|
|
21
|
+
DotMatrixEvents,
|
|
20
22
|
DraggableEvents,
|
|
21
23
|
DrawerEvents,
|
|
22
24
|
ModalEvents,
|
|
@@ -29,7 +29,12 @@ import {
|
|
|
29
29
|
MagicMenuItemId,
|
|
30
30
|
MagicMenuViewId
|
|
31
31
|
} from "../symbols";
|
|
32
|
-
const {
|
|
32
|
+
const {
|
|
33
|
+
instanceId,
|
|
34
|
+
viewId,
|
|
35
|
+
disabled = void 0,
|
|
36
|
+
trigger
|
|
37
|
+
} = defineProps({
|
|
33
38
|
instanceId: { type: String, required: false },
|
|
34
39
|
viewId: { type: String, required: false },
|
|
35
40
|
disabled: { type: Boolean, required: false },
|
|
@@ -54,13 +59,18 @@ magicError.assert(mappedViewId.value, {
|
|
|
54
59
|
message: "MagicMenuTrigger must be nested inside MagicMenuView or a viewId must be provided",
|
|
55
60
|
errorCode: "missing_view_id"
|
|
56
61
|
});
|
|
57
|
-
const { getView, getRelativeViewIndex } = useMenuView(
|
|
62
|
+
const { getView, getRelativeViewIndex, getParentView } = useMenuView(
|
|
63
|
+
mappedInstanceId.value
|
|
64
|
+
);
|
|
58
65
|
const view = getView(mappedViewId.value);
|
|
59
66
|
const viewIndex = getRelativeViewIndex(mappedViewId.value);
|
|
60
67
|
const { initializeState } = useMenuState(mappedInstanceId.value);
|
|
61
68
|
const state = initializeState();
|
|
62
69
|
const { getItem } = useMenuItem(mappedInstanceId.value);
|
|
63
|
-
const item = getItem({
|
|
70
|
+
const item = getItem({
|
|
71
|
+
viewId: getParentView(mappedViewId.value)?.id ?? "",
|
|
72
|
+
id: itemId ?? ""
|
|
73
|
+
});
|
|
64
74
|
const mappedDisabled = computed(() => disabled ?? item?.disabled ?? false);
|
|
65
75
|
const mappedTrigger = computed(() => {
|
|
66
76
|
if (trigger?.length) {
|
|
@@ -2,10 +2,11 @@ import MagicTray from './src/components/MagicTray.vue.js';
|
|
|
2
2
|
import MagicTrayProvider from './src/components/MagicTrayProvider.vue.js';
|
|
3
3
|
import MagicTrayContent from './src/components/MagicTrayContent.vue.js';
|
|
4
4
|
import MagicTrayHandle from './src/components/MagicTrayHandle.vue.js';
|
|
5
|
+
import MagicTrayTrigger from './src/components/MagicTrayTrigger.vue.js';
|
|
5
6
|
import MagicTrayTransform from './src/components/MagicTrayTransform.vue.js';
|
|
6
7
|
import { useMagicTray } from './src/composables/useMagicTray.js';
|
|
7
8
|
import type { Plugin } from 'vue';
|
|
8
9
|
import type { MagicTrayDragMode, MagicTrayOptions, MagicTraySide, MagicTraySidePayload, MagicTraySnapEntry, MagicTraySnapMode, MagicTraySnapPoint, MagicTraySnapPointPayload, MagicTraySnapRange, MagicTrayTransformAxis, MagicTrayWillSnapToPayload } from './src/types/index.js';
|
|
9
10
|
declare const MagicTrayPlugin: Plugin;
|
|
10
|
-
export { MagicTrayPlugin, MagicTray, MagicTrayProvider, MagicTrayContent, MagicTrayHandle, MagicTrayTransform, useMagicTray, };
|
|
11
|
+
export { MagicTrayPlugin, MagicTray, MagicTrayProvider, MagicTrayContent, MagicTrayHandle, MagicTrayTrigger, MagicTrayTransform, useMagicTray, };
|
|
11
12
|
export type { MagicTrayOptions, MagicTraySide, MagicTraySidePayload, MagicTraySnapMode, MagicTrayDragMode, MagicTraySnapPoint, MagicTraySnapRange, MagicTraySnapEntry, MagicTraySnapPointPayload, MagicTrayWillSnapToPayload, MagicTrayTransformAxis, };
|
|
@@ -2,6 +2,7 @@ import MagicTray from "./src/components/MagicTray.vue";
|
|
|
2
2
|
import MagicTrayProvider from "./src/components/MagicTrayProvider.vue";
|
|
3
3
|
import MagicTrayContent from "./src/components/MagicTrayContent.vue";
|
|
4
4
|
import MagicTrayHandle from "./src/components/MagicTrayHandle.vue";
|
|
5
|
+
import MagicTrayTrigger from "./src/components/MagicTrayTrigger.vue";
|
|
5
6
|
import MagicTrayTransform from "./src/components/MagicTrayTransform.vue";
|
|
6
7
|
import { useMagicTray } from "./src/composables/useMagicTray.mjs";
|
|
7
8
|
const MagicTrayPlugin = {
|
|
@@ -10,6 +11,7 @@ const MagicTrayPlugin = {
|
|
|
10
11
|
app.component("MagicTrayProvider", MagicTrayProvider);
|
|
11
12
|
app.component("MagicTrayContent", MagicTrayContent);
|
|
12
13
|
app.component("MagicTrayHandle", MagicTrayHandle);
|
|
14
|
+
app.component("MagicTrayTrigger", MagicTrayTrigger);
|
|
13
15
|
app.component("MagicTrayTransform", MagicTrayTransform);
|
|
14
16
|
}
|
|
15
17
|
};
|
|
@@ -19,6 +21,7 @@ export {
|
|
|
19
21
|
MagicTrayProvider,
|
|
20
22
|
MagicTrayContent,
|
|
21
23
|
MagicTrayHandle,
|
|
24
|
+
MagicTrayTrigger,
|
|
22
25
|
MagicTrayTransform,
|
|
23
26
|
useMagicTray
|
|
24
27
|
};
|