@maas/vue-equipment 1.0.0-beta.58 → 1.0.0-beta.59
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/README.md +1 -1
- package/dist/nuxt/module.json +1 -1
- package/dist/nuxt/module.mjs +6 -2
- package/dist/plugins/MagicAccordion/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicAccordion/src/utils/defaultOptions.d.ts +2 -3
- package/dist/plugins/MagicCommand/src/components/MagicCommandProvider.vue +6 -15
- package/dist/plugins/MagicCommand/src/composables/private/useCommandState.mjs +8 -2
- package/dist/plugins/MagicCommand/src/types/index.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/utils/defaultOptions.d.ts +2 -2
- package/dist/plugins/MagicCookie/src/components/MagicCookieProvider.vue +1 -4
- package/dist/plugins/MagicCookie/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicCookie/src/utils/defaultOptions.d.ts +2 -3
- package/dist/plugins/MagicDraggable/src/components/MagicDraggable.vue +7 -15
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableDrag.d.ts +6 -6
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableSnap.d.ts +3 -3
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableState.d.ts +2 -2
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableState.mjs +15 -2
- package/dist/plugins/MagicDraggable/src/types/index.d.ts +4 -4
- package/dist/plugins/MagicDraggable/src/utils/defaultOptions.d.ts +2 -2
- package/dist/plugins/MagicDrawer/index.d.ts +6 -1
- package/dist/plugins/MagicDrawer/index.mjs +20 -1
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.d.vue.ts +3 -13
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue +19 -487
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue.d.ts +3 -13
- package/dist/plugins/MagicDrawer/src/components/MagicDrawerBackdrop.d.vue.ts +15 -0
- package/dist/plugins/MagicDrawer/src/components/MagicDrawerBackdrop.vue +76 -0
- package/dist/plugins/MagicDrawer/src/components/MagicDrawerBackdrop.vue.d.ts +15 -0
- package/dist/plugins/MagicDrawer/src/components/MagicDrawerContent.d.vue.ts +23 -0
- package/dist/plugins/MagicDrawer/src/components/MagicDrawerContent.vue +410 -0
- package/dist/plugins/MagicDrawer/src/components/MagicDrawerContent.vue.d.ts +23 -0
- package/dist/plugins/MagicDrawer/src/components/MagicDrawerProvider.d.vue.ts +19 -0
- package/dist/plugins/MagicDrawer/src/components/MagicDrawerProvider.vue +67 -0
- package/dist/plugins/MagicDrawer/src/components/MagicDrawerProvider.vue.d.ts +19 -0
- package/dist/plugins/MagicDrawer/src/components/MagicDrawerTeleport.d.vue.ts +20 -0
- package/dist/plugins/MagicDrawer/src/components/MagicDrawerTeleport.vue +36 -0
- package/dist/plugins/MagicDrawer/src/components/MagicDrawerTeleport.vue.d.ts +20 -0
- package/dist/plugins/MagicDrawer/src/components/MagicDrawerTrigger.d.vue.ts +22 -0
- package/dist/plugins/MagicDrawer/src/components/MagicDrawerTrigger.vue +62 -0
- package/dist/plugins/MagicDrawer/src/components/MagicDrawerTrigger.vue.d.ts +22 -0
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerCallback.d.ts +3 -2
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerCallback.mjs +11 -11
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDOM.mjs +1 -1
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDrag.d.ts +7 -7
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerGuards.d.ts +2 -2
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerProgress.d.ts +2 -2
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerSnap.d.ts +5 -5
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.d.ts +2 -2
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.mjs +15 -5
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerWheel.d.ts +2 -2
- package/dist/plugins/MagicDrawer/src/composables/useMagicDrawer.d.ts +3 -2
- package/dist/plugins/MagicDrawer/src/composables/useMagicDrawer.mjs +3 -2
- package/dist/plugins/MagicDrawer/src/symbols/index.d.ts +7 -0
- package/dist/plugins/MagicDrawer/src/symbols/index.mjs +3 -0
- package/dist/plugins/MagicDrawer/src/types/index.d.ts +6 -6
- package/dist/plugins/MagicDrawer/src/utils/defaultOptions.d.ts +2 -2
- package/dist/plugins/MagicEmitter/src/composables/useMagicEmitter.d.ts +36 -36
- package/dist/plugins/MagicMarquee/src/utils/defaultOptions.d.ts +1 -2
- package/dist/plugins/MagicMenu/src/components/MagicMenuProvider.vue +1 -4
- package/dist/plugins/MagicModal/index.d.ts +8 -3
- package/dist/plugins/MagicModal/index.mjs +20 -1
- package/dist/plugins/MagicModal/src/components/MagicModal.d.vue.ts +4 -7
- package/dist/plugins/MagicModal/src/components/MagicModal.vue +21 -253
- package/dist/plugins/MagicModal/src/components/MagicModal.vue.d.ts +4 -7
- package/dist/plugins/MagicModal/src/components/MagicModalBackdrop.d.vue.ts +15 -0
- package/dist/plugins/MagicModal/src/components/MagicModalBackdrop.vue +66 -0
- package/dist/plugins/MagicModal/src/components/MagicModalBackdrop.vue.d.ts +15 -0
- package/dist/plugins/MagicModal/src/components/MagicModalContent.d.vue.ts +15 -0
- package/dist/plugins/MagicModal/src/components/MagicModalContent.vue +176 -0
- package/dist/plugins/MagicModal/src/components/MagicModalContent.vue.d.ts +15 -0
- package/dist/plugins/MagicModal/src/components/MagicModalProvider.d.vue.ts +19 -0
- package/dist/plugins/MagicModal/src/components/MagicModalProvider.vue +58 -0
- package/dist/plugins/MagicModal/src/components/MagicModalProvider.vue.d.ts +19 -0
- package/dist/plugins/MagicModal/src/components/MagicModalTeleport.d.vue.ts +20 -0
- package/dist/plugins/MagicModal/src/components/MagicModalTeleport.vue +36 -0
- package/dist/plugins/MagicModal/src/components/MagicModalTeleport.vue.d.ts +20 -0
- package/dist/plugins/MagicModal/src/components/MagicModalTrigger.d.vue.ts +22 -0
- package/dist/plugins/MagicModal/src/components/MagicModalTrigger.vue +59 -0
- package/dist/plugins/MagicModal/src/components/MagicModalTrigger.vue.d.ts +22 -0
- package/dist/plugins/MagicModal/src/composables/private/useModalCallback.d.ts +4 -3
- package/dist/plugins/MagicModal/src/composables/private/useModalCallback.mjs +8 -8
- package/dist/plugins/MagicModal/src/composables/private/useModalDOM.mjs +1 -1
- package/dist/plugins/MagicModal/src/composables/private/useModalState.d.ts +2 -2
- package/dist/plugins/MagicModal/src/composables/private/useModalState.mjs +15 -2
- package/dist/plugins/MagicModal/src/composables/useMagicModal.d.ts +4 -1
- package/dist/plugins/MagicModal/src/composables/useMagicModal.mjs +5 -4
- package/dist/plugins/MagicModal/src/symbols/index.d.ts +8 -0
- package/dist/plugins/MagicModal/src/symbols/index.mjs +3 -0
- package/dist/plugins/MagicModal/src/types/index.d.ts +6 -0
- package/dist/plugins/MagicModal/src/utils/defaultOptions.d.ts +2 -3
- package/dist/plugins/MagicNoise/src/utils/defaultOptions.d.ts +1 -2
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerProvider.vue +4 -7
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerState.d.ts +2 -2
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerState.mjs +9 -2
- package/dist/plugins/MagicPlayer/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicToast/src/types/index.d.ts +5 -6
- package/dist/plugins/MagicToast/src/utils/defaultOptions.d.ts +2 -2
- package/dist/utils/index.d.ts +1 -5
- package/dist/utils/types/index.ts +0 -1
- package/package.json +4 -2
- package/dist/utils/types/RequireAll.ts +0 -3
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ For the full documentation visit [vue.equipment](https://vue.equipment). We are
|
|
|
17
17
|
|
|
18
18
|
## 🐛 Found a Bug?
|
|
19
19
|
|
|
20
|
-
> If you see something that doesn
|
|
20
|
+
> If you see something that doesn’t look right, [submit a bug report](https://github.com/magicasaservice/vue-equipment/issues/new?assignees=&labels=bug%2Cpending+triage&template=bug_report.yml). See it. Say it. Sorted.
|
|
21
21
|
|
|
22
22
|
## 📄 License
|
|
23
23
|
|
package/dist/nuxt/module.json
CHANGED
package/dist/nuxt/module.mjs
CHANGED
|
@@ -145,8 +145,12 @@ const functions$1 = [
|
|
|
145
145
|
|
|
146
146
|
const functions = functions$1;
|
|
147
147
|
functions.map((f) => f.name);
|
|
148
|
-
const plugins = functions.filter(
|
|
149
|
-
|
|
148
|
+
const plugins = functions.filter(
|
|
149
|
+
(p) => p.package === "plugins" && !p.internal
|
|
150
|
+
);
|
|
151
|
+
const composables = functions.filter(
|
|
152
|
+
(p) => p.package === "composables" && !p.internal
|
|
153
|
+
);
|
|
150
154
|
|
|
151
155
|
const module$1 = defineNuxtModule({
|
|
152
156
|
meta: {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
declare const defaultOptions: RequireAll<MagicAccordionOptions>;
|
|
1
|
+
import type { RequiredMagicAccordionOptions } from '../types/index.js';
|
|
2
|
+
declare const defaultOptions: RequiredMagicAccordionOptions;
|
|
4
3
|
export { defaultOptions };
|
|
@@ -13,25 +13,16 @@ import { shallowRef, provide, watch } from "vue";
|
|
|
13
13
|
import { useMagicKeys, usePointer } from "@vueuse/core";
|
|
14
14
|
import { VuePrimitive } from "@maas/vue-primitive";
|
|
15
15
|
import { useMagicError } from "@maas/vue-equipment/plugins/MagicError";
|
|
16
|
-
import { createDefu } from "defu";
|
|
17
16
|
import { useCommandState } from "../composables/private/useCommandState";
|
|
18
17
|
import { useMagicCommand } from "../composables/useMagicCommand";
|
|
19
|
-
import { defaultOptions } from "../utils/defaultOptions";
|
|
20
18
|
import { MagicCommandInstanceId, MagicCommandProviderOptions } from "../symbols";
|
|
21
19
|
const { id, options = {} } = defineProps({
|
|
22
20
|
id: { type: null, required: true },
|
|
23
21
|
asChild: { type: Boolean, required: false },
|
|
24
22
|
options: { type: Object, required: false }
|
|
25
23
|
});
|
|
26
|
-
const customDefu = createDefu((obj, key, value) => {
|
|
27
|
-
if (key === "open" || key === "close" || key === "next" || key === "prev") {
|
|
28
|
-
obj[key] = value;
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
const mappedOptions = customDefu(options, defaultOptions);
|
|
33
24
|
const { initializeState } = useCommandState(id);
|
|
34
|
-
const state = initializeState(
|
|
25
|
+
const state = initializeState(options);
|
|
35
26
|
const lastX = shallowRef(0);
|
|
36
27
|
const lastY = shallowRef(0);
|
|
37
28
|
const { x, y } = usePointer();
|
|
@@ -58,8 +49,8 @@ const { logWarning } = useMagicError({
|
|
|
58
49
|
prefix: "MagicCommand",
|
|
59
50
|
source: "MagicCommandProvider"
|
|
60
51
|
});
|
|
61
|
-
if (
|
|
62
|
-
for (const key of
|
|
52
|
+
if (state.options.keyListener?.open) {
|
|
53
|
+
for (const key of state.options.keyListener.open) {
|
|
63
54
|
const mappedKey = keys[key];
|
|
64
55
|
if (!mappedKey) {
|
|
65
56
|
logWarning(`The key \u201C${key}\u201D is not supported by MagicCommand`);
|
|
@@ -72,8 +63,8 @@ if (mappedOptions.keyListener?.open) {
|
|
|
72
63
|
});
|
|
73
64
|
}
|
|
74
65
|
}
|
|
75
|
-
if (
|
|
76
|
-
for (const key of
|
|
66
|
+
if (state.options.keyListener?.close) {
|
|
67
|
+
for (const key of state.options.keyListener.close) {
|
|
77
68
|
const mappedKey = keys[key];
|
|
78
69
|
if (!mappedKey) {
|
|
79
70
|
logWarning(`The key \u201C${key}\u201D is not supported by MagicCommand`);
|
|
@@ -87,7 +78,7 @@ if (mappedOptions.keyListener?.close) {
|
|
|
87
78
|
}
|
|
88
79
|
}
|
|
89
80
|
provide(MagicCommandInstanceId, id);
|
|
90
|
-
provide(MagicCommandProviderOptions,
|
|
81
|
+
provide(MagicCommandProviderOptions, state.options);
|
|
91
82
|
</script>
|
|
92
83
|
|
|
93
84
|
<style>
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { reactive, toValue, onScopeDispose } from "vue";
|
|
2
|
-
import {
|
|
2
|
+
import { createDefu } from "defu";
|
|
3
3
|
import { createStateStore } from "@maas/vue-equipment/utils";
|
|
4
4
|
import { defaultOptions } from "../../utils/defaultOptions.mjs";
|
|
5
5
|
const getCommandStateStore = createStateStore(
|
|
@@ -9,6 +9,12 @@ const getCommandStateStore = createStateStore(
|
|
|
9
9
|
export function useCommandState(instanceId) {
|
|
10
10
|
const commandStateStore = getCommandStateStore();
|
|
11
11
|
let scopeCounted = false;
|
|
12
|
+
const customDefu = createDefu((obj, key, value) => {
|
|
13
|
+
if (key === "open" || key === "close" || key === "next" || key === "prev") {
|
|
14
|
+
obj[key] = value;
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
12
18
|
function createState(id) {
|
|
13
19
|
const view = commandStateStore.value.find((state2) => state2.id === id)?.views.findLast((view2) => view2.active)?.id;
|
|
14
20
|
const state = {
|
|
@@ -47,7 +53,7 @@ export function useCommandState(instanceId) {
|
|
|
47
53
|
scopeCounted = true;
|
|
48
54
|
}
|
|
49
55
|
if (options) {
|
|
50
|
-
const mappedOptions =
|
|
56
|
+
const mappedOptions = customDefu(options, defaultOptions);
|
|
51
57
|
state.options = mappedOptions;
|
|
52
58
|
}
|
|
53
59
|
return state;
|
|
@@ -15,7 +15,7 @@ export interface MagicCommandOptions {
|
|
|
15
15
|
};
|
|
16
16
|
loop?: boolean;
|
|
17
17
|
}
|
|
18
|
-
export type
|
|
18
|
+
export type RequiredMagicCommandOptions = RequireAllNested<MagicCommandOptions>;
|
|
19
19
|
export type Action = 'open' | 'close';
|
|
20
20
|
export type Interaction = 'click' | 'mouseenter';
|
|
21
21
|
export interface CommandItem {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
declare const defaultOptions:
|
|
1
|
+
import type { RequiredMagicCommandOptions } from '../types/index.js';
|
|
2
|
+
declare const defaultOptions: RequiredMagicCommandOptions;
|
|
3
3
|
export { defaultOptions };
|
|
@@ -6,16 +6,13 @@
|
|
|
6
6
|
|
|
7
7
|
<script setup>
|
|
8
8
|
import { provide } from "vue";
|
|
9
|
-
import { defu } from "defu";
|
|
10
9
|
import { useCookieState } from "../composables/private/useCookieState";
|
|
11
|
-
import { defaultOptions } from "../utils/defaultOptions";
|
|
12
10
|
import { MagicCookieInstanceId } from "../symbols";
|
|
13
11
|
const { id, options } = defineProps({
|
|
14
12
|
id: { type: null, required: true },
|
|
15
13
|
options: { type: Object, required: false }
|
|
16
14
|
});
|
|
17
|
-
const mappedOptions = defu(options, defaultOptions);
|
|
18
15
|
const { initializeState } = useCookieState(id);
|
|
19
|
-
initializeState(
|
|
16
|
+
initializeState(options);
|
|
20
17
|
provide(MagicCookieInstanceId, id);
|
|
21
18
|
</script>
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
declare const defaultOptions: RequireAll<MagicCookieOptions>;
|
|
1
|
+
import type { RequiredMagicCookieOptions } from '../types/index.js';
|
|
2
|
+
declare const defaultOptions: RequiredMagicCookieOptions;
|
|
4
3
|
export { defaultOptions };
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
>
|
|
10
10
|
<div ref="wrapper" class="magic-draggable__wrapper">
|
|
11
11
|
<component
|
|
12
|
-
:is="
|
|
12
|
+
:is="state.options.tag"
|
|
13
13
|
ref="el"
|
|
14
14
|
class="magic-draggable__drag"
|
|
15
15
|
:style="style"
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
|
|
26
26
|
<script setup>
|
|
27
27
|
import { useTemplateRef, computed, toValue, toRefs } from "vue";
|
|
28
|
-
import { createDefu } from "defu";
|
|
29
28
|
import {
|
|
30
29
|
useMagicError
|
|
31
30
|
} from "@maas/vue-equipment/plugins/MagicError";
|
|
@@ -43,24 +42,17 @@ const magicError = useMagicError({
|
|
|
43
42
|
prefix: "MagicDraggable",
|
|
44
43
|
source: "MagicDraggable"
|
|
45
44
|
});
|
|
46
|
-
const customDefu = createDefu((obj, key, value) => {
|
|
47
|
-
if (key === "snapPoints") {
|
|
48
|
-
obj[key] = value;
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
const mappedOptions = customDefu(options, defaultOptions);
|
|
53
45
|
const mappedId = toValue(id);
|
|
54
|
-
|
|
46
|
+
const elRef = useTemplateRef("el");
|
|
47
|
+
const wrapperRef = useTemplateRef("wrapper");
|
|
48
|
+
const { initializeState } = useDraggableState(id);
|
|
49
|
+
const state = initializeState(options);
|
|
50
|
+
if (!state.options.snapPoints.length) {
|
|
55
51
|
magicError.throwError({
|
|
56
52
|
message: "MagicDraggable must have at least one snap point set",
|
|
57
53
|
errorCode: "missing_snap_point"
|
|
58
54
|
});
|
|
59
55
|
}
|
|
60
|
-
const elRef = useTemplateRef("el");
|
|
61
|
-
const wrapperRef = useTemplateRef("wrapper");
|
|
62
|
-
const { initializeState } = useDraggableState(id);
|
|
63
|
-
const state = initializeState();
|
|
64
56
|
const { dragging, activeSnapPoint } = toRefs(state);
|
|
65
57
|
const disabled = computed(() => {
|
|
66
58
|
if (options.disabled === void 0) {
|
|
@@ -69,7 +61,7 @@ const disabled = computed(() => {
|
|
|
69
61
|
return options.disabled;
|
|
70
62
|
}
|
|
71
63
|
});
|
|
72
|
-
const { snapPoints, animation, initial, threshold, scrollLock } =
|
|
64
|
+
const { snapPoints, animation, initial, threshold, scrollLock } = state.options;
|
|
73
65
|
const { onPointerdown, onClick, style, hasDragged } = useDraggableDrag({
|
|
74
66
|
id,
|
|
75
67
|
elRef,
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { type Ref, type MaybeRef } from 'vue';
|
|
2
|
-
import type {
|
|
2
|
+
import type { RequiredMagicDraggableOptions } from '../../types/index.js';
|
|
3
3
|
type UseDraggableDragArgs = {
|
|
4
4
|
id: MaybeRef<string>;
|
|
5
5
|
elRef: Ref<HTMLElement | null>;
|
|
6
6
|
wrapperRef: Ref<HTMLDivElement | null>;
|
|
7
|
-
threshold: MaybeRef<
|
|
8
|
-
snapPoints: MaybeRef<
|
|
9
|
-
animation: MaybeRef<
|
|
10
|
-
initial: MaybeRef<
|
|
11
|
-
scrollLock: MaybeRef<
|
|
7
|
+
threshold: MaybeRef<RequiredMagicDraggableOptions['threshold']>;
|
|
8
|
+
snapPoints: MaybeRef<RequiredMagicDraggableOptions['snapPoints']>;
|
|
9
|
+
animation: MaybeRef<RequiredMagicDraggableOptions['animation']>;
|
|
10
|
+
initial: MaybeRef<RequiredMagicDraggableOptions['initial']>;
|
|
11
|
+
scrollLock: MaybeRef<RequiredMagicDraggableOptions['scrollLock']>;
|
|
12
12
|
};
|
|
13
13
|
export declare function useDraggableDrag(args: UseDraggableDragArgs): {
|
|
14
14
|
initialize: () => Promise<void>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type MaybeRef } from 'vue';
|
|
2
|
-
import type { DraggableSnapPoint, Coordinates,
|
|
2
|
+
import type { DraggableSnapPoint, Coordinates, RequiredMagicDraggableOptions } from '../../types/index.js';
|
|
3
3
|
type UseDraggableSnapArgs = {
|
|
4
4
|
id: MaybeRef<string>;
|
|
5
|
-
animation: MaybeRef<
|
|
6
|
-
snapPoints: MaybeRef<
|
|
5
|
+
animation: MaybeRef<RequiredMagicDraggableOptions['animation']>;
|
|
6
|
+
snapPoints: MaybeRef<RequiredMagicDraggableOptions['snapPoints']>;
|
|
7
7
|
};
|
|
8
8
|
type InterpolateDraggedArgs = {
|
|
9
9
|
x: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type MaybeRef } from 'vue';
|
|
2
|
-
import type { DraggableState } from '../../types/index.js';
|
|
2
|
+
import type { DraggableState, MagicDraggableOptions } from '../../types/index.js';
|
|
3
3
|
export declare function useDraggableState(id: MaybeRef<string>): {
|
|
4
|
-
initializeState: () => DraggableState;
|
|
4
|
+
initializeState: (options?: MagicDraggableOptions) => DraggableState;
|
|
5
5
|
draggableStateStore: import("vue").Ref<DraggableState[], DraggableState[]>;
|
|
6
6
|
};
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { reactive, toValue, onScopeDispose } from "vue";
|
|
2
2
|
import { createStateStore } from "@maas/vue-equipment/utils";
|
|
3
|
+
import { createDefu } from "defu";
|
|
4
|
+
import { defaultOptions } from "../../utils/defaultOptions.mjs";
|
|
3
5
|
const getDraggableStateStore = createStateStore(
|
|
4
6
|
"MagicDraggable",
|
|
5
7
|
() => []
|
|
@@ -7,6 +9,12 @@ const getDraggableStateStore = createStateStore(
|
|
|
7
9
|
export function useDraggableState(id) {
|
|
8
10
|
const draggableStateStore = getDraggableStateStore();
|
|
9
11
|
let scopeCounted = false;
|
|
12
|
+
const customDefu = createDefu((obj, key, value) => {
|
|
13
|
+
if (key === "snapPoints") {
|
|
14
|
+
obj[key] = value;
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
10
18
|
function createState(id2) {
|
|
11
19
|
const state = {
|
|
12
20
|
id: id2,
|
|
@@ -24,7 +32,8 @@ export function useDraggableState(id) {
|
|
|
24
32
|
draggedY: 0,
|
|
25
33
|
elRect: void 0,
|
|
26
34
|
wrapperRect: void 0,
|
|
27
|
-
activeSnapPoint: void 0
|
|
35
|
+
activeSnapPoint: void 0,
|
|
36
|
+
options: defaultOptions
|
|
28
37
|
};
|
|
29
38
|
return reactive(state);
|
|
30
39
|
}
|
|
@@ -39,7 +48,7 @@ export function useDraggableState(id) {
|
|
|
39
48
|
(x) => x.id !== currentId
|
|
40
49
|
);
|
|
41
50
|
}
|
|
42
|
-
function initializeState() {
|
|
51
|
+
function initializeState(options) {
|
|
43
52
|
const currentId = toValue(id);
|
|
44
53
|
let state = draggableStateStore.value.find(
|
|
45
54
|
(entry) => entry.id === currentId
|
|
@@ -47,6 +56,10 @@ export function useDraggableState(id) {
|
|
|
47
56
|
if (!state) {
|
|
48
57
|
state = addState(currentId);
|
|
49
58
|
}
|
|
59
|
+
if (options) {
|
|
60
|
+
const mappedOptions = customDefu(options, defaultOptions);
|
|
61
|
+
state.options = mappedOptions;
|
|
62
|
+
}
|
|
50
63
|
if (!scopeCounted) {
|
|
51
64
|
state.refCount++;
|
|
52
65
|
scopeCounted = true;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { RequireAll } from '@maas/vue-equipment/utils';
|
|
2
1
|
type Position = 'top-left' | 'top' | 'top-right' | 'left' | 'center' | 'right' | 'bottom-left' | 'bottom' | 'bottom-right';
|
|
3
2
|
export type Coordinates = {
|
|
4
3
|
x: number;
|
|
@@ -34,9 +33,9 @@ export interface MagicDraggableOptions {
|
|
|
34
33
|
};
|
|
35
34
|
disabled?: boolean;
|
|
36
35
|
}
|
|
37
|
-
export type
|
|
38
|
-
threshold:
|
|
39
|
-
animation:
|
|
36
|
+
export type RequiredMagicDraggableOptions = Required<MagicDraggableOptions> & {
|
|
37
|
+
threshold: Required<MagicDraggableOptions['threshold']>;
|
|
38
|
+
animation: Required<MagicDraggableOptions['animation']>;
|
|
40
39
|
};
|
|
41
40
|
export interface DraggableState {
|
|
42
41
|
id: string;
|
|
@@ -55,6 +54,7 @@ export interface DraggableState {
|
|
|
55
54
|
elRect: DOMRect | undefined;
|
|
56
55
|
wrapperRect: DOMRect | undefined;
|
|
57
56
|
activeSnapPoint: DraggableSnapPoint | undefined;
|
|
57
|
+
options: RequiredMagicDraggableOptions;
|
|
58
58
|
}
|
|
59
59
|
export interface DraggableEvents {
|
|
60
60
|
beforeSnap: {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
declare const defaultOptions:
|
|
1
|
+
import type { RequiredMagicDraggableOptions } from '../types/index.js';
|
|
2
|
+
declare const defaultOptions: RequiredMagicDraggableOptions;
|
|
3
3
|
export { defaultOptions };
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import MagicDrawer from './src/components/MagicDrawer.vue.js';
|
|
2
|
+
import MagicDrawerProvider from './src/components/MagicDrawerProvider.vue.js';
|
|
3
|
+
import MagicDrawerTeleport from './src/components/MagicDrawerTeleport.vue.js';
|
|
4
|
+
import MagicDrawerBackdrop from './src/components/MagicDrawerBackdrop.vue.js';
|
|
5
|
+
import MagicDrawerContent from './src/components/MagicDrawerContent.vue.js';
|
|
6
|
+
import MagicDrawerTrigger from './src/components/MagicDrawerTrigger.vue.js';
|
|
2
7
|
import { useMagicDrawer } from './src/composables/useMagicDrawer.js';
|
|
3
8
|
import type { Plugin } from 'vue';
|
|
4
9
|
import type { MagicDrawerOptions } from './src/types/index.js';
|
|
5
10
|
declare const MagicDrawerPlugin: Plugin;
|
|
6
|
-
export { MagicDrawerPlugin, MagicDrawer, useMagicDrawer };
|
|
11
|
+
export { MagicDrawerPlugin, MagicDrawer, MagicDrawerProvider, MagicDrawerTeleport, MagicDrawerBackdrop, MagicDrawerContent, MagicDrawerTrigger, useMagicDrawer, };
|
|
7
12
|
export type { MagicDrawerOptions };
|
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
import MagicDrawer from "./src/components/MagicDrawer.vue";
|
|
2
|
+
import MagicDrawerProvider from "./src/components/MagicDrawerProvider.vue";
|
|
3
|
+
import MagicDrawerTeleport from "./src/components/MagicDrawerTeleport.vue";
|
|
4
|
+
import MagicDrawerBackdrop from "./src/components/MagicDrawerBackdrop.vue";
|
|
5
|
+
import MagicDrawerContent from "./src/components/MagicDrawerContent.vue";
|
|
6
|
+
import MagicDrawerTrigger from "./src/components/MagicDrawerTrigger.vue";
|
|
2
7
|
import { useMagicDrawer } from "./src/composables/useMagicDrawer.mjs";
|
|
3
8
|
const MagicDrawerPlugin = {
|
|
4
9
|
install: (app) => {
|
|
5
10
|
app.component("MagicDrawer", MagicDrawer);
|
|
11
|
+
app.component("MagicDrawerProvider", MagicDrawerProvider);
|
|
12
|
+
app.component("MagicDrawerTeleport", MagicDrawerTeleport);
|
|
13
|
+
app.component("MagicDrawerBackdrop", MagicDrawerBackdrop);
|
|
14
|
+
app.component("MagicDrawerContent", MagicDrawerContent);
|
|
15
|
+
app.component("MagicDrawerTrigger", MagicDrawerTrigger);
|
|
6
16
|
}
|
|
7
17
|
};
|
|
8
|
-
export {
|
|
18
|
+
export {
|
|
19
|
+
MagicDrawerPlugin,
|
|
20
|
+
MagicDrawer,
|
|
21
|
+
MagicDrawerProvider,
|
|
22
|
+
MagicDrawerTeleport,
|
|
23
|
+
MagicDrawerBackdrop,
|
|
24
|
+
MagicDrawerContent,
|
|
25
|
+
MagicDrawerTrigger,
|
|
26
|
+
useMagicDrawer
|
|
27
|
+
};
|
|
@@ -1,24 +1,14 @@
|
|
|
1
1
|
import { type MaybeRef } from 'vue';
|
|
2
2
|
import type { MagicDrawerOptions } from '../types/index.js';
|
|
3
|
-
import '@maas/vue-equipment/utils/css/keyframes/fade-in.css';
|
|
4
|
-
import '@maas/vue-equipment/utils/css/keyframes/fade-out.css';
|
|
5
|
-
import '@maas/vue-equipment/utils/css/keyframes/slide-ltr-in.css';
|
|
6
|
-
import '@maas/vue-equipment/utils/css/keyframes/slide-rtl-in.css';
|
|
7
|
-
import '@maas/vue-equipment/utils/css/keyframes/slide-ttb-in.css';
|
|
8
|
-
import '@maas/vue-equipment/utils/css/keyframes/slide-btt-in.css';
|
|
9
|
-
import '@maas/vue-equipment/utils/css/keyframes/slide-ltr-out.css';
|
|
10
|
-
import '@maas/vue-equipment/utils/css/keyframes/slide-rtl-out.css';
|
|
11
|
-
import '@maas/vue-equipment/utils/css/keyframes/slide-ttb-out.css';
|
|
12
|
-
import '@maas/vue-equipment/utils/css/keyframes/slide-btt-out.css';
|
|
13
3
|
interface MagicDrawerProps {
|
|
14
4
|
id: MaybeRef<string>;
|
|
15
5
|
options?: MagicDrawerOptions;
|
|
16
6
|
}
|
|
17
|
-
declare var
|
|
7
|
+
declare var __VLS_14: {}, __VLS_20: {};
|
|
18
8
|
type __VLS_Slots = {} & {
|
|
19
|
-
backdrop?: (props: typeof
|
|
9
|
+
backdrop?: (props: typeof __VLS_14) => any;
|
|
20
10
|
} & {
|
|
21
|
-
default?: (props: typeof
|
|
11
|
+
default?: (props: typeof __VLS_20) => any;
|
|
22
12
|
};
|
|
23
13
|
declare const __VLS_base: import("vue").DefineComponent<MagicDrawerProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<MagicDrawerProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
24
14
|
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|