@maas/vue-equipment 1.0.0-beta.13 → 1.0.0-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nuxt/module.json +1 -1
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionContent.vue +65 -82
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionContent.vue.d.ts +2 -2
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionProvider.vue +24 -30
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionTrigger.vue +65 -61
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionTrigger.vue.d.ts +1 -1
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionView.vue +41 -45
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionView.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandContent.vue +137 -150
- package/dist/plugins/MagicCommand/src/components/MagicCommandContent.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandDrawer.vue +45 -52
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.vue +80 -82
- package/dist/plugins/MagicCommand/src/components/MagicCommandItem.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandModal.vue +40 -47
- package/dist/plugins/MagicCommand/src/components/MagicCommandProvider.vue +68 -74
- package/dist/plugins/MagicCommand/src/components/MagicCommandRenderer.vue +22 -38
- package/dist/plugins/MagicCommand/src/components/MagicCommandTrigger.vue +95 -85
- package/dist/plugins/MagicCommand/src/components/MagicCommandTrigger.vue.d.ts +1 -1
- package/dist/plugins/MagicCommand/src/components/MagicCommandView.vue +41 -47
- package/dist/plugins/MagicCommand/src/components/MagicCommandView.vue.d.ts +1 -1
- package/dist/plugins/MagicCookie/src/components/MagicCookieItem.vue +41 -39
- package/dist/plugins/MagicCookie/src/components/MagicCookieItem.vue.d.ts +2 -2
- package/dist/plugins/MagicCookie/src/components/MagicCookieProvider.vue +23 -34
- package/dist/plugins/MagicCookie/src/components/MagicCookieView.vue +40 -73
- package/dist/plugins/MagicCookie/src/components/MagicCookieView.vue.d.ts +1 -1
- package/dist/plugins/MagicDraggable/src/components/MagicDraggable.vue +70 -87
- package/dist/plugins/MagicDraggable/src/components/MagicDraggable.vue.d.ts +7 -7
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue +262 -304
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue.d.ts +12 -12
- package/dist/plugins/MagicEmitter/src/composables/useMagicEmitter.d.ts +100 -100
- package/dist/plugins/MagicMarquee/src/components/MagicMarquee.vue +41 -69
- package/dist/plugins/MagicMarquee/src/composables/useMagicMarquee.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuChannel.vue +54 -59
- package/dist/plugins/MagicMenu/src/components/MagicMenuChannel.vue.d.ts +2 -2
- package/dist/plugins/MagicMenu/src/components/MagicMenuContent.vue +188 -208
- package/dist/plugins/MagicMenu/src/components/MagicMenuContent.vue.d.ts +3 -3
- package/dist/plugins/MagicMenu/src/components/MagicMenuFloat.vue +181 -194
- package/dist/plugins/MagicMenu/src/components/MagicMenuItem.vue +91 -100
- package/dist/plugins/MagicMenu/src/components/MagicMenuItem.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuProvider.vue +83 -85
- package/dist/plugins/MagicMenu/src/components/MagicMenuRemote.vue +79 -75
- package/dist/plugins/MagicMenu/src/components/MagicMenuRemote.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuTrigger.vue +106 -105
- package/dist/plugins/MagicMenu/src/components/MagicMenuTrigger.vue.d.ts +1 -1
- package/dist/plugins/MagicMenu/src/components/MagicMenuView.vue +54 -60
- package/dist/plugins/MagicMenu/src/components/MagicMenuView.vue.d.ts +1 -1
- package/dist/plugins/MagicModal/src/components/MagicModal.vue +136 -164
- package/dist/plugins/MagicModal/src/components/MagicModal.vue.d.ts +1 -1
- package/dist/plugins/MagicNoise/src/components/MagicNoise.vue +53 -78
- package/dist/plugins/MagicPie/src/components/MagicPie.vue +147 -175
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudio.vue +49 -65
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerAudioControls.vue +87 -129
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerDisplayTime.vue +33 -41
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerMuxPopover.vue +99 -109
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerOverlay.vue +47 -75
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerPoster.vue +16 -31
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerProvider.vue +43 -44
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerTimeline.vue +52 -109
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideo.vue +65 -72
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerVideoControls.vue +154 -225
- package/dist/plugins/MagicPlayer/src/composables/useMagicPlayer.d.ts +1 -1
- package/dist/plugins/MagicScroll/src/components/MagicScrollCollision.vue +49 -59
- package/dist/plugins/MagicScroll/src/components/MagicScrollMotion.vue +63 -70
- package/dist/plugins/MagicScroll/src/components/MagicScrollProvider.vue +29 -33
- package/dist/plugins/MagicScroll/src/components/MagicScrollScene.vue +59 -69
- package/dist/plugins/MagicToast/src/components/MagicToastProvider.vue +80 -95
- package/dist/plugins/MagicToast/src/components/MagicToastView.vue +52 -70
- package/dist/plugins/MagicToast/src/components/MagicToastView.vue.d.ts +2 -2
- package/package.json +1 -1
- package/dist/plugins/MagicAccordion/demo/data/footer.json +0 -117
- package/dist/plugins/MagicCommand/demo/data/about.json +0 -3
- package/dist/plugins/MagicCommand/demo/data/search.json +0 -594
package/dist/nuxt/module.json
CHANGED
|
@@ -1,11 +1,34 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div
|
|
3
|
+
class="magic-accordion-content"
|
|
4
|
+
:data-active="view?.active"
|
|
5
|
+
:style="{ '--ma-duration': `${state.options.animation?.duration}ms` }"
|
|
6
|
+
>
|
|
7
|
+
<auto-size
|
|
8
|
+
:width="false"
|
|
9
|
+
:duration="mappedAnimation.duration"
|
|
10
|
+
:easing="mappedAnimation.easing"
|
|
11
|
+
>
|
|
12
|
+
<transition
|
|
13
|
+
:name="mappedTransition"
|
|
14
|
+
:on-before-enter="onBeforeEnter"
|
|
15
|
+
:on-enter="onEnter"
|
|
16
|
+
:on-after-enter="onAfterEnter"
|
|
17
|
+
:on-before-leave="onBeforeLeave"
|
|
18
|
+
:on-leave="onLeave"
|
|
19
|
+
:on-after-leave="onAfterLeave"
|
|
20
|
+
>
|
|
21
|
+
<primitive v-show="view?.active" :as-child="asChild">
|
|
22
|
+
<slot :view-active="view?.active" />
|
|
23
|
+
</primitive>
|
|
24
|
+
</transition>
|
|
25
|
+
</auto-size>
|
|
26
|
+
</div>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<script setup>
|
|
5
30
|
import { inject, computed } from "vue";
|
|
6
31
|
import { defu } from "defu";
|
|
7
|
-
import { AutoSize } from "@maas/vue-autosize";
|
|
8
|
-
import { Primitive } from "@maas/vue-primitive";
|
|
9
32
|
import { useAccordionView } from "../composables/private/useAccordionView";
|
|
10
33
|
import { useAccordionState } from "../composables/private/useAccordionState";
|
|
11
34
|
import { useAccordionCallback } from "../composables/private/useAccordionCallback";
|
|
@@ -13,85 +36,45 @@ import { MagicAccordionInstanceId, MagicAccordionViewId } from "../symbols";
|
|
|
13
36
|
import "@maas/vue-equipment/utils/css/animations/fade-in.css";
|
|
14
37
|
import "@maas/vue-equipment/utils/css/animations/auto-size-out.css";
|
|
15
38
|
import "@maas/vue-equipment/utils/css/easings.css";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
39
|
+
const { transition, animation } = defineProps({
|
|
40
|
+
asChild: {
|
|
41
|
+
type: Boolean,
|
|
42
|
+
required: false
|
|
43
|
+
},
|
|
44
|
+
transition: {
|
|
45
|
+
type: String,
|
|
46
|
+
required: false
|
|
22
47
|
},
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (!instanceId) {
|
|
27
|
-
throw new Error("MagicMenuContent must be nested inside MagicMenuProvider");
|
|
28
|
-
}
|
|
29
|
-
if (!viewId) {
|
|
30
|
-
throw new Error("MagicMenuContent must be nested inside MagicMenuView");
|
|
31
|
-
}
|
|
32
|
-
const { initializeState } = useAccordionState(instanceId);
|
|
33
|
-
const state = initializeState();
|
|
34
|
-
const { getView } = useAccordionView(instanceId);
|
|
35
|
-
const view = getView(viewId);
|
|
36
|
-
const mappedTransition = computed(() => __props.transition ?? state.options.transition);
|
|
37
|
-
const mappedAnimation = computed(() => defu(__props.animation, state.options.animation));
|
|
38
|
-
const {
|
|
39
|
-
onBeforeEnter,
|
|
40
|
-
onEnter,
|
|
41
|
-
onAfterEnter,
|
|
42
|
-
onBeforeLeave,
|
|
43
|
-
onLeave,
|
|
44
|
-
onAfterLeave
|
|
45
|
-
} = useAccordionCallback({
|
|
46
|
-
instanceId,
|
|
47
|
-
viewId
|
|
48
|
-
});
|
|
49
|
-
return (_ctx, _cache) => {
|
|
50
|
-
return _openBlock(), _createElementBlock("div", {
|
|
51
|
-
class: "magic-accordion-content",
|
|
52
|
-
"data-active": _unref(view)?.active,
|
|
53
|
-
style: _normalizeStyle({ "--ma-duration": `${_unref(state).options.animation?.duration}ms` })
|
|
54
|
-
}, [
|
|
55
|
-
_createVNode(_unref(AutoSize), {
|
|
56
|
-
width: false,
|
|
57
|
-
duration: mappedAnimation.value.duration,
|
|
58
|
-
easing: mappedAnimation.value.easing
|
|
59
|
-
}, {
|
|
60
|
-
default: _withCtx(() => [
|
|
61
|
-
_createVNode(_Transition, {
|
|
62
|
-
name: mappedTransition.value,
|
|
63
|
-
"on-before-enter": _unref(onBeforeEnter),
|
|
64
|
-
"on-enter": _unref(onEnter),
|
|
65
|
-
"on-after-enter": _unref(onAfterEnter),
|
|
66
|
-
"on-before-leave": _unref(onBeforeLeave),
|
|
67
|
-
"on-leave": _unref(onLeave),
|
|
68
|
-
"on-after-leave": _unref(onAfterLeave),
|
|
69
|
-
persisted: ""
|
|
70
|
-
}, {
|
|
71
|
-
default: _withCtx(() => [
|
|
72
|
-
_withDirectives(_createVNode(_unref(Primitive), { "as-child": _ctx.asChild }, {
|
|
73
|
-
default: _withCtx(() => [
|
|
74
|
-
_renderSlot(_ctx.$slots, "default", {
|
|
75
|
-
viewActive: _unref(view)?.active
|
|
76
|
-
})
|
|
77
|
-
]),
|
|
78
|
-
_: 3
|
|
79
|
-
/* FORWARDED */
|
|
80
|
-
}, 8, ["as-child"]), [
|
|
81
|
-
[_vShow, _unref(view)?.active]
|
|
82
|
-
])
|
|
83
|
-
]),
|
|
84
|
-
_: 3
|
|
85
|
-
/* FORWARDED */
|
|
86
|
-
}, 8, ["name", "on-before-enter", "on-enter", "on-after-enter", "on-before-leave", "on-leave", "on-after-leave"])
|
|
87
|
-
]),
|
|
88
|
-
_: 3
|
|
89
|
-
/* FORWARDED */
|
|
90
|
-
}, 8, ["duration", "easing"])
|
|
91
|
-
], 12, _hoisted_1);
|
|
92
|
-
};
|
|
48
|
+
animation: {
|
|
49
|
+
type: Object,
|
|
50
|
+
required: false
|
|
93
51
|
}
|
|
94
52
|
});
|
|
53
|
+
const instanceId = inject(MagicAccordionInstanceId, void 0);
|
|
54
|
+
const viewId = inject(MagicAccordionViewId, void 0);
|
|
55
|
+
if (!instanceId) {
|
|
56
|
+
throw new Error("MagicMenuContent must be nested inside MagicMenuProvider");
|
|
57
|
+
}
|
|
58
|
+
if (!viewId) {
|
|
59
|
+
throw new Error("MagicMenuContent must be nested inside MagicMenuView");
|
|
60
|
+
}
|
|
61
|
+
const { initializeState } = useAccordionState(instanceId);
|
|
62
|
+
const state = initializeState();
|
|
63
|
+
const { getView } = useAccordionView(instanceId);
|
|
64
|
+
const view = getView(viewId);
|
|
65
|
+
const mappedTransition = computed(() => transition ?? state.options.transition);
|
|
66
|
+
const mappedAnimation = computed(() => defu(animation, state.options.animation));
|
|
67
|
+
const {
|
|
68
|
+
onBeforeEnter,
|
|
69
|
+
onEnter,
|
|
70
|
+
onAfterEnter,
|
|
71
|
+
onBeforeLeave,
|
|
72
|
+
onLeave,
|
|
73
|
+
onAfterLeave
|
|
74
|
+
} = useAccordionCallback({
|
|
75
|
+
instanceId,
|
|
76
|
+
viewId
|
|
77
|
+
});
|
|
95
78
|
</script>
|
|
96
79
|
|
|
97
80
|
<style>
|
|
@@ -11,8 +11,8 @@ interface MagicAccordionContentProps {
|
|
|
11
11
|
easing: (t: number) => number;
|
|
12
12
|
};
|
|
13
13
|
}
|
|
14
|
-
declare const state: import("../types").AccordionState;
|
|
15
|
-
declare const view: import("../types").AccordionView | undefined;
|
|
14
|
+
declare const state: import("../types/index.js").AccordionState;
|
|
15
|
+
declare const view: import("../types/index.js").AccordionView | undefined;
|
|
16
16
|
declare const mappedTransition: import("vue").ComputedRef<string | undefined>;
|
|
17
17
|
declare const mappedAnimation: import("vue").ComputedRef<{
|
|
18
18
|
duration: number;
|
|
@@ -1,37 +1,31 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<primitive :data-id="id" :as-child="asChild" class="magic-accordion-provider">
|
|
3
|
+
<slot />
|
|
4
|
+
</primitive>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup>
|
|
4
8
|
import { onBeforeUnmount, provide } from "vue";
|
|
5
|
-
import { Primitive } from "@maas/vue-primitive";
|
|
6
9
|
import { MagicAccordionInstanceId } from "../symbols";
|
|
7
10
|
import { useAccordionState } from "../composables/private/useAccordionState";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
asChild: { type: Boolean, required: false },
|
|
13
|
-
options: { type: Object, required: false }
|
|
11
|
+
const { id, asChild, options } = defineProps({
|
|
12
|
+
id: {
|
|
13
|
+
type: null,
|
|
14
|
+
required: true
|
|
14
15
|
},
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return (_ctx, _cache) => {
|
|
23
|
-
return _openBlock(), _createBlock(_unref(Primitive), {
|
|
24
|
-
"data-id": _ctx.id,
|
|
25
|
-
"as-child": _ctx.asChild,
|
|
26
|
-
class: "magic-accordion-provider"
|
|
27
|
-
}, {
|
|
28
|
-
default: _withCtx(() => [
|
|
29
|
-
_renderSlot(_ctx.$slots, "default")
|
|
30
|
-
]),
|
|
31
|
-
_: 3
|
|
32
|
-
/* FORWARDED */
|
|
33
|
-
}, 8, ["data-id", "as-child"]);
|
|
34
|
-
};
|
|
16
|
+
asChild: {
|
|
17
|
+
type: Boolean,
|
|
18
|
+
required: false
|
|
19
|
+
},
|
|
20
|
+
options: {
|
|
21
|
+
type: Object,
|
|
22
|
+
required: false
|
|
35
23
|
}
|
|
36
24
|
});
|
|
25
|
+
const { deleteState, initializeState } = useAccordionState(id);
|
|
26
|
+
initializeState(options);
|
|
27
|
+
onBeforeUnmount(() => {
|
|
28
|
+
deleteState();
|
|
29
|
+
});
|
|
30
|
+
provide(MagicAccordionInstanceId, id);
|
|
37
31
|
</script>
|
|
@@ -1,73 +1,77 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<primitive
|
|
3
|
+
ref="el"
|
|
4
|
+
:as-child="asChild"
|
|
5
|
+
:data-id="`${mappedViewId}-trigger`"
|
|
6
|
+
:data-disabled="mappedDisabled"
|
|
7
|
+
as="button"
|
|
8
|
+
class="magic-accordion-trigger"
|
|
9
|
+
@mouseenter="onMouseenter"
|
|
10
|
+
@click="onClick"
|
|
11
|
+
>
|
|
12
|
+
<slot :view-active="view?.active" />
|
|
13
|
+
</primitive>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script setup>
|
|
4
17
|
import { useTemplateRef, inject, computed, toValue } from "vue";
|
|
5
|
-
import { Primitive } from "@maas/vue-primitive";
|
|
6
18
|
import { onKeyStroke } from "@vueuse/core";
|
|
7
19
|
import { useAccordionTrigger } from "../composables/private/useAccordionTrigger";
|
|
8
20
|
import { useAccordionState } from "../composables/private/useAccordionState";
|
|
9
21
|
import { useAccordionView } from "../composables/private/useAccordionView";
|
|
10
22
|
import { MagicAccordionInstanceId, MagicAccordionViewId } from "../symbols";
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
23
|
+
const {
|
|
24
|
+
viewId,
|
|
25
|
+
disabled = false,
|
|
26
|
+
trigger = "click",
|
|
27
|
+
asChild = false
|
|
28
|
+
} = defineProps({
|
|
29
|
+
viewId: {
|
|
30
|
+
type: String,
|
|
31
|
+
required: false
|
|
32
|
+
},
|
|
33
|
+
disabled: {
|
|
34
|
+
type: null,
|
|
35
|
+
required: false
|
|
36
|
+
},
|
|
37
|
+
trigger: {
|
|
38
|
+
type: String,
|
|
39
|
+
required: false
|
|
18
40
|
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const injectedViewId = inject(MagicAccordionViewId, void 0);
|
|
23
|
-
const mappedViewId = computed(() => __props.viewId ?? injectedViewId);
|
|
24
|
-
if (!instanceId) {
|
|
25
|
-
throw new Error(
|
|
26
|
-
"MagicAccordionTrigger must be nested inside MagicAccordionProvider"
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
if (!mappedViewId.value) {
|
|
30
|
-
throw new Error(
|
|
31
|
-
"MagicAccordionTrigger must be nested inside MagicAccordionView or a viewId must be provided"
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
const { initializeState } = useAccordionState(instanceId);
|
|
35
|
-
const state = initializeState();
|
|
36
|
-
const { getView } = useAccordionView(instanceId);
|
|
37
|
-
const view = getView(mappedViewId.value);
|
|
38
|
-
const mappedDisabled = computed(
|
|
39
|
-
() => toValue(__props.disabled) || state.options.disabled
|
|
40
|
-
);
|
|
41
|
-
const { onMouseenter, onClick, onEnter } = useAccordionTrigger({
|
|
42
|
-
elRef,
|
|
43
|
-
instanceId,
|
|
44
|
-
viewId: mappedViewId.value,
|
|
45
|
-
disabled: __props.disabled,
|
|
46
|
-
trigger: __props.trigger
|
|
47
|
-
});
|
|
48
|
-
onKeyStroke("Enter", onEnter);
|
|
49
|
-
return (_ctx, _cache) => {
|
|
50
|
-
return _openBlock(), _createBlock(_unref(Primitive), {
|
|
51
|
-
ref: "el",
|
|
52
|
-
"as-child": _ctx.asChild,
|
|
53
|
-
"data-id": `${mappedViewId.value}-trigger`,
|
|
54
|
-
"data-disabled": mappedDisabled.value,
|
|
55
|
-
as: "button",
|
|
56
|
-
class: "magic-accordion-trigger",
|
|
57
|
-
onMouseenter: _unref(onMouseenter),
|
|
58
|
-
onClick: _unref(onClick)
|
|
59
|
-
}, {
|
|
60
|
-
default: _withCtx(() => [
|
|
61
|
-
_renderSlot(_ctx.$slots, "default", {
|
|
62
|
-
viewActive: _unref(view)?.active
|
|
63
|
-
})
|
|
64
|
-
]),
|
|
65
|
-
_: 3
|
|
66
|
-
/* FORWARDED */
|
|
67
|
-
}, 8, ["as-child", "data-id", "data-disabled", "onMouseenter", "onClick"]);
|
|
68
|
-
};
|
|
41
|
+
asChild: {
|
|
42
|
+
type: Boolean,
|
|
43
|
+
required: false
|
|
69
44
|
}
|
|
70
45
|
});
|
|
46
|
+
const elRef = useTemplateRef("el");
|
|
47
|
+
const instanceId = inject(MagicAccordionInstanceId, void 0);
|
|
48
|
+
const injectedViewId = inject(MagicAccordionViewId, void 0);
|
|
49
|
+
const mappedViewId = computed(() => viewId ?? injectedViewId);
|
|
50
|
+
if (!instanceId) {
|
|
51
|
+
throw new Error(
|
|
52
|
+
"MagicAccordionTrigger must be nested inside MagicAccordionProvider"
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
if (!mappedViewId.value) {
|
|
56
|
+
throw new Error(
|
|
57
|
+
"MagicAccordionTrigger must be nested inside MagicAccordionView or a viewId must be provided"
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
const { initializeState } = useAccordionState(instanceId);
|
|
61
|
+
const state = initializeState();
|
|
62
|
+
const { getView } = useAccordionView(instanceId);
|
|
63
|
+
const view = getView(mappedViewId.value);
|
|
64
|
+
const mappedDisabled = computed(
|
|
65
|
+
() => toValue(disabled) || state.options.disabled
|
|
66
|
+
);
|
|
67
|
+
const { onMouseenter, onClick, onEnter } = useAccordionTrigger({
|
|
68
|
+
elRef,
|
|
69
|
+
instanceId,
|
|
70
|
+
viewId: mappedViewId.value,
|
|
71
|
+
disabled,
|
|
72
|
+
trigger
|
|
73
|
+
});
|
|
74
|
+
onKeyStroke("Enter", onEnter);
|
|
71
75
|
</script>
|
|
72
76
|
|
|
73
77
|
<style>
|
|
@@ -8,7 +8,7 @@ interface MagicAccordionTriggerProps {
|
|
|
8
8
|
asChild?: boolean;
|
|
9
9
|
}
|
|
10
10
|
declare const mappedViewId: import("vue").ComputedRef<string | undefined>;
|
|
11
|
-
declare const view: import("../types").AccordionView | undefined;
|
|
11
|
+
declare const view: import("../types/index.js").AccordionView | undefined;
|
|
12
12
|
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 () => {}>>;
|
|
@@ -1,56 +1,52 @@
|
|
|
1
|
-
<
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<primitive
|
|
3
|
+
:as-child="asChild"
|
|
4
|
+
:data-id="mappedId"
|
|
5
|
+
:data-active="view?.active"
|
|
6
|
+
class="magic-accordion-view"
|
|
7
|
+
>
|
|
8
|
+
<slot :view-active="view?.active" />
|
|
9
|
+
</primitive>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup>
|
|
4
13
|
import { computed, inject, onBeforeUnmount, provide, useId } from "vue";
|
|
5
|
-
import { Primitive } from "@maas/vue-primitive";
|
|
6
14
|
import {
|
|
7
15
|
MagicAccordionInstanceId,
|
|
8
16
|
MagicAccordionViewActive,
|
|
9
17
|
MagicAccordionViewId
|
|
10
18
|
} from "../symbols";
|
|
11
19
|
import { useAccordionView } from "../composables/private/useAccordionView";
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
asChild: { type: Boolean, required: false },
|
|
17
|
-
active: { type: Boolean, required: false }
|
|
20
|
+
const { id, active } = defineProps({
|
|
21
|
+
id: {
|
|
22
|
+
type: String,
|
|
23
|
+
required: false
|
|
18
24
|
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const mappedId = computed(() => __props.id ?? `magic-accordion-view-${useId()}`);
|
|
27
|
-
const mappedActive = computed(() => view.active);
|
|
28
|
-
const { initializeView, deleteView } = useAccordionView(instanceId);
|
|
29
|
-
const view = initializeView({
|
|
30
|
-
id: mappedId.value,
|
|
31
|
-
active: __props.active ?? false
|
|
32
|
-
});
|
|
33
|
-
provide(MagicAccordionViewId, mappedId.value);
|
|
34
|
-
provide(MagicAccordionViewActive, mappedActive);
|
|
35
|
-
onBeforeUnmount(() => {
|
|
36
|
-
deleteView(mappedId.value);
|
|
37
|
-
});
|
|
38
|
-
return (_ctx, _cache) => {
|
|
39
|
-
return _openBlock(), _createBlock(_unref(Primitive), {
|
|
40
|
-
"as-child": _ctx.asChild,
|
|
41
|
-
"data-id": mappedId.value,
|
|
42
|
-
"data-active": _unref(view)?.active,
|
|
43
|
-
class: "magic-accordion-view"
|
|
44
|
-
}, {
|
|
45
|
-
default: _withCtx(() => [
|
|
46
|
-
_renderSlot(_ctx.$slots, "default", {
|
|
47
|
-
viewActive: _unref(view)?.active
|
|
48
|
-
})
|
|
49
|
-
]),
|
|
50
|
-
_: 3
|
|
51
|
-
/* FORWARDED */
|
|
52
|
-
}, 8, ["as-child", "data-id", "data-active"]);
|
|
53
|
-
};
|
|
25
|
+
asChild: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
required: false
|
|
28
|
+
},
|
|
29
|
+
active: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
required: false
|
|
54
32
|
}
|
|
55
33
|
});
|
|
34
|
+
const instanceId = inject(MagicAccordionInstanceId, void 0);
|
|
35
|
+
if (!instanceId) {
|
|
36
|
+
throw new Error(
|
|
37
|
+
"MagicAccordionView must be nested inside MagicAccordionProvider"
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
const mappedId = computed(() => id ?? `magic-accordion-view-${useId()}`);
|
|
41
|
+
const mappedActive = computed(() => view.active);
|
|
42
|
+
const { initializeView, deleteView } = useAccordionView(instanceId);
|
|
43
|
+
const view = initializeView({
|
|
44
|
+
id: mappedId.value,
|
|
45
|
+
active: active ?? false
|
|
46
|
+
});
|
|
47
|
+
provide(MagicAccordionViewId, mappedId.value);
|
|
48
|
+
provide(MagicAccordionViewActive, mappedActive);
|
|
49
|
+
onBeforeUnmount(() => {
|
|
50
|
+
deleteView(mappedId.value);
|
|
51
|
+
});
|
|
56
52
|
</script>
|
|
@@ -5,7 +5,7 @@ interface MagicAccordionViewProps {
|
|
|
5
5
|
active?: boolean;
|
|
6
6
|
}
|
|
7
7
|
declare const mappedId: import("vue").ComputedRef<string>;
|
|
8
|
-
declare const view: import("../types").AccordionView;
|
|
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
11
|
viewActive: boolean;
|