@maas/vue-equipment 1.0.0-beta.34 → 1.0.0-beta.36
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/useScrollTo/index.js +6 -2
- package/dist/composables/useScrollTo/index.js.map +1 -1
- package/dist/nuxt/module.d.mts +2 -2
- package/dist/nuxt/module.json +1 -1
- package/dist/nuxt/module.mjs +8 -1
- package/dist/plugins/.turbo/turbo-lint.log +1 -1
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionContent.vue +15 -6
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionContent.vue.d.ts +1 -1
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionProvider.vue.d.ts +1 -1
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionTrigger.vue +17 -12
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionTrigger.vue.d.ts +1 -1
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionView.vue +11 -5
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionView.vue.d.ts +1 -1
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionTrigger.d.ts +2 -2
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionTrigger.mjs +5 -5
- package/dist/plugins/MagicCommand/src/components/MagicCommandContent.vue +28 -10
- package/dist/plugins/MagicCommand/src/components/MagicCommandContent.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandDrawer.vue +11 -5
- package/dist/plugins/MagicCommand/src/components/MagicCommandDrawer.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.vue +19 -9
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandModal.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandProvider.vue +17 -2
- package/dist/plugins/MagicCommand/src/components/MagicCommandProvider.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandRenderer.vue +11 -5
- package/dist/plugins/MagicCommand/src/components/MagicCommandRenderer.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandTrigger.vue +22 -11
- package/dist/plugins/MagicCommand/src/components/MagicCommandTrigger.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandView.vue +11 -3
- package/dist/plugins/MagicCommand/src/components/MagicCommandView.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/composables/private/useCommandItem.mjs +3 -1
- package/dist/plugins/MagicCommand/src/composables/private/useCommandView.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/composables/private/useCommandView.mjs +63 -44
- package/dist/plugins/MagicCommand/src/composables/useMagicCommand.mjs +21 -4
- package/dist/plugins/MagicCookie/src/components/MagicCookieItem.vue +12 -3
- package/dist/plugins/MagicCookie/src/components/MagicCookieItem.vue.d.ts +1 -1
- package/dist/plugins/MagicCookie/src/components/MagicCookieProvider.vue.d.ts +1 -1
- package/dist/plugins/MagicCookie/src/components/MagicCookieView.vue +11 -5
- package/dist/plugins/MagicCookie/src/components/MagicCookieView.vue.d.ts +1 -1
- package/dist/plugins/MagicCookie/src/composables/private/useCookieItem.mjs +9 -2
- package/dist/plugins/MagicDraggable/src/components/MagicDraggable.vue +11 -2
- package/dist/plugins/MagicDraggable/src/components/MagicDraggable.vue.d.ts +1 -1
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableDrag.mjs +8 -3
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableScrollLock.mjs +3 -1
- package/dist/plugins/MagicDraggable/src/composables/private/useDraggableSnap.mjs +7 -2
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue +7 -2
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue.d.ts +1 -1
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDOM.mjs +3 -1
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerDrag.mjs +6 -1
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerSnap.mjs +55 -21
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.mjs +3 -1
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerUtils.mjs +21 -8
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerWheel.mjs +6 -1
- package/dist/plugins/MagicError/index.d.ts +5 -0
- package/dist/plugins/MagicError/index.mjs +3 -0
- package/dist/plugins/MagicError/nuxt.d.ts +2 -0
- package/dist/plugins/MagicError/nuxt.mjs +12 -0
- package/dist/plugins/MagicError/package.json +40 -0
- package/dist/plugins/MagicError/src/MagicError.d.ts +0 -0
- package/dist/plugins/MagicError/src/MagicError.mjs +0 -0
- package/dist/plugins/MagicError/src/class/MagicError.d.ts +6 -0
- package/dist/plugins/MagicError/src/class/MagicError.mjs +15 -0
- package/dist/plugins/MagicError/src/composables/useMagicError.d.ts +18 -0
- package/dist/plugins/MagicError/src/composables/useMagicError.mjs +31 -0
- package/dist/plugins/MagicMarquee/src/components/MagicMarquee.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuChannel.vue +22 -10
- package/dist/plugins/MagicMenu/src/components/MagicMenuChannel.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuContent.vue +15 -6
- package/dist/plugins/MagicMenu/src/components/MagicMenuContent.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuFloat.vue +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuFloat.vue.d.ts +4 -3
- package/dist/plugins/MagicMenu/src/components/MagicMenuItem.vue +19 -9
- package/dist/plugins/MagicMenu/src/components/MagicMenuItem.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuProvider.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuRemote.vue +19 -13
- package/dist/plugins/MagicMenu/src/components/MagicMenuRemote.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuTrigger.vue +15 -10
- package/dist/plugins/MagicMenu/src/components/MagicMenuTrigger.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuView.vue +12 -4
- package/dist/plugins/MagicMenu/src/components/MagicMenuView.vue.d.ts +3 -3
- package/dist/plugins/MagicMenu/src/composables/private/useMenuDOM.mjs +3 -1
- package/dist/plugins/MagicMenu/src/composables/private/useMenuItem.mjs +12 -2
- package/dist/plugins/MagicMenu/src/composables/private/useMenuKeyListener.mjs +22 -10
- package/dist/plugins/MagicMenu/src/composables/private/useMenuView.mjs +13 -4
- package/dist/plugins/MagicMenu/src/types/index.d.ts +2 -2
- package/dist/plugins/MagicModal/src/components/MagicModal.vue.d.ts +1 -1
- package/dist/plugins/MagicModal/src/composables/private/useModalDOM.mjs +3 -1
- package/dist/plugins/MagicNoise/src/components/MagicNoise.vue.d.ts +1 -1
- package/dist/plugins/MagicNoise/src/composables/private/useNoiseApi.mjs +7 -3
- package/dist/plugins/MagicPie/src/components/MagicPie.vue +15 -2
- package/dist/plugins/MagicPie/src/components/MagicPie.vue.d.ts +1 -1
- package/dist/plugins/MagicPie/src/composables/private/usePieState.mjs +3 -1
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudio.vue +17 -7
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudio.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudioControls.vue +11 -5
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudioControls.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerDisplayTime.vue +11 -5
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerDisplayTime.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerMuxPopover.vue +29 -14
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerMuxPopover.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerOverlay.vue +11 -5
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerOverlay.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerPoster.vue +11 -5
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerPoster.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerProvider.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerTimeline.vue +11 -5
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerTimeline.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideo.vue +17 -7
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideo.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideoControls.vue +11 -5
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideoControls.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/icons/FullscreenEnter.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/icons/FullscreenExit.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/icons/Pause.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/icons/Play.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/icons/VolumeOff.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/icons/VolumeOn.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/components/icons/Waiting.vue.d.ts +1 -1
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerMediaApi.mjs +65 -11
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerRuntime.d.ts +1 -0
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerRuntime.mjs +96 -16
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerState.mjs +3 -1
- package/dist/plugins/MagicPlayer/src/composables/private/usePlayerVideoApi.mjs +7 -2
- package/dist/plugins/MagicPlayer/src/types/index.d.ts +2 -0
- package/dist/plugins/MagicPlayer/src/utils/defaultOptions.mjs +1 -0
- package/dist/plugins/MagicScroll/src/components/MagicScrollCollision.vue +12 -6
- package/dist/plugins/MagicScroll/src/components/MagicScrollCollision.vue.d.ts +1 -1
- package/dist/plugins/MagicScroll/src/components/MagicScrollMotion.vue.d.ts +1 -1
- package/dist/plugins/MagicScroll/src/components/MagicScrollProvider.vue.d.ts +1 -1
- package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue +11 -3
- package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue.d.ts +1 -1
- package/dist/plugins/MagicToast/src/components/MagicToastProvider.vue.d.ts +1 -1
- package/dist/plugins/MagicToast/src/components/MagicToastView.vue +11 -3
- package/dist/plugins/MagicToast/src/components/MagicToastView.vue.d.ts +1 -1
- package/dist/plugins/MagicToast/src/composables/private/useToastCallback.d.ts +2 -2
- package/dist/plugins/MagicToast/src/composables/private/useToastCallback.mjs +7 -5
- package/dist/plugins/MagicToast/src/composables/private/useToastScrollLock.mjs +3 -1
- package/dist/utils/index.js +3 -1
- package/dist/utils/index.js.map +1 -1
- package/package.json +16 -21
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
<script setup>
|
|
17
17
|
import { computed, inject, useTemplateRef, toValue, watch } from "vue";
|
|
18
18
|
import { Primitive } from "@maas/vue-primitive";
|
|
19
|
+
import {
|
|
20
|
+
useMagicError
|
|
21
|
+
} from "@maas/vue-equipment/plugins/MagicError";
|
|
19
22
|
import { useCommandView } from "../composables/private/useCommandView";
|
|
20
23
|
import { useCommandTrigger } from "../composables/private/useCommandTrigger";
|
|
21
24
|
import {
|
|
@@ -40,22 +43,24 @@ const {
|
|
|
40
43
|
trigger: { type: Array, required: false },
|
|
41
44
|
asChild: { type: Boolean, required: false }
|
|
42
45
|
});
|
|
46
|
+
const magicError = useMagicError({
|
|
47
|
+
prefix: "MagicCommand",
|
|
48
|
+
source: "MagicCommandTrigger"
|
|
49
|
+
});
|
|
43
50
|
const elRef = useTemplateRef("el");
|
|
44
51
|
const instanceId = inject(MagicCommandInstanceId, void 0);
|
|
45
52
|
const itemActive = inject(MagicCommandItemActive, void 0);
|
|
46
53
|
const itemDisabled = inject(MagicCommandItemDisabled, void 0);
|
|
47
54
|
const injectedViewId = inject(MagicCommandViewId, void 0);
|
|
48
55
|
const mappedViewId = computed(() => viewId ?? injectedViewId);
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
);
|
|
58
|
-
}
|
|
56
|
+
magicError.assert(instanceId, {
|
|
57
|
+
message: "MagicCommandTrigger must be nested inside MagicCommandProvider",
|
|
58
|
+
errorCode: "missing_instance_id"
|
|
59
|
+
});
|
|
60
|
+
magicError.assert(mappedViewId.value, {
|
|
61
|
+
message: "MagicCommandTrigger must be nested inside MagicCommandView or a viewId must be provided",
|
|
62
|
+
errorCode: "missing_view_id"
|
|
63
|
+
});
|
|
59
64
|
const { getView } = useCommandView(instanceId);
|
|
60
65
|
const view = getView(mappedViewId.value);
|
|
61
66
|
const mappedActive = computed(() => active ?? toValue(itemActive) ?? false);
|
|
@@ -82,9 +87,15 @@ watch(
|
|
|
82
87
|
}
|
|
83
88
|
);
|
|
84
89
|
const keys = useMagicKeys();
|
|
90
|
+
const { logWarning } = magicError;
|
|
85
91
|
if (options?.keyListener?.enter) {
|
|
86
92
|
for (const key of options.keyListener.enter) {
|
|
87
|
-
|
|
93
|
+
const mappedKey = keys[key];
|
|
94
|
+
if (!mappedKey) {
|
|
95
|
+
logWarning(`The key \u201C${key}\u201D is not supported by MagicCommand`);
|
|
96
|
+
continue;
|
|
97
|
+
}
|
|
98
|
+
watch(mappedKey, (value) => {
|
|
88
99
|
if (value) {
|
|
89
100
|
onKeypress();
|
|
90
101
|
}
|
|
@@ -14,7 +14,7 @@ declare var __VLS_12: {
|
|
|
14
14
|
type __VLS_Slots = {} & {
|
|
15
15
|
default?: (props: typeof __VLS_12) => any;
|
|
16
16
|
};
|
|
17
|
-
declare const __VLS_component: import("vue").DefineComponent<MagicCommandTriggerProps,
|
|
17
|
+
declare const __VLS_component: import("vue").DefineComponent<MagicCommandTriggerProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<MagicCommandTriggerProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
18
18
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
19
19
|
export default _default;
|
|
20
20
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
|
|
7
7
|
<script setup>
|
|
8
8
|
import { computed, inject, onBeforeUnmount, provide, useId, watch } from "vue";
|
|
9
|
+
import {
|
|
10
|
+
useMagicError
|
|
11
|
+
} from "@maas/vue-equipment/plugins/MagicError";
|
|
9
12
|
import { useCommandView } from "../composables/private/useCommandView";
|
|
10
13
|
import {
|
|
11
14
|
MagicCommandInstanceId,
|
|
@@ -18,12 +21,17 @@ const { id, initial = false } = defineProps({
|
|
|
18
21
|
id: { type: String, required: false },
|
|
19
22
|
initial: { type: Boolean, required: false }
|
|
20
23
|
});
|
|
24
|
+
const magicError = useMagicError({
|
|
25
|
+
prefix: "MagicCommand",
|
|
26
|
+
source: "MagicCommandView"
|
|
27
|
+
});
|
|
21
28
|
const parentTree = inject(MagicCommandParentTree, []);
|
|
22
29
|
const instanceId = inject(MagicCommandInstanceId, void 0);
|
|
23
30
|
const itemId = inject(MagicCommandItemId, void 0);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
magicError.assert(instanceId, {
|
|
32
|
+
message: "MagicCommandView must be nested inside MagicCommandProvider",
|
|
33
|
+
errorCode: "missing_instance_id"
|
|
34
|
+
});
|
|
27
35
|
const mappedId = computed(() => id ?? `magic-command-view-${useId()}`);
|
|
28
36
|
const mappedParentTree = computed(() => [...parentTree, mappedId.value]);
|
|
29
37
|
const mappedActive = computed(() => view.active);
|
|
@@ -8,7 +8,7 @@ declare var __VLS_1: {
|
|
|
8
8
|
type __VLS_Slots = {} & {
|
|
9
9
|
default?: (props: typeof __VLS_1) => any;
|
|
10
10
|
};
|
|
11
|
-
declare const __VLS_component: import("vue").DefineComponent<MagicCommandViewProps,
|
|
11
|
+
declare const __VLS_component: import("vue").DefineComponent<MagicCommandViewProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<MagicCommandViewProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
12
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
13
13
|
export default _default;
|
|
14
14
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type MaybeRef } from 'vue';
|
|
2
2
|
import type { CommandView } from '../../types/index.js';
|
|
3
3
|
type InitializeViewArgs = Pick<CommandView, 'id' | 'parent' | 'initial'>;
|
|
4
|
-
export declare function useCommandView(
|
|
4
|
+
export declare function useCommandView(id: MaybeRef<string>): {
|
|
5
5
|
currentView: import("vue").ComputedRef<CommandView | undefined>;
|
|
6
6
|
initializeView: (args: InitializeViewArgs) => CommandView;
|
|
7
7
|
deleteView: (id: string) => void;
|
|
@@ -1,28 +1,37 @@
|
|
|
1
1
|
import { reactive, computed, toValue } from "vue";
|
|
2
|
+
import { useMagicError } from "@maas/vue-equipment/plugins/MagicError";
|
|
2
3
|
import { useCommandState } from "./useCommandState.mjs";
|
|
3
4
|
function isAbortError(error) {
|
|
4
5
|
return error instanceof DOMException && error.name === "AbortError";
|
|
5
6
|
}
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
const { logWarning } = useMagicError({
|
|
8
|
+
prefix: "MagicCommand",
|
|
9
|
+
source: "useCommandView"
|
|
10
|
+
});
|
|
11
|
+
export function useCommandView(id) {
|
|
12
|
+
const { initializeState } = useCommandState(id);
|
|
8
13
|
const state = initializeState();
|
|
9
|
-
const currentInstanceId = toValue(
|
|
14
|
+
const currentInstanceId = toValue(id);
|
|
10
15
|
const currentView = computed(() => {
|
|
11
16
|
const activeViews = state.views.filter((view) => view.active);
|
|
12
|
-
if (activeViews.length === 0)
|
|
13
|
-
|
|
17
|
+
if (activeViews.length === 0) {
|
|
18
|
+
return void 0;
|
|
19
|
+
}
|
|
20
|
+
if (activeViews.length === 1) {
|
|
21
|
+
return activeViews[0];
|
|
22
|
+
}
|
|
14
23
|
return activeViews.reduce(
|
|
15
24
|
(a, b) => a.parent.views.length >= b.parent.views.length ? a : b
|
|
16
25
|
);
|
|
17
26
|
});
|
|
18
27
|
const viewMap = /* @__PURE__ */ new Map();
|
|
19
28
|
function createView(args) {
|
|
20
|
-
const { id, parent, initial } = args;
|
|
29
|
+
const { id: id2, parent, initial } = args;
|
|
21
30
|
if (parent.views.length === 0) {
|
|
22
31
|
parent.views.push(currentInstanceId);
|
|
23
32
|
}
|
|
24
33
|
const view = reactive({
|
|
25
|
-
id,
|
|
34
|
+
id: id2,
|
|
26
35
|
parent,
|
|
27
36
|
initial,
|
|
28
37
|
active: false,
|
|
@@ -33,7 +42,7 @@ export function useCommandView(instanceId) {
|
|
|
33
42
|
unselectAbortController: new AbortController()
|
|
34
43
|
}
|
|
35
44
|
});
|
|
36
|
-
viewMap.set(
|
|
45
|
+
viewMap.set(id2, view);
|
|
37
46
|
return view;
|
|
38
47
|
}
|
|
39
48
|
function addView(args) {
|
|
@@ -55,35 +64,37 @@ export function useCommandView(instanceId) {
|
|
|
55
64
|
const view = state?.views.findLast((view2) => view2.active)?.id;
|
|
56
65
|
state.input.view = view;
|
|
57
66
|
}
|
|
58
|
-
function getView(
|
|
59
|
-
let view = viewMap.get(
|
|
67
|
+
function getView(id2) {
|
|
68
|
+
let view = viewMap.get(id2);
|
|
60
69
|
if (!view) {
|
|
61
|
-
view = state.views.find((v) => v.id ===
|
|
62
|
-
if (view) viewMap.set(
|
|
70
|
+
view = state.views.find((v) => v.id === id2);
|
|
71
|
+
if (view) viewMap.set(id2, view);
|
|
63
72
|
}
|
|
64
73
|
return view;
|
|
65
74
|
}
|
|
66
|
-
function deleteView(
|
|
67
|
-
const index = state.views.findIndex((view) => view.id ===
|
|
75
|
+
function deleteView(id2) {
|
|
76
|
+
const index = state.views.findIndex((view) => view.id === id2);
|
|
68
77
|
if (index !== -1) {
|
|
69
78
|
state.views.splice(index, 1);
|
|
70
|
-
viewMap.delete(
|
|
79
|
+
viewMap.delete(id2);
|
|
71
80
|
}
|
|
72
81
|
}
|
|
73
|
-
function getRelativeViewIndex(
|
|
74
|
-
const view = getView(
|
|
75
|
-
if (!view)
|
|
82
|
+
function getRelativeViewIndex(id2) {
|
|
83
|
+
const view = getView(id2);
|
|
84
|
+
if (!view) {
|
|
85
|
+
return -1;
|
|
86
|
+
}
|
|
76
87
|
const nestingLevel = view.parent.views.length;
|
|
77
88
|
return state.views.findIndex(
|
|
78
|
-
(v) => v.parent.views.length === nestingLevel && v.id ===
|
|
89
|
+
(v) => v.parent.views.length === nestingLevel && v.id === id2
|
|
79
90
|
);
|
|
80
91
|
}
|
|
81
|
-
function getNextView(
|
|
82
|
-
const index = state.views.findIndex((view) => view.id ===
|
|
92
|
+
function getNextView(id2) {
|
|
93
|
+
const index = state.views.findIndex((view) => view.id === id2);
|
|
83
94
|
return index !== -1 ? state.views[index + 1] : void 0;
|
|
84
95
|
}
|
|
85
|
-
function getPreviousView(
|
|
86
|
-
const index = state.views.findIndex((view) => view.id ===
|
|
96
|
+
function getPreviousView(id2) {
|
|
97
|
+
const index = state.views.findIndex((view) => view.id === id2);
|
|
87
98
|
return index > 0 ? state.views[index - 1] : void 0;
|
|
88
99
|
}
|
|
89
100
|
function getTopLevelView() {
|
|
@@ -92,21 +103,27 @@ export function useCommandView(instanceId) {
|
|
|
92
103
|
function getNestedView(itemId) {
|
|
93
104
|
return state.views.find((view) => view.parent.item === itemId);
|
|
94
105
|
}
|
|
95
|
-
function getParentView(
|
|
96
|
-
const view = getView(
|
|
97
|
-
if (!view)
|
|
106
|
+
function getParentView(id2) {
|
|
107
|
+
const view = getView(id2);
|
|
108
|
+
if (!view) {
|
|
109
|
+
return void 0;
|
|
110
|
+
}
|
|
98
111
|
const parentId = view.parent.views[view.parent.views.length - 1];
|
|
99
112
|
return parentId ? getView(parentId) : void 0;
|
|
100
113
|
}
|
|
101
|
-
function getUnrelatedViews(
|
|
102
|
-
const view = getView(
|
|
103
|
-
if (!view)
|
|
114
|
+
function getUnrelatedViews(id2) {
|
|
115
|
+
const view = getView(id2);
|
|
116
|
+
if (!view) {
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
104
119
|
const parentViewsSet = new Set(view.parent.views);
|
|
105
|
-
return state.views.filter((v) => v.id !==
|
|
120
|
+
return state.views.filter((v) => v.id !== id2 && !parentViewsSet.has(v.id));
|
|
106
121
|
}
|
|
107
|
-
async function selectView(
|
|
108
|
-
const view = getView(
|
|
109
|
-
if (!view)
|
|
122
|
+
async function selectView(id2, delayMs = 0) {
|
|
123
|
+
const view = getView(id2);
|
|
124
|
+
if (!view) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
110
127
|
if (view.state.unselectAbortController) {
|
|
111
128
|
view.state.unselectAbortController.abort();
|
|
112
129
|
}
|
|
@@ -120,7 +137,7 @@ export function useCommandView(instanceId) {
|
|
|
120
137
|
activateView();
|
|
121
138
|
} catch (error) {
|
|
122
139
|
if (isAbortError(error) && state.options.debug) {
|
|
123
|
-
|
|
140
|
+
logWarning("selectView() was interrupted by a call to unselectView()");
|
|
124
141
|
}
|
|
125
142
|
}
|
|
126
143
|
}
|
|
@@ -131,9 +148,11 @@ export function useCommandView(instanceId) {
|
|
|
131
148
|
activateView();
|
|
132
149
|
}
|
|
133
150
|
}
|
|
134
|
-
async function unselectView(
|
|
135
|
-
const view = getView(
|
|
136
|
-
if (!view)
|
|
151
|
+
async function unselectView(id2, delayMs = 0) {
|
|
152
|
+
const view = getView(id2);
|
|
153
|
+
if (!view) {
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
137
156
|
if (view.state.selectAbortController) {
|
|
138
157
|
view.state.selectAbortController.abort();
|
|
139
158
|
}
|
|
@@ -147,12 +166,12 @@ export function useCommandView(instanceId) {
|
|
|
147
166
|
activateView();
|
|
148
167
|
} catch (error) {
|
|
149
168
|
if (isAbortError(error) && state.options.debug) {
|
|
150
|
-
|
|
169
|
+
logWarning("unselectView() was interrupted by a call to selectView()");
|
|
151
170
|
}
|
|
152
171
|
}
|
|
153
172
|
}
|
|
154
|
-
function unselectUnrelatedViews(
|
|
155
|
-
const views = getUnrelatedViews(
|
|
173
|
+
function unselectUnrelatedViews(id2) {
|
|
174
|
+
const views = getUnrelatedViews(id2);
|
|
156
175
|
for (const view of views) {
|
|
157
176
|
view.active = false;
|
|
158
177
|
}
|
|
@@ -163,8 +182,8 @@ export function useCommandView(instanceId) {
|
|
|
163
182
|
}
|
|
164
183
|
}
|
|
165
184
|
function initializeView(args) {
|
|
166
|
-
const { id } = args;
|
|
167
|
-
const view = getView(
|
|
185
|
+
const { id: id2 } = args;
|
|
186
|
+
const view = getView(id2) ?? addView(args);
|
|
168
187
|
return view;
|
|
169
188
|
}
|
|
170
189
|
function sortViewItems(viewId) {
|
|
@@ -173,8 +192,8 @@ export function useCommandView(instanceId) {
|
|
|
173
192
|
const elements = Array.from(
|
|
174
193
|
parent?.querySelectorAll(".magic-command-item") ?? []
|
|
175
194
|
);
|
|
176
|
-
function getIndex(
|
|
177
|
-
return elements.findIndex((el) => el.dataset.id ===
|
|
195
|
+
function getIndex(id2) {
|
|
196
|
+
return elements.findIndex((el) => el.dataset.id === id2);
|
|
178
197
|
}
|
|
179
198
|
view?.items?.sort((a, b) => getIndex(a.id) - getIndex(b.id));
|
|
180
199
|
}
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { computed, nextTick } from "vue";
|
|
2
|
+
import { useMagicError } from "@maas/vue-equipment/plugins/MagicError";
|
|
2
3
|
import { useCommandState } from "./private/useCommandState.mjs";
|
|
3
4
|
import { useCommandItem } from "./private/useCommandItem.mjs";
|
|
4
5
|
import { useCommandView } from "./private/useCommandView.mjs";
|
|
6
|
+
const { throwError } = useMagicError({
|
|
7
|
+
prefix: "MagicCommand",
|
|
8
|
+
source: "useMagicCommand"
|
|
9
|
+
});
|
|
5
10
|
export function useMagicCommand(id) {
|
|
6
11
|
const { initializeState } = useCommandState(id);
|
|
7
12
|
const state = initializeState();
|
|
@@ -20,10 +25,16 @@ export function useMagicCommand(id) {
|
|
|
20
25
|
function selectItem(args) {
|
|
21
26
|
const { id: id2, viewId } = args;
|
|
22
27
|
if (!viewId) {
|
|
23
|
-
|
|
28
|
+
throwError({
|
|
29
|
+
message: "viewId is required to select an item",
|
|
30
|
+
errorCode: "view_id_required"
|
|
31
|
+
});
|
|
24
32
|
}
|
|
25
33
|
if (!id2) {
|
|
26
|
-
|
|
34
|
+
throwError({
|
|
35
|
+
message: "id is required to select an item",
|
|
36
|
+
errorCode: "id_required"
|
|
37
|
+
});
|
|
27
38
|
}
|
|
28
39
|
const { selectItem: selectItem2 } = useCommandItem({
|
|
29
40
|
instanceId: id2,
|
|
@@ -34,10 +45,16 @@ export function useMagicCommand(id) {
|
|
|
34
45
|
function unselectItem(args) {
|
|
35
46
|
const { id: id2, viewId } = args;
|
|
36
47
|
if (!viewId) {
|
|
37
|
-
|
|
48
|
+
throwError({
|
|
49
|
+
message: "viewId is required to select an item",
|
|
50
|
+
errorCode: "view_id_required"
|
|
51
|
+
});
|
|
38
52
|
}
|
|
39
53
|
if (!id2) {
|
|
40
|
-
|
|
54
|
+
throwError({
|
|
55
|
+
message: "id is required to select an item",
|
|
56
|
+
errorCode: "id_required"
|
|
57
|
+
});
|
|
41
58
|
}
|
|
42
59
|
const { unselectItem: unselectItem2 } = useCommandItem({
|
|
43
60
|
instanceId: id2,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div
|
|
3
3
|
class="magic-cookie-item"
|
|
4
|
+
:data-id="mappedId"
|
|
4
5
|
:data-optional="item.optional"
|
|
5
6
|
:data-active="item.active"
|
|
6
7
|
>
|
|
@@ -10,6 +11,9 @@
|
|
|
10
11
|
|
|
11
12
|
<script setup>
|
|
12
13
|
import { computed, inject, provide, onBeforeUnmount, useId } from "vue";
|
|
14
|
+
import {
|
|
15
|
+
useMagicError
|
|
16
|
+
} from "@maas/vue-equipment/plugins/MagicError";
|
|
13
17
|
import { useCookieItem } from "../composables/private/useCookieItem";
|
|
14
18
|
import {
|
|
15
19
|
MagicCookieInstanceId,
|
|
@@ -21,10 +25,15 @@ const { id, optional, maxAge } = defineProps({
|
|
|
21
25
|
optional: { type: Boolean, required: false },
|
|
22
26
|
maxAge: { type: Number, required: false }
|
|
23
27
|
});
|
|
28
|
+
const magicError = useMagicError({
|
|
29
|
+
prefix: "MagicCookie",
|
|
30
|
+
source: "MagicCookieItem"
|
|
31
|
+
});
|
|
24
32
|
const instanceId = inject(MagicCookieInstanceId, void 0);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
33
|
+
magicError.assert(instanceId, {
|
|
34
|
+
message: "MagicCookieItem must be nested inside MagicCookieProvider",
|
|
35
|
+
errorCode: "missing_instance_id"
|
|
36
|
+
});
|
|
28
37
|
const mappedId = computed(() => id ?? `magic-cookie-item-${useId()}`);
|
|
29
38
|
const mappedActive = computed(() => item.active);
|
|
30
39
|
const { initializeItem, deleteItem } = useCookieItem({
|
|
@@ -9,7 +9,7 @@ declare var __VLS_1: {
|
|
|
9
9
|
type __VLS_Slots = {} & {
|
|
10
10
|
default?: (props: typeof __VLS_1) => any;
|
|
11
11
|
};
|
|
12
|
-
declare const __VLS_component: import("vue").DefineComponent<MagicCookieItemProps,
|
|
12
|
+
declare const __VLS_component: import("vue").DefineComponent<MagicCookieItemProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<MagicCookieItemProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
13
13
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
14
14
|
export default _default;
|
|
15
15
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -8,7 +8,7 @@ declare var __VLS_7: {};
|
|
|
8
8
|
type __VLS_Slots = {} & {
|
|
9
9
|
default?: (props: typeof __VLS_7) => any;
|
|
10
10
|
};
|
|
11
|
-
declare const __VLS_component: import("vue").DefineComponent<MagicCookieProviderProps,
|
|
11
|
+
declare const __VLS_component: import("vue").DefineComponent<MagicCookieProviderProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<MagicCookieProviderProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
12
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
13
13
|
export default _default;
|
|
14
14
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -24,17 +24,23 @@
|
|
|
24
24
|
<script setup>
|
|
25
25
|
import { inject } from "vue";
|
|
26
26
|
import { AutoSize } from "@maas/vue-autosize";
|
|
27
|
+
import {
|
|
28
|
+
useMagicError
|
|
29
|
+
} from "@maas/vue-equipment/plugins/MagicError";
|
|
27
30
|
import { useCookieState } from "../composables/private/useCookieState";
|
|
28
31
|
import { useCookieCallback } from "../composables/private/useCookieCallback";
|
|
29
32
|
import { MagicCookieInstanceId } from "../symbols";
|
|
30
33
|
import "@maas/vue-equipment/utils/css/keyframes/fade-in.css";
|
|
31
34
|
import "@maas/vue-equipment/utils/css/keyframes/auto-size-out.css";
|
|
35
|
+
const magicError = useMagicError({
|
|
36
|
+
prefix: "MagicCookie",
|
|
37
|
+
source: "MagicCookieView"
|
|
38
|
+
});
|
|
32
39
|
const instanceId = inject(MagicCookieInstanceId, void 0);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
40
|
+
magicError.assert(instanceId, {
|
|
41
|
+
message: "MagicCookieView must be used within a MagicCookieProvider",
|
|
42
|
+
errorCode: "missing_instance_id"
|
|
43
|
+
});
|
|
38
44
|
const { initializeState } = useCookieState(instanceId);
|
|
39
45
|
const state = initializeState();
|
|
40
46
|
const {
|
|
@@ -6,7 +6,7 @@ declare var __VLS_19: {
|
|
|
6
6
|
type __VLS_Slots = {} & {
|
|
7
7
|
default?: (props: typeof __VLS_19) => any;
|
|
8
8
|
};
|
|
9
|
-
declare const __VLS_component: import("vue").DefineComponent<{},
|
|
9
|
+
declare const __VLS_component: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
10
10
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
11
11
|
export default _default;
|
|
12
12
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import { reactive, toValue } from "vue";
|
|
2
2
|
import { useCookies } from "@vueuse/integrations/useCookies";
|
|
3
|
+
import { useMagicError } from "@maas/vue-equipment/plugins/MagicError";
|
|
3
4
|
import { useCookieState } from "./useCookieState.mjs";
|
|
4
5
|
export function useCookieItem(args) {
|
|
5
6
|
const { instanceId } = args;
|
|
7
|
+
const { logWarning } = useMagicError({
|
|
8
|
+
prefix: "MagicCookie",
|
|
9
|
+
source: "useCookieItem"
|
|
10
|
+
});
|
|
6
11
|
const { initializeState } = useCookieState(instanceId);
|
|
7
12
|
const state = initializeState();
|
|
8
13
|
function getBrowserCookie(id) {
|
|
@@ -36,7 +41,9 @@ export function useCookieItem(args) {
|
|
|
36
41
|
return item;
|
|
37
42
|
}
|
|
38
43
|
function deleteItem(id) {
|
|
39
|
-
if (!state?.items)
|
|
44
|
+
if (!state?.items) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
40
47
|
state.items = state.items.filter((x) => x.id !== id);
|
|
41
48
|
}
|
|
42
49
|
function getItem(id) {
|
|
@@ -67,7 +74,7 @@ export function useCookieItem(args) {
|
|
|
67
74
|
function setItemCookie(id) {
|
|
68
75
|
const item = getItem(id);
|
|
69
76
|
if (!item) {
|
|
70
|
-
|
|
77
|
+
logWarning(`Item ${id} not found. Cookie cannot be set.`);
|
|
71
78
|
return;
|
|
72
79
|
}
|
|
73
80
|
useCookies([id]).set(toValue(id), item.active, {
|
|
@@ -26,6 +26,9 @@
|
|
|
26
26
|
<script setup>
|
|
27
27
|
import { useTemplateRef, computed, toValue, toRefs } from "vue";
|
|
28
28
|
import { createDefu } from "defu";
|
|
29
|
+
import {
|
|
30
|
+
useMagicError
|
|
31
|
+
} from "@maas/vue-equipment/plugins/MagicError";
|
|
29
32
|
import { useDraggableDrag } from "../composables/private/useDraggableDrag";
|
|
30
33
|
import { useDraggableState } from "../composables/private/useDraggableState";
|
|
31
34
|
import { defaultOptions } from "../utils/defaultOptions";
|
|
@@ -36,6 +39,10 @@ const { id, options = {} } = defineProps({
|
|
|
36
39
|
id: { type: null, required: true },
|
|
37
40
|
options: { type: Object, required: false }
|
|
38
41
|
});
|
|
42
|
+
const magicError = useMagicError({
|
|
43
|
+
prefix: "MagicDraggable",
|
|
44
|
+
source: "MagicDraggable"
|
|
45
|
+
});
|
|
39
46
|
const customDefu = createDefu((obj, key, value) => {
|
|
40
47
|
if (key === "snapPoints") {
|
|
41
48
|
obj[key] = value;
|
|
@@ -45,7 +52,10 @@ const customDefu = createDefu((obj, key, value) => {
|
|
|
45
52
|
const mappedOptions = customDefu(options, defaultOptions);
|
|
46
53
|
const mappedId = toValue(id);
|
|
47
54
|
if (!mappedOptions.snapPoints.length) {
|
|
48
|
-
|
|
55
|
+
magicError.throwError({
|
|
56
|
+
message: "MagicDraggable must have at least one snap point set",
|
|
57
|
+
errorCode: "missing_snap_point"
|
|
58
|
+
});
|
|
49
59
|
}
|
|
50
60
|
const elRef = useTemplateRef("el");
|
|
51
61
|
const wrapperRef = useTemplateRef("wrapper");
|
|
@@ -90,7 +100,6 @@ function guardedClick(event) {
|
|
|
90
100
|
z-index: var(--magic-draggable-z-index, 999);
|
|
91
101
|
inset: var(--magic-draggable-inset, 0);
|
|
92
102
|
pointer-events: none;
|
|
93
|
-
background: transparent;
|
|
94
103
|
color: inherit;
|
|
95
104
|
padding: 0;
|
|
96
105
|
border: none;
|
|
@@ -8,7 +8,7 @@ declare var __VLS_12: {};
|
|
|
8
8
|
type __VLS_Slots = {} & {
|
|
9
9
|
default?: (props: typeof __VLS_12) => any;
|
|
10
10
|
};
|
|
11
|
-
declare const __VLS_component: import("vue").DefineComponent<MagicDraggableProps,
|
|
11
|
+
declare const __VLS_component: import("vue").DefineComponent<MagicDraggableProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<MagicDraggableProps> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
12
|
declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
|
|
13
13
|
export default _default;
|
|
14
14
|
type __VLS_WithSlots<T, S> = T & {
|
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
import {
|
|
25
25
|
useMagicEmitter
|
|
26
26
|
} from "@maas/vue-equipment/plugins/MagicEmitter";
|
|
27
|
+
import { useMagicError } from "@maas/vue-equipment/plugins/MagicError";
|
|
27
28
|
import { useDraggableSnap } from "./useDraggableSnap.mjs";
|
|
28
29
|
import { useDraggableState } from "./useDraggableState.mjs";
|
|
29
30
|
import { useDraggableScrollLock } from "./useDraggableScrollLock.mjs";
|
|
@@ -38,6 +39,10 @@ export function useDraggableDrag(args) {
|
|
|
38
39
|
animation,
|
|
39
40
|
scrollLock
|
|
40
41
|
} = args;
|
|
42
|
+
const { logWarning } = useMagicError({
|
|
43
|
+
prefix: "MagicDraggable",
|
|
44
|
+
source: "useDraggableDrag"
|
|
45
|
+
});
|
|
41
46
|
const { initializeState } = useDraggableState(toValue(id));
|
|
42
47
|
const state = initializeState();
|
|
43
48
|
const {
|
|
@@ -127,11 +132,11 @@ export function useDraggableDrag(args) {
|
|
|
127
132
|
const childRect = toValue(elRect);
|
|
128
133
|
const parentRect = toValue(wrapperRect);
|
|
129
134
|
if (!childRect || !parentRect) {
|
|
130
|
-
|
|
135
|
+
logWarning("Could not calculate sizing");
|
|
131
136
|
return;
|
|
132
137
|
}
|
|
133
138
|
if (childRect.width > parentRect.width || childRect.height > parentRect.height) {
|
|
134
|
-
|
|
139
|
+
logWarning("Element is too small for its content");
|
|
135
140
|
return;
|
|
136
141
|
}
|
|
137
142
|
}
|
|
@@ -350,7 +355,7 @@ export function useDraggableDrag(args) {
|
|
|
350
355
|
if (elRect.value && wrapperRect.value) {
|
|
351
356
|
emitter.on("snapTo", snapToCallback);
|
|
352
357
|
if (elRect.value.width > wrapperRect.value.width || elRect.value.height > wrapperRect.value.height) {
|
|
353
|
-
|
|
358
|
+
logWarning("is too small for its content");
|
|
354
359
|
return;
|
|
355
360
|
}
|
|
356
361
|
}
|
|
@@ -15,7 +15,9 @@ export function useDraggableScrollLock() {
|
|
|
15
15
|
scrollLock.value = false;
|
|
16
16
|
}
|
|
17
17
|
function addScrollLockPadding() {
|
|
18
|
-
if (typeof window === "undefined")
|
|
18
|
+
if (typeof window === "undefined") {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
19
21
|
const exclude = new RegExp(/magic-draggable/);
|
|
20
22
|
document.body.style.setProperty(
|
|
21
23
|
"--scrollbar-width",
|