@maas/vue-equipment 1.0.0-beta.17 → 1.0.0-beta.18
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 +2 -2
- package/dist/nuxt/types.d.mts +2 -6
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionContent.vue +3 -12
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionContent.vue.d.ts +1 -1
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionProvider.vue +3 -12
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionTrigger.vue +4 -16
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionTrigger.vue.d.ts +1 -1
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionView.vue +3 -12
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionView.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandDrawer.vue +1 -4
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.vue +3 -12
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandModal.vue +1 -4
- package/dist/plugins/MagicCommand/src/components/MagicCommandProvider.vue +3 -12
- package/dist/plugins/MagicCommand/src/components/MagicCommandTrigger.vue +6 -24
- package/dist/plugins/MagicCommand/src/components/MagicCommandTrigger.vue.d.ts +2 -2
- package/dist/plugins/MagicCommand/src/components/MagicCommandView.vue +2 -8
- package/dist/plugins/MagicCommand/src/components/MagicCommandView.vue.d.ts +1 -1
- package/dist/plugins/MagicCookie/src/components/MagicCookieItem.vue +3 -12
- package/dist/plugins/MagicCookie/src/components/MagicCookieItem.vue.d.ts +1 -1
- package/dist/plugins/MagicCookie/src/components/MagicCookieProvider.vue +2 -8
- package/dist/plugins/MagicCookie/src/components/MagicCookieView.vue.d.ts +1 -1
- package/dist/plugins/MagicDraggable/src/components/MagicDraggable.vue +12 -9
- package/dist/plugins/MagicDraggable/src/components/MagicDraggable.vue.d.ts +4 -4
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableDrag.mjs +38 -61
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableSnap.d.ts +2 -17
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableSnap.mjs +77 -59
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableState.mjs +2 -1
- package/dist/plugins/MagicDraggable/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue +2 -8
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue.d.ts +44 -44
- package/dist/plugins/MagicMarquee/src/components/MagicMarquee.vue +2 -8
- package/dist/plugins/MagicMenu/src/components/MagicMenuChannel.vue +2 -8
- package/dist/plugins/MagicMenu/src/components/MagicMenuContent.vue +4 -17
- package/dist/plugins/MagicMenu/src/components/MagicMenuFloat.vue +4 -16
- package/dist/plugins/MagicMenu/src/components/MagicMenuItem.vue +2 -8
- package/dist/plugins/MagicMenu/src/components/MagicMenuItem.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuProvider.vue +3 -12
- package/dist/plugins/MagicMenu/src/components/MagicMenuRemote.vue +6 -24
- package/dist/plugins/MagicMenu/src/components/MagicMenuRemote.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuTrigger.vue +5 -20
- package/dist/plugins/MagicMenu/src/components/MagicMenuTrigger.vue.d.ts +2 -2
- package/dist/plugins/MagicMenu/src/components/MagicMenuView.vue +2 -8
- package/dist/plugins/MagicMenu/src/components/MagicMenuView.vue.d.ts +1 -1
- package/dist/plugins/MagicModal/src/components/MagicModal.vue +3 -12
- package/dist/plugins/MagicModal/src/components/MagicModal.vue.d.ts +10 -10
- package/dist/plugins/MagicNoise/src/components/MagicNoise.vue +2 -8
- package/dist/plugins/MagicPie/src/components/MagicPie.vue +2 -8
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudioControls.vue +1 -4
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerDisplayTime.vue +1 -4
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerMuxPopover.vue +1 -4
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerProvider.vue +2 -8
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideoControls.vue +3 -12
- package/dist/plugins/MagicScroll/src/components/MagicScrollCollision.vue +2 -8
- package/dist/plugins/MagicScroll/src/components/MagicScrollMotion.vue +3 -12
- package/dist/plugins/MagicScroll/src/components/MagicScrollProvider.vue +1 -4
- package/dist/plugins/MagicScroll/src/components/MagicScrollProvider.vue.d.ts +1 -18
- package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue +2 -8
- package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue.d.ts +1 -1
- package/dist/plugins/MagicToast/src/components/MagicToastProvider.vue +2 -8
- package/dist/plugins/MagicToast/src/components/MagicToastView.vue +2 -8
- package/package.json +2 -2
- package/dist/nuxt/module.cjs +0 -5
- package/dist/nuxt/module.d.ts +0 -10
- package/dist/nuxt/types.d.ts +0 -7
package/dist/nuxt/module.json
CHANGED
package/dist/nuxt/types.d.mts
CHANGED
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
export { default } from './module.mjs'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
|
-
|
|
7
|
-
export { default } from './module.js'
|
|
3
|
+
export { type ModuleOptions } from './module.mjs'
|
|
@@ -39,18 +39,9 @@ import "@maas/vue-equipment/utils/css/animations/fade-in.css";
|
|
|
39
39
|
import "@maas/vue-equipment/utils/css/animations/auto-size-out.css";
|
|
40
40
|
import "@maas/vue-equipment/utils/css/easings.css";
|
|
41
41
|
const { transition, animation } = defineProps({
|
|
42
|
-
asChild: {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
},
|
|
46
|
-
transition: {
|
|
47
|
-
type: String,
|
|
48
|
-
required: false
|
|
49
|
-
},
|
|
50
|
-
animation: {
|
|
51
|
-
type: Object,
|
|
52
|
-
required: false
|
|
53
|
-
}
|
|
42
|
+
asChild: { type: Boolean, required: false },
|
|
43
|
+
transition: { type: String, required: false },
|
|
44
|
+
animation: { type: Object, required: false }
|
|
54
45
|
});
|
|
55
46
|
const instanceId = inject(MagicAccordionInstanceId, void 0);
|
|
56
47
|
const viewId = inject(MagicAccordionViewId, void 0);
|
|
@@ -21,7 +21,7 @@ declare const mappedAnimation: import("vue").ComputedRef<{
|
|
|
21
21
|
declare const onBeforeEnter: () => void, onEnter: () => void, onAfterEnter: () => Promise<void>, onBeforeLeave: () => void, onLeave: () => void, onAfterLeave: () => void;
|
|
22
22
|
declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
|
|
23
23
|
declare var __VLS_13: {
|
|
24
|
-
viewActive:
|
|
24
|
+
viewActive: any;
|
|
25
25
|
};
|
|
26
26
|
type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
|
|
27
27
|
default?: (props: typeof __VLS_13) => any;
|
|
@@ -10,18 +10,9 @@ import { Primitive } from "@maas/vue-primitive";
|
|
|
10
10
|
import { MagicAccordionInstanceId } from "../symbols";
|
|
11
11
|
import { useAccordionState } from "../composables/private/useAccordionState";
|
|
12
12
|
const { id, asChild, options } = defineProps({
|
|
13
|
-
id: {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
},
|
|
17
|
-
asChild: {
|
|
18
|
-
type: Boolean,
|
|
19
|
-
required: false
|
|
20
|
-
},
|
|
21
|
-
options: {
|
|
22
|
-
type: Object,
|
|
23
|
-
required: false
|
|
24
|
-
}
|
|
13
|
+
id: { type: null, required: true },
|
|
14
|
+
asChild: { type: Boolean, required: false },
|
|
15
|
+
options: { type: Object, required: false }
|
|
25
16
|
});
|
|
26
17
|
const { deleteState, initializeState } = useAccordionState(id);
|
|
27
18
|
initializeState(options);
|
|
@@ -27,22 +27,10 @@ const {
|
|
|
27
27
|
trigger = "click",
|
|
28
28
|
asChild = false
|
|
29
29
|
} = defineProps({
|
|
30
|
-
viewId: {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
disabled: {
|
|
35
|
-
type: null,
|
|
36
|
-
required: false
|
|
37
|
-
},
|
|
38
|
-
trigger: {
|
|
39
|
-
type: String,
|
|
40
|
-
required: false
|
|
41
|
-
},
|
|
42
|
-
asChild: {
|
|
43
|
-
type: Boolean,
|
|
44
|
-
required: false
|
|
45
|
-
}
|
|
30
|
+
viewId: { type: String, required: false },
|
|
31
|
+
disabled: { type: null, required: false },
|
|
32
|
+
trigger: { type: String, required: false },
|
|
33
|
+
asChild: { type: Boolean, required: false }
|
|
46
34
|
});
|
|
47
35
|
const elRef = useTemplateRef("el");
|
|
48
36
|
const instanceId = inject(MagicAccordionInstanceId, void 0);
|
|
@@ -13,7 +13,7 @@ declare const mappedDisabled: import("vue").ComputedRef<boolean | undefined>;
|
|
|
13
13
|
declare const onMouseenter: () => void, onClick: () => void;
|
|
14
14
|
declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
|
|
15
15
|
declare var __VLS_12: {
|
|
16
|
-
viewActive:
|
|
16
|
+
viewActive: any;
|
|
17
17
|
};
|
|
18
18
|
type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
|
|
19
19
|
default?: (props: typeof __VLS_12) => any;
|
|
@@ -19,18 +19,9 @@ import {
|
|
|
19
19
|
} from "../symbols";
|
|
20
20
|
import { useAccordionView } from "../composables/private/useAccordionView";
|
|
21
21
|
const { id, active } = defineProps({
|
|
22
|
-
id: {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
},
|
|
26
|
-
asChild: {
|
|
27
|
-
type: Boolean,
|
|
28
|
-
required: false
|
|
29
|
-
},
|
|
30
|
-
active: {
|
|
31
|
-
type: Boolean,
|
|
32
|
-
required: false
|
|
33
|
-
}
|
|
22
|
+
id: { type: String, required: false },
|
|
23
|
+
asChild: { type: Boolean, required: false },
|
|
24
|
+
active: { type: Boolean, required: false }
|
|
34
25
|
});
|
|
35
26
|
const instanceId = inject(MagicAccordionInstanceId, void 0);
|
|
36
27
|
if (!instanceId) {
|
|
@@ -8,7 +8,7 @@ declare const mappedId: import("vue").ComputedRef<string>;
|
|
|
8
8
|
declare const view: import("../types/index.js").AccordionView;
|
|
9
9
|
declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
|
|
10
10
|
declare var __VLS_6: {
|
|
11
|
-
viewActive:
|
|
11
|
+
viewActive: any;
|
|
12
12
|
};
|
|
13
13
|
type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
|
|
14
14
|
default?: (props: typeof __VLS_6) => any;
|
|
@@ -21,10 +21,7 @@ defineOptions({
|
|
|
21
21
|
inheritAttrs: false
|
|
22
22
|
});
|
|
23
23
|
defineProps({
|
|
24
|
-
options: {
|
|
25
|
-
type: null,
|
|
26
|
-
required: false
|
|
27
|
-
}
|
|
24
|
+
options: { type: null, required: false }
|
|
28
25
|
});
|
|
29
26
|
const instanceId = inject(MagicCommandInstanceId, "");
|
|
30
27
|
const emitter = useMagicEmitter();
|
|
@@ -39,18 +39,9 @@ const {
|
|
|
39
39
|
initial = false,
|
|
40
40
|
disabled = false
|
|
41
41
|
} = defineProps({
|
|
42
|
-
id: {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
},
|
|
46
|
-
initial: {
|
|
47
|
-
type: Boolean,
|
|
48
|
-
required: false
|
|
49
|
-
},
|
|
50
|
-
disabled: {
|
|
51
|
-
type: Boolean,
|
|
52
|
-
required: false
|
|
53
|
-
}
|
|
42
|
+
id: { type: String, required: false },
|
|
43
|
+
initial: { type: Boolean, required: false },
|
|
44
|
+
disabled: { type: Boolean, required: false }
|
|
54
45
|
});
|
|
55
46
|
const emit = defineEmits(["click"]);
|
|
56
47
|
const instanceId = inject(MagicCommandInstanceId, void 0);
|
|
@@ -10,7 +10,7 @@ declare function guardedSelect(): void;
|
|
|
10
10
|
declare function onClick(event: MouseEvent): void;
|
|
11
11
|
declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
|
|
12
12
|
declare var __VLS_1: {
|
|
13
|
-
itemActive:
|
|
13
|
+
itemActive: any;
|
|
14
14
|
itemDisabled: boolean;
|
|
15
15
|
};
|
|
16
16
|
type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
|
|
@@ -21,10 +21,7 @@ defineOptions({
|
|
|
21
21
|
inheritAttrs: false
|
|
22
22
|
});
|
|
23
23
|
defineProps({
|
|
24
|
-
options: {
|
|
25
|
-
type: null,
|
|
26
|
-
required: false
|
|
27
|
-
}
|
|
24
|
+
options: { type: null, required: false }
|
|
28
25
|
});
|
|
29
26
|
const instanceId = inject(MagicCommandInstanceId, "");
|
|
30
27
|
const emitter = useMagicEmitter();
|
|
@@ -14,18 +14,9 @@ import { useMagicCommand } from "../composables/useMagicCommand";
|
|
|
14
14
|
import { defaultOptions } from "../utils/defaultOptions";
|
|
15
15
|
import { MagicCommandInstanceId, MagicCommandProviderOptions } from "../symbols";
|
|
16
16
|
const { id, options = {} } = defineProps({
|
|
17
|
-
id: {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
},
|
|
21
|
-
asChild: {
|
|
22
|
-
type: Boolean,
|
|
23
|
-
required: false
|
|
24
|
-
},
|
|
25
|
-
options: {
|
|
26
|
-
type: Object,
|
|
27
|
-
required: false
|
|
28
|
-
}
|
|
17
|
+
id: { type: null, required: true },
|
|
18
|
+
asChild: { type: Boolean, required: false },
|
|
19
|
+
options: { type: Object, required: false }
|
|
29
20
|
});
|
|
30
21
|
const customDefu = createDefu((obj, key, value) => {
|
|
31
22
|
if (key === "open" || key === "close" || key === "next" || key === "prev") {
|
|
@@ -33,30 +33,12 @@ const {
|
|
|
33
33
|
action = "open",
|
|
34
34
|
trigger = ["click"]
|
|
35
35
|
} = defineProps({
|
|
36
|
-
viewId: {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
required: false
|
|
43
|
-
},
|
|
44
|
-
disabled: {
|
|
45
|
-
type: Boolean,
|
|
46
|
-
required: false
|
|
47
|
-
},
|
|
48
|
-
action: {
|
|
49
|
-
type: String,
|
|
50
|
-
required: false
|
|
51
|
-
},
|
|
52
|
-
trigger: {
|
|
53
|
-
type: Array,
|
|
54
|
-
required: false
|
|
55
|
-
},
|
|
56
|
-
asChild: {
|
|
57
|
-
type: Boolean,
|
|
58
|
-
required: false
|
|
59
|
-
}
|
|
36
|
+
viewId: { type: String, required: false },
|
|
37
|
+
active: { type: Boolean, required: false },
|
|
38
|
+
disabled: { type: Boolean, required: false },
|
|
39
|
+
action: { type: String, required: false },
|
|
40
|
+
trigger: { type: Array, required: false },
|
|
41
|
+
asChild: { type: Boolean, required: false }
|
|
60
42
|
});
|
|
61
43
|
const elRef = useTemplateRef("el");
|
|
62
44
|
const instanceId = inject(MagicCommandInstanceId, void 0);
|
|
@@ -15,8 +15,8 @@ declare const mappedDisabled: import("vue").ComputedRef<boolean>;
|
|
|
15
15
|
declare const onMouseenter: () => Promise<void>, onClick: (e: MouseEvent) => Promise<void>;
|
|
16
16
|
declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
|
|
17
17
|
declare var __VLS_12: {
|
|
18
|
-
viewActive:
|
|
19
|
-
triggerDisabled:
|
|
18
|
+
viewActive: any;
|
|
19
|
+
triggerDisabled: any;
|
|
20
20
|
};
|
|
21
21
|
type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
|
|
22
22
|
default?: (props: typeof __VLS_12) => any;
|
|
@@ -15,14 +15,8 @@ import {
|
|
|
15
15
|
MagicCommandViewActive
|
|
16
16
|
} from "../symbols";
|
|
17
17
|
const { id, initial = false } = defineProps({
|
|
18
|
-
id: {
|
|
19
|
-
|
|
20
|
-
required: false
|
|
21
|
-
},
|
|
22
|
-
initial: {
|
|
23
|
-
type: Boolean,
|
|
24
|
-
required: false
|
|
25
|
-
}
|
|
18
|
+
id: { type: String, required: false },
|
|
19
|
+
initial: { type: Boolean, required: false }
|
|
26
20
|
});
|
|
27
21
|
const parentTree = inject(MagicCommandParentTree, []);
|
|
28
22
|
const instanceId = inject(MagicCommandInstanceId, void 0);
|
|
@@ -6,7 +6,7 @@ declare const mappedId: import("vue").ComputedRef<string>;
|
|
|
6
6
|
declare const view: import("../types/index.js").CommandView;
|
|
7
7
|
declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
|
|
8
8
|
declare var __VLS_1: {
|
|
9
|
-
viewActive:
|
|
9
|
+
viewActive: any;
|
|
10
10
|
};
|
|
11
11
|
type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
|
|
12
12
|
default?: (props: typeof __VLS_1) => any;
|
|
@@ -17,18 +17,9 @@ import {
|
|
|
17
17
|
MagicCookieItemActive
|
|
18
18
|
} from "../symbols";
|
|
19
19
|
const { id, optional, maxAge } = defineProps({
|
|
20
|
-
id: {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
optional: {
|
|
25
|
-
type: Boolean,
|
|
26
|
-
required: false
|
|
27
|
-
},
|
|
28
|
-
maxAge: {
|
|
29
|
-
type: Number,
|
|
30
|
-
required: false
|
|
31
|
-
}
|
|
20
|
+
id: { type: String, required: false },
|
|
21
|
+
optional: { type: Boolean, required: false },
|
|
22
|
+
maxAge: { type: Number, required: false }
|
|
32
23
|
});
|
|
33
24
|
const instanceId = inject(MagicCookieInstanceId, void 0);
|
|
34
25
|
if (!instanceId) {
|
|
@@ -6,7 +6,7 @@ interface MagicCookieItemProps {
|
|
|
6
6
|
declare const item: import("../types/index.js").CookieItem;
|
|
7
7
|
declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
|
|
8
8
|
declare var __VLS_1: {
|
|
9
|
-
item:
|
|
9
|
+
item: any;
|
|
10
10
|
};
|
|
11
11
|
type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
|
|
12
12
|
default?: (props: typeof __VLS_1) => any;
|
|
@@ -16,14 +16,8 @@ defineOptions({
|
|
|
16
16
|
inheritAttrs: false
|
|
17
17
|
});
|
|
18
18
|
const { id, options } = defineProps({
|
|
19
|
-
id: {
|
|
20
|
-
|
|
21
|
-
required: true
|
|
22
|
-
},
|
|
23
|
-
options: {
|
|
24
|
-
type: Object,
|
|
25
|
-
required: false
|
|
26
|
-
}
|
|
19
|
+
id: { type: null, required: true },
|
|
20
|
+
options: { type: Object, required: false }
|
|
27
21
|
});
|
|
28
22
|
const mappedOptions = defu(options, defaultOptions);
|
|
29
23
|
const { initializeState } = useCookieState(id);
|
|
@@ -5,7 +5,7 @@ declare const state: import("../types/index.js").CookieState;
|
|
|
5
5
|
declare const onBeforeEnter: () => void, onEnter: () => void, onAfterEnter: () => Promise<void>, onBeforeLeave: () => void, onLeave: () => void, onAfterLeave: () => void;
|
|
6
6
|
declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
|
|
7
7
|
declare var __VLS_18: {
|
|
8
|
-
viewActive:
|
|
8
|
+
viewActive: any;
|
|
9
9
|
};
|
|
10
10
|
type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
|
|
11
11
|
default?: (props: typeof __VLS_18) => any;
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
<script setup>
|
|
26
26
|
import { useTemplateRef, computed, toValue, toRefs } from "vue";
|
|
27
|
-
import {
|
|
27
|
+
import { createDefu } from "defu";
|
|
28
28
|
import { useDraggableDrag } from "../composables/private/useDraggableDrag";
|
|
29
29
|
import { useDraggableState } from "../composables/private/useDraggableState";
|
|
30
30
|
import { defaultOptions } from "../utils/defaultOptions";
|
|
@@ -32,17 +32,20 @@ defineOptions({
|
|
|
32
32
|
inheritAttrs: false
|
|
33
33
|
});
|
|
34
34
|
const { id, options = {} } = defineProps({
|
|
35
|
-
id: {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
35
|
+
id: { type: null, required: true },
|
|
36
|
+
options: { type: Object, required: false }
|
|
37
|
+
});
|
|
38
|
+
const customDefu = createDefu((obj, key, value) => {
|
|
39
|
+
if (key === "snapPoints") {
|
|
40
|
+
obj[key] = value;
|
|
41
|
+
return true;
|
|
42
42
|
}
|
|
43
43
|
});
|
|
44
|
-
const mappedOptions =
|
|
44
|
+
const mappedOptions = customDefu(options, defaultOptions);
|
|
45
45
|
const mappedId = toValue(id);
|
|
46
|
+
if (!mappedOptions.snapPoints.length) {
|
|
47
|
+
throw new Error("MagicDraggable must have at least one snap point set");
|
|
48
|
+
}
|
|
46
49
|
const elRef = useTemplateRef("el");
|
|
47
50
|
const wrapperRef = useTemplateRef("wrapper");
|
|
48
51
|
const { initializeState } = useDraggableState(id);
|
|
@@ -36,10 +36,6 @@ declare const mappedOptions: Omit<MagicDraggableOptions, keyof MagicDraggableOpt
|
|
|
36
36
|
momentum: number;
|
|
37
37
|
idle: number;
|
|
38
38
|
});
|
|
39
|
-
tag: "dialog" | "div";
|
|
40
|
-
scrollLock: boolean | {
|
|
41
|
-
padding: boolean;
|
|
42
|
-
};
|
|
43
39
|
disabled: boolean;
|
|
44
40
|
animation: ({
|
|
45
41
|
snap?: {
|
|
@@ -72,6 +68,10 @@ declare const mappedOptions: Omit<MagicDraggableOptions, keyof MagicDraggableOpt
|
|
|
72
68
|
easing?: (t: number) => number;
|
|
73
69
|
};
|
|
74
70
|
});
|
|
71
|
+
scrollLock: boolean | {
|
|
72
|
+
padding: boolean;
|
|
73
|
+
};
|
|
74
|
+
tag: "div" | "dialog";
|
|
75
75
|
snapPoints: import("../types/index.js").DraggableSnapPoint[];
|
|
76
76
|
initial: {
|
|
77
77
|
snapPoint?: import("../types/index.js").DraggableSnapPoint;
|
|
@@ -53,7 +53,8 @@ export function useDraggableDrag(args) {
|
|
|
53
53
|
draggedX,
|
|
54
54
|
draggedY,
|
|
55
55
|
elRect,
|
|
56
|
-
wrapperRect
|
|
56
|
+
wrapperRect,
|
|
57
|
+
activeSnapPoint
|
|
57
58
|
} = toRefs(state);
|
|
58
59
|
let cancelPointerup = void 0;
|
|
59
60
|
let cancelPointermove = void 0;
|
|
@@ -78,21 +79,15 @@ export function useDraggableDrag(args) {
|
|
|
78
79
|
});
|
|
79
80
|
const {
|
|
80
81
|
snapTo,
|
|
81
|
-
|
|
82
|
+
mappedActiveSnapPoint,
|
|
82
83
|
mapSnapPoint,
|
|
83
84
|
mappedSnapPoints,
|
|
84
85
|
snapPointsMap,
|
|
85
86
|
interpolateDragged
|
|
86
87
|
} = useDraggableSnap({
|
|
87
88
|
id,
|
|
88
|
-
elRect,
|
|
89
|
-
wrapperRect,
|
|
90
89
|
animation,
|
|
91
|
-
snapPoints
|
|
92
|
-
draggedX,
|
|
93
|
-
draggedY,
|
|
94
|
-
lastDraggedX,
|
|
95
|
-
lastDraggedY
|
|
90
|
+
snapPoints
|
|
96
91
|
});
|
|
97
92
|
const emitter = useMagicEmitter();
|
|
98
93
|
const {
|
|
@@ -101,10 +96,9 @@ export function useDraggableDrag(args) {
|
|
|
101
96
|
addScrollLockPadding,
|
|
102
97
|
removeScrollLockPadding
|
|
103
98
|
} = useDraggableScrollLock();
|
|
104
|
-
|
|
99
|
+
function getSizes() {
|
|
105
100
|
elRect.value = unrefElement(elRef)?.getBoundingClientRect();
|
|
106
101
|
wrapperRect.value = unrefElement(wrapperRef)?.getBoundingClientRect();
|
|
107
|
-
await nextTick();
|
|
108
102
|
}
|
|
109
103
|
function setDragged({ x, y }) {
|
|
110
104
|
draggedX.value = x - originX.value;
|
|
@@ -128,33 +122,18 @@ export function useDraggableDrag(args) {
|
|
|
128
122
|
});
|
|
129
123
|
}
|
|
130
124
|
}
|
|
131
|
-
function
|
|
125
|
+
async function checkSizes() {
|
|
126
|
+
getSizes();
|
|
132
127
|
const childRect = toValue(elRect);
|
|
133
128
|
const parentRect = toValue(wrapperRect);
|
|
134
129
|
if (!childRect || !parentRect) {
|
|
130
|
+
console.warn("MagicDraggable could not calculate sizing");
|
|
135
131
|
return;
|
|
136
132
|
}
|
|
137
133
|
if (childRect.width > parentRect.width || childRect.height > parentRect.height) {
|
|
138
134
|
console.warn("MagicDraggable is too small for its content");
|
|
139
135
|
return;
|
|
140
136
|
}
|
|
141
|
-
interpolateTo.value = { x: draggedX.value, y: draggedY.value };
|
|
142
|
-
if (childRect.top < parentRect.top) {
|
|
143
|
-
interpolateTo.value = { x: interpolateTo.value?.x, y: 0 };
|
|
144
|
-
} else if (childRect.bottom > parentRect.bottom) {
|
|
145
|
-
interpolateTo.value = {
|
|
146
|
-
x: interpolateTo.value?.x,
|
|
147
|
-
y: parentRect.height - childRect.height
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
if (childRect.left < parentRect.left) {
|
|
151
|
-
interpolateTo.value = { x: 0, y: interpolateTo.value?.y };
|
|
152
|
-
} else if (childRect.right > parentRect.right) {
|
|
153
|
-
interpolateTo.value = {
|
|
154
|
-
x: parentRect.width - childRect.width,
|
|
155
|
-
y: interpolateTo.value?.y
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
137
|
}
|
|
159
138
|
function vectorBetweenCoordinates(a, b) {
|
|
160
139
|
const dx = b.x - a.x;
|
|
@@ -255,9 +234,18 @@ export function useDraggableDrag(args) {
|
|
|
255
234
|
const draggedCoords = { x: draggedX.value, y: draggedY.value };
|
|
256
235
|
const closestSnapPoint = mappedSnapPoints.value.reduce((a, b) => {
|
|
257
236
|
return calculateDistance(a, draggedCoords) < calculateDistance(b, draggedCoords) ? a : b;
|
|
258
|
-
});
|
|
237
|
+
}, mappedSnapPoints.value[0]);
|
|
259
238
|
return closestSnapPoint;
|
|
260
239
|
}
|
|
240
|
+
function onIdle() {
|
|
241
|
+
interpolateTo.value = findClosestSnapPoint();
|
|
242
|
+
if (distanceThresholdReached.value && momentumThresholdReached.value) {
|
|
243
|
+
intermediateDraggedX.value = draggedX.value;
|
|
244
|
+
intermediateDraggedY.value = draggedY.value;
|
|
245
|
+
distanceThresholdReached.value = false;
|
|
246
|
+
momentumThresholdReached.value = false;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
261
249
|
function onPointerup(e) {
|
|
262
250
|
if (!momentumThresholdReached.value && distanceThresholdReached.value) {
|
|
263
251
|
interpolateTo.value = findClosestSnapPoint();
|
|
@@ -265,9 +253,7 @@ export function useDraggableDrag(args) {
|
|
|
265
253
|
const { x, y } = interpolateTo.value || {};
|
|
266
254
|
if (x !== void 0 && y !== void 0) {
|
|
267
255
|
interpolateDragged({ x, y });
|
|
268
|
-
|
|
269
|
-
if (interpolateTo.value) {
|
|
270
|
-
const key = `x${interpolateTo.value.x}y${interpolateTo.value.y}`;
|
|
256
|
+
const key = `x${x}y${y}`;
|
|
271
257
|
activeSnapPoint.value = snapPointsMap.value[key];
|
|
272
258
|
}
|
|
273
259
|
if (intermediateDraggedX.value === draggedX.value && intermediateDraggedY.value === draggedY.value) {
|
|
@@ -293,13 +279,11 @@ export function useDraggableDrag(args) {
|
|
|
293
279
|
}
|
|
294
280
|
guardedReleasePointerCapture({ event: e, element: elRef.value });
|
|
295
281
|
}
|
|
296
|
-
function onPointermove(e) {
|
|
282
|
+
async function onPointermove(e) {
|
|
297
283
|
if (!e.isPrimary) {
|
|
298
284
|
return;
|
|
299
285
|
}
|
|
300
286
|
setDragged({ x: e.screenX, y: e.screenY });
|
|
301
|
-
getSizes();
|
|
302
|
-
detectCollision();
|
|
303
287
|
if (!distanceThresholdReached.value) {
|
|
304
288
|
checkDistance();
|
|
305
289
|
}
|
|
@@ -307,27 +291,20 @@ export function useDraggableDrag(args) {
|
|
|
307
291
|
checkMomentum();
|
|
308
292
|
}
|
|
309
293
|
if (!distanceThresholdReached.value && !momentumThresholdReached.value) {
|
|
310
|
-
|
|
294
|
+
const { x, y } = mappedActiveSnapPoint.value ?? {};
|
|
295
|
+
if (x !== void 0 && y !== void 0) {
|
|
296
|
+
interpolateTo.value = { x, y };
|
|
297
|
+
console.log("G", interpolateTo.value);
|
|
298
|
+
}
|
|
311
299
|
return;
|
|
312
300
|
}
|
|
313
|
-
|
|
314
|
-
findSnapPointByVector();
|
|
315
|
-
}
|
|
301
|
+
findSnapPointByVector();
|
|
316
302
|
emitter.emit("drag", {
|
|
317
303
|
id: toValue(id),
|
|
318
304
|
x: draggedX.value,
|
|
319
305
|
y: draggedY.value
|
|
320
306
|
});
|
|
321
307
|
}
|
|
322
|
-
function onIdle() {
|
|
323
|
-
interpolateTo.value = findClosestSnapPoint();
|
|
324
|
-
if (distanceThresholdReached.value && momentumThresholdReached.value) {
|
|
325
|
-
intermediateDraggedX.value = draggedX.value;
|
|
326
|
-
intermediateDraggedY.value = draggedY.value;
|
|
327
|
-
distanceThresholdReached.value = false;
|
|
328
|
-
momentumThresholdReached.value = false;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
308
|
function onPointerdown(e) {
|
|
332
309
|
const scrollLockValue = toValue(scrollLock);
|
|
333
310
|
if (scrollLockValue) {
|
|
@@ -338,19 +315,21 @@ export function useDraggableDrag(args) {
|
|
|
338
315
|
}
|
|
339
316
|
if (dragging.value) {
|
|
340
317
|
return;
|
|
341
|
-
} else {
|
|
342
|
-
guardedSetPointerCapture({ event: e, element: elRef.value });
|
|
343
|
-
dragging.value = true;
|
|
344
|
-
emitter.emit("beforeDrag", {
|
|
345
|
-
id: toValue(id),
|
|
346
|
-
x: draggedX.value,
|
|
347
|
-
y: draggedY.value
|
|
348
|
-
});
|
|
349
318
|
}
|
|
319
|
+
checkSizes();
|
|
320
|
+
guardedSetPointerCapture({ event: e, element: elRef.value });
|
|
321
|
+
dragging.value = true;
|
|
322
|
+
emitter.emit("beforeDrag", {
|
|
323
|
+
id: toValue(id),
|
|
324
|
+
x: draggedX.value,
|
|
325
|
+
y: draggedY.value
|
|
326
|
+
});
|
|
350
327
|
intermediateDraggedX.value = draggedX.value;
|
|
351
328
|
intermediateDraggedY.value = draggedY.value;
|
|
352
329
|
lastDraggedX.value = draggedX.value;
|
|
353
330
|
lastDraggedY.value = draggedY.value;
|
|
331
|
+
originX.value = e.screenX - draggedX.value;
|
|
332
|
+
originY.value = e.screenY - draggedY.value;
|
|
354
333
|
cancelPointerup = useEventListener(document, "pointerup", onPointerup);
|
|
355
334
|
cancelPointermove = useEventListener(
|
|
356
335
|
document,
|
|
@@ -359,8 +338,6 @@ export function useDraggableDrag(args) {
|
|
|
359
338
|
{ passive: false }
|
|
360
339
|
);
|
|
361
340
|
cancelTouchend = isIOS() ? useEventListener(document, "touchend", onPointerup) : void 0;
|
|
362
|
-
originX.value = e.screenX - draggedX.value;
|
|
363
|
-
originY.value = e.screenY - draggedY.value;
|
|
364
341
|
dragStart.value = /* @__PURE__ */ new Date();
|
|
365
342
|
onPointermove(e);
|
|
366
343
|
}
|
|
@@ -396,7 +373,7 @@ export function useDraggableDrag(args) {
|
|
|
396
373
|
});
|
|
397
374
|
useResizeObserver(wrapperRef, async () => {
|
|
398
375
|
useThrottleFn(async () => {
|
|
399
|
-
|
|
376
|
+
getSizes();
|
|
400
377
|
if (activeSnapPoint.value) {
|
|
401
378
|
await snapTo({ snapPoint: activeSnapPoint.value, interpolate: false });
|
|
402
379
|
snapPointsMap.trigger();
|
|
@@ -406,7 +383,7 @@ export function useDraggableDrag(args) {
|
|
|
406
383
|
});
|
|
407
384
|
useResizeObserver(elRef, async () => {
|
|
408
385
|
useThrottleFn(async () => {
|
|
409
|
-
|
|
386
|
+
getSizes();
|
|
410
387
|
if (activeSnapPoint.value) {
|
|
411
388
|
await snapTo({ snapPoint: activeSnapPoint.value, interpolate: false });
|
|
412
389
|
snapPointsMap.trigger();
|