@maas/vue-equipment 0.30.7 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nuxt/module.json +1 -1
- package/dist/nuxt/module.mjs +8 -1
- package/dist/plugins/MagicAccordion/index.d.ts +5 -0
- package/dist/plugins/MagicAccordion/index.mjs +25 -0
- package/dist/plugins/MagicAccordion/nuxt.d.ts +2 -0
- package/dist/plugins/MagicAccordion/nuxt.mjs +23 -0
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionContent.vue +72 -0
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionContent.vue.d.ts +26 -0
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionProvider.vue +31 -0
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionProvider.vue.d.ts +27 -0
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionTrigger.vue +71 -0
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionTrigger.vue.d.ts +47 -0
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionView.vue +55 -0
- package/dist/plugins/MagicAccordion/src/components/MagicAccordionView.vue.d.ts +25 -0
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionCallback.d.ts +14 -0
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionCallback.mjs +32 -0
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionState.d.ts +7 -0
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionState.mjs +42 -0
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionTrigger.d.ts +16 -0
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionTrigger.mjs +35 -0
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionView.d.ts +12 -0
- package/dist/plugins/MagicAccordion/src/composables/private/useAccordionView.mjs +60 -0
- package/dist/plugins/MagicAccordion/src/composables/useMagicAccordion.d.ts +10 -0
- package/dist/plugins/MagicAccordion/src/composables/useMagicAccordion.mjs +9 -0
- package/dist/plugins/MagicAccordion/src/symbols/index.d.ts +5 -0
- package/dist/plugins/MagicAccordion/src/symbols/index.mjs +8 -0
- package/dist/plugins/MagicAccordion/src/types/index.d.ts +43 -0
- package/dist/plugins/MagicAccordion/src/types/index.mjs +0 -0
- package/dist/plugins/MagicAccordion/src/utils/defaultOptions.d.ts +4 -0
- package/dist/plugins/MagicAccordion/src/utils/defaultOptions.mjs +6 -0
- package/dist/plugins/MagicAutoSize/src/components/MagicAutoSize.vue +43 -4
- package/dist/plugins/MagicAutoSize/src/components/MagicAutoSize.vue.d.ts +5 -1
- package/dist/plugins/MagicDrawer/src/components/MagicDrawer.vue +3 -1
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.d.ts +2 -45
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerState.mjs +3 -2
- package/dist/plugins/MagicDrawer/src/composables/useMagicDrawer.mjs +5 -8
- package/dist/plugins/MagicDrawer/src/types/index.d.ts +1 -0
- package/dist/plugins/MagicEmitter/src/composables/useMagicEmitter.d.ts +376 -118
- package/dist/plugins/MagicEmitter/src/types/index.d.ts +2 -0
- package/dist/plugins/MagicMenu/index.d.ts +2 -2
- package/dist/plugins/MagicMenu/index.mjs +14 -2
- package/dist/plugins/MagicMenu/src/components/MagicMenuContent.vue +15 -4
- package/dist/plugins/MagicMenu/src/components/MagicMenuFloat.vue +8 -0
- package/dist/plugins/MagicMenu/src/composables/private/useMenuCallback.d.ts +3 -1
- package/dist/plugins/MagicMenu/src/composables/private/useMenuCallback.mjs +29 -29
- package/dist/plugins/MagicMenu/src/composables/private/useMenuTrigger.mjs +9 -13
- package/dist/plugins/MagicMenu/src/composables/private/useMenuView.mjs +6 -6
- package/dist/plugins/MagicMenu/src/types/index.d.ts +33 -8
- package/dist/plugins/MagicMenu/src/utils/defaultOptions.d.ts +2 -3
- package/dist/plugins/MagicMenu/src/utils/modeDelayDefaults.d.ts +15 -0
- package/dist/plugins/MagicMenu/src/utils/modeDelayDefaults.mjs +18 -0
- package/dist/plugins/MagicMenu/src/utils/modeFloatingStrategyDefaults.d.ts +6 -0
- package/dist/plugins/MagicMenu/src/utils/modeFloatingStrategyDefaults.mjs +7 -0
- package/dist/plugins/MagicMenu/src/utils/modeScrollLockDefaults.d.ts +12 -0
- package/dist/plugins/MagicMenu/src/utils/modeScrollLockDefaults.mjs +13 -0
- package/dist/plugins/MagicPlayer/src/components/MagicPlayerOverlay.vue +1 -1
- package/dist/plugins/MagicScroll/src/symbols/index.d.ts +2 -2
- package/dist/plugins/MagicToast/src/composables/private/useToastApi.d.ts +1 -1
- package/dist/plugins/MagicToast/src/composables/private/useToastStore.d.ts +14 -4
- package/dist/plugins/MagicToast/src/composables/useMagicToast.d.ts +5 -5
- package/dist/plugins/index.d.ts +1 -0
- package/dist/plugins/index.mjs +1 -0
- package/dist/utils/css/easings.css +4 -0
- package/package.json +1 -1
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerStore.d.ts +0 -5
- package/dist/plugins/MagicDrawer/src/composables/private/useDrawerStore.mjs +0 -15
- /package/dist/plugins/MagicMenu/src/utils/{modeTransitions.d.ts → modeTransitionDefaults.d.ts} +0 -0
- /package/dist/plugins/MagicMenu/src/utils/{modeTransitions.mjs → modeTransitionDefaults.mjs} +0 -0
package/dist/nuxt/module.json
CHANGED
package/dist/nuxt/module.mjs
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { defineNuxtModule, createResolver, extendViteConfig, installModule, addImportsSources } from '@nuxt/kit';
|
|
2
2
|
|
|
3
3
|
const functions$1 = [
|
|
4
|
+
{
|
|
5
|
+
name: "MagicAccordion",
|
|
6
|
+
"package": "plugins",
|
|
7
|
+
lastUpdated: 1720627049000,
|
|
8
|
+
docs: "https://maas.egineering/vue-equipment/plugins/MagicAccordion/",
|
|
9
|
+
description: "accordion"
|
|
10
|
+
},
|
|
4
11
|
{
|
|
5
12
|
name: "MagicAutoSize",
|
|
6
13
|
"package": "plugins",
|
|
@@ -53,7 +60,7 @@ const functions$1 = [
|
|
|
53
60
|
{
|
|
54
61
|
name: "MagicMenu",
|
|
55
62
|
"package": "plugins",
|
|
56
|
-
lastUpdated:
|
|
63
|
+
lastUpdated: 1720627185000,
|
|
57
64
|
docs: "https://maas.egineering/vue-equipment/plugins/MagicMenu/",
|
|
58
65
|
description: "menu"
|
|
59
66
|
},
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { Plugin } from 'vue';
|
|
2
|
+
import { useMagicAccordion } from './src/composables/useMagicAccordion.js';
|
|
3
|
+
import { MagicAccordionInstanceId, MagicAccordionViewId, MagicAccordionViewActive } from './src/symbols/index.js';
|
|
4
|
+
declare const MagicAccordionPlugin: Plugin;
|
|
5
|
+
export { MagicAccordionPlugin, useMagicAccordion, MagicAccordionInstanceId, MagicAccordionViewId, MagicAccordionViewActive, };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import MagicAccordionContent from "./src/components/MagicAccordionContent.vue";
|
|
2
|
+
import MagicAccordionProvider from "./src/components/MagicAccordionProvider.vue";
|
|
3
|
+
import MagicAccordionTrigger from "./src/components/MagicAccordionTrigger.vue";
|
|
4
|
+
import MagicAccordionView from "./src/components/MagicAccordionView.vue";
|
|
5
|
+
import { useMagicAccordion } from "./src/composables/useMagicAccordion.mjs";
|
|
6
|
+
import {
|
|
7
|
+
MagicAccordionInstanceId,
|
|
8
|
+
MagicAccordionViewId,
|
|
9
|
+
MagicAccordionViewActive
|
|
10
|
+
} from "./src/symbols/index.mjs";
|
|
11
|
+
const MagicAccordionPlugin = {
|
|
12
|
+
install: (app) => {
|
|
13
|
+
app.component("MagicAccordionContent", MagicAccordionContent);
|
|
14
|
+
app.component("MagicAccordionProvider", MagicAccordionProvider);
|
|
15
|
+
app.component("MagicAccordionTrigger", MagicAccordionTrigger);
|
|
16
|
+
app.component("MagicAccordionView", MagicAccordionView);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export {
|
|
20
|
+
MagicAccordionPlugin,
|
|
21
|
+
useMagicAccordion,
|
|
22
|
+
MagicAccordionInstanceId,
|
|
23
|
+
MagicAccordionViewId,
|
|
24
|
+
MagicAccordionViewActive
|
|
25
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {
|
|
2
|
+
defineNuxtModule,
|
|
3
|
+
createResolver,
|
|
4
|
+
addComponentsDir,
|
|
5
|
+
addImports
|
|
6
|
+
} from "@nuxt/kit";
|
|
7
|
+
export default defineNuxtModule({
|
|
8
|
+
meta: {
|
|
9
|
+
name: "@maas/vue-equipment/nuxt/MagicAccordion"
|
|
10
|
+
},
|
|
11
|
+
setup() {
|
|
12
|
+
const resolver = createResolver(import.meta.url);
|
|
13
|
+
addComponentsDir({
|
|
14
|
+
path: resolver.resolve("src/components"),
|
|
15
|
+
global: true,
|
|
16
|
+
pathPrefix: false
|
|
17
|
+
});
|
|
18
|
+
addImports({
|
|
19
|
+
from: "@maas/vue-equipment/plugins/MagicAccordion",
|
|
20
|
+
name: "useMagicAccordion"
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="['magic-accordion-content', { '-active': isActive }]">
|
|
3
|
+
<magic-auto-size :immediate="true">
|
|
4
|
+
<transition
|
|
5
|
+
:name="state.options.transition"
|
|
6
|
+
:on-before-enter="onBeforeEnter"
|
|
7
|
+
:on-enter="onEnter"
|
|
8
|
+
:on-after-enter="onAfterEnter"
|
|
9
|
+
:on-before-leave="onBeforeLeave"
|
|
10
|
+
:on-leave="onLeave"
|
|
11
|
+
:on-after-leave="onAfterLeave"
|
|
12
|
+
>
|
|
13
|
+
<primitive :as-child="asChild" v-if="isActive">
|
|
14
|
+
<slot />
|
|
15
|
+
</primitive>
|
|
16
|
+
</transition>
|
|
17
|
+
</magic-auto-size>
|
|
18
|
+
</div>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script lang="ts" setup>
|
|
22
|
+
import { computed, inject } from 'vue'
|
|
23
|
+
import { Primitive } from '@maas/vue-primitive'
|
|
24
|
+
import { useAccordionView } from '../composables/private/useAccordionView'
|
|
25
|
+
import { useAccordionState } from '../composables/private/useAccordionState'
|
|
26
|
+
import { useAccordionCallback } from '../composables/private/useAccordionCallback'
|
|
27
|
+
import { MagicAccordionInstanceId, MagicAccordionViewId } from '../symbols'
|
|
28
|
+
|
|
29
|
+
import '@maas/vue-equipment/utils/css/animations/fade-in.css'
|
|
30
|
+
import '@maas/vue-equipment/utils/css/easings.css'
|
|
31
|
+
|
|
32
|
+
interface MagicAccordionContentProps {
|
|
33
|
+
asChild?: boolean
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
defineProps<MagicAccordionContentProps>()
|
|
37
|
+
|
|
38
|
+
const instanceId = inject(MagicAccordionInstanceId, undefined)
|
|
39
|
+
const viewId = inject(MagicAccordionViewId, undefined)
|
|
40
|
+
|
|
41
|
+
if (!instanceId) {
|
|
42
|
+
throw new Error('MagicMenuContent must be nested inside MagicMenuProvider')
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!viewId) {
|
|
46
|
+
throw new Error('MagicMenuContent must be nested inside MagicMenuView')
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const { initializeState } = useAccordionState(instanceId)
|
|
50
|
+
const state = initializeState()
|
|
51
|
+
|
|
52
|
+
const { getView } = useAccordionView(instanceId)
|
|
53
|
+
const view = getView(viewId)
|
|
54
|
+
|
|
55
|
+
const isActive = computed(() => view?.active)
|
|
56
|
+
|
|
57
|
+
const {
|
|
58
|
+
onBeforeEnter,
|
|
59
|
+
onEnter,
|
|
60
|
+
onAfterEnter,
|
|
61
|
+
onBeforeLeave,
|
|
62
|
+
onLeave,
|
|
63
|
+
onAfterLeave,
|
|
64
|
+
} = useAccordionCallback({
|
|
65
|
+
instanceId,
|
|
66
|
+
viewId,
|
|
67
|
+
})
|
|
68
|
+
</script>
|
|
69
|
+
|
|
70
|
+
<style>
|
|
71
|
+
:root{--magic-accordion-enter-animation:fade-in 150ms var(--ease-in-out);--magic-accordion-leave-animation:none 200ms var(--ease-in-out-sharp);--magic-accordion-size-transition:all 200ms var(--ease-in-out-sharp);--magic-accordion-content-clip-path:inset(0)}.magic-accordion-content{--magic-auto-size-transition:var(--magic-accordion-size-transition);clip-path:var(--magic-accordion-content-clip-path)}.magic-accordion-enter-active{animation:var(--magic-accordion-enter-animation);position:relative}.magic-accordion-leave-active{animation:var(--magic-accordion-leave-animation)}
|
|
72
|
+
</style>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import '@maas/vue-equipment/utils/css/animations/fade-in.css';
|
|
2
|
+
import '@maas/vue-equipment/utils/css/easings.css';
|
|
3
|
+
interface MagicAccordionContentProps {
|
|
4
|
+
asChild?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare function __VLS_template(): {
|
|
7
|
+
default?(_: {}): any;
|
|
8
|
+
};
|
|
9
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_TypePropsToOption<MagicAccordionContentProps>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<MagicAccordionContentProps>>>, {}, {}>;
|
|
10
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
11
|
+
export default _default;
|
|
12
|
+
|
|
13
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
14
|
+
new (): {
|
|
15
|
+
$slots: S;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
19
|
+
type __VLS_TypePropsToOption<T> = {
|
|
20
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
21
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
22
|
+
} : {
|
|
23
|
+
type: import('vue').PropType<T[K]>;
|
|
24
|
+
required: true;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<primitive :as-child="asChild" class="magic-accordion-provider">
|
|
3
|
+
<slot />
|
|
4
|
+
</primitive>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script lang="ts" setup>
|
|
8
|
+
import { onBeforeUnmount, provide, type MaybeRef } from 'vue'
|
|
9
|
+
import { Primitive } from '@maas/vue-primitive'
|
|
10
|
+
import { MagicAccordionInstanceId } from '../symbols'
|
|
11
|
+
import type { MagicAccordionOptions } from '../types'
|
|
12
|
+
import { useAccordionState } from '../composables/private/useAccordionState'
|
|
13
|
+
|
|
14
|
+
interface MagicAccordionProviderProps {
|
|
15
|
+
id: MaybeRef<string>
|
|
16
|
+
asChild?: boolean
|
|
17
|
+
options?: MagicAccordionOptions
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const props = defineProps<MagicAccordionProviderProps>()
|
|
21
|
+
|
|
22
|
+
const { deleteState, initializeState } = useAccordionState(props.id)
|
|
23
|
+
initializeState()
|
|
24
|
+
|
|
25
|
+
// Lifecycle
|
|
26
|
+
onBeforeUnmount(() => {
|
|
27
|
+
deleteState()
|
|
28
|
+
})
|
|
29
|
+
|
|
30
|
+
provide(MagicAccordionInstanceId, props.id)
|
|
31
|
+
</script>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type MaybeRef } from 'vue';
|
|
2
|
+
import type { MagicAccordionOptions } from '../types';
|
|
3
|
+
interface MagicAccordionProviderProps {
|
|
4
|
+
id: MaybeRef<string>;
|
|
5
|
+
asChild?: boolean;
|
|
6
|
+
options?: MagicAccordionOptions;
|
|
7
|
+
}
|
|
8
|
+
declare function __VLS_template(): {
|
|
9
|
+
default?(_: {}): any;
|
|
10
|
+
};
|
|
11
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_TypePropsToOption<MagicAccordionProviderProps>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<MagicAccordionProviderProps>>>, {}, {}>;
|
|
12
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
13
|
+
export default _default;
|
|
14
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
15
|
+
new (): {
|
|
16
|
+
$slots: S;
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
20
|
+
type __VLS_TypePropsToOption<T> = {
|
|
21
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
22
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
23
|
+
} : {
|
|
24
|
+
type: import('vue').PropType<T[K]>;
|
|
25
|
+
required: true;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<primitive
|
|
3
|
+
:class="['magic-accordion-trigger', { '-disabled': mappedDisabled }]"
|
|
4
|
+
:as-child="asChild"
|
|
5
|
+
as="button"
|
|
6
|
+
ref="elRef"
|
|
7
|
+
@mouseeenter="onMouseenter"
|
|
8
|
+
@click="onClick"
|
|
9
|
+
>
|
|
10
|
+
<slot />
|
|
11
|
+
</primitive>
|
|
12
|
+
</template>
|
|
13
|
+
|
|
14
|
+
<script lang="ts" setup>
|
|
15
|
+
import { inject, ref, computed, toValue, type MaybeRef } from 'vue'
|
|
16
|
+
import { Primitive } from '@maas/vue-primitive'
|
|
17
|
+
import { onKeyStroke } from '@vueuse/core'
|
|
18
|
+
import { useAccordionTrigger } from '../composables/private/useAccordionTrigger'
|
|
19
|
+
import { MagicAccordionInstanceId, MagicAccordionViewId } from '../symbols'
|
|
20
|
+
import type { Interaction } from '../types'
|
|
21
|
+
import { useAccordionState } from '../composables/private/useAccordionState'
|
|
22
|
+
|
|
23
|
+
interface MagicAccordionTriggerProps {
|
|
24
|
+
disabled?: MaybeRef<boolean>
|
|
25
|
+
trigger?: Interaction
|
|
26
|
+
asChild?: boolean
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const props = withDefaults(defineProps<MagicAccordionTriggerProps>(), {
|
|
30
|
+
disabled: false,
|
|
31
|
+
trigger: 'click',
|
|
32
|
+
asChild: false,
|
|
33
|
+
})
|
|
34
|
+
const elRef = ref<InstanceType<typeof Primitive> | undefined>(undefined)
|
|
35
|
+
|
|
36
|
+
const instanceId = inject(MagicAccordionInstanceId, undefined)
|
|
37
|
+
const viewId = inject(MagicAccordionViewId, undefined)
|
|
38
|
+
|
|
39
|
+
if (!instanceId) {
|
|
40
|
+
throw new Error(
|
|
41
|
+
'MagicAccordionTrigger must be nested inside MagicAccordionProvider'
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!viewId) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
'MagicAccordionTrigger must be nested inside MagicAccordionView'
|
|
48
|
+
)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const { initializeState } = useAccordionState(instanceId)
|
|
52
|
+
const state = initializeState()
|
|
53
|
+
|
|
54
|
+
const mappedDisabled = computed(
|
|
55
|
+
() => toValue(props.disabled) || state.options.disabled
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
const { onMouseenter, onClick, onEnter } = useAccordionTrigger({
|
|
59
|
+
instanceId,
|
|
60
|
+
viewId,
|
|
61
|
+
elRef,
|
|
62
|
+
disabled: props.disabled,
|
|
63
|
+
trigger: props.trigger,
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
onKeyStroke('Enter', onEnter)
|
|
67
|
+
</script>
|
|
68
|
+
|
|
69
|
+
<style>
|
|
70
|
+
:root{--magic-accordion-trigger-cursor-disabled:not-allowed}.magic-accordion-trigger.-disabled{cursor:var(--magic-accordion-trigger-cursor-disabled)}
|
|
71
|
+
</style>
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type MaybeRef } from 'vue';
|
|
2
|
+
import type { Interaction } from '../types';
|
|
3
|
+
interface MagicAccordionTriggerProps {
|
|
4
|
+
disabled?: MaybeRef<boolean>;
|
|
5
|
+
trigger?: Interaction;
|
|
6
|
+
asChild?: boolean;
|
|
7
|
+
}
|
|
8
|
+
declare function __VLS_template(): {
|
|
9
|
+
default?(_: {}): any;
|
|
10
|
+
};
|
|
11
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToOption<MagicAccordionTriggerProps>, {
|
|
12
|
+
disabled: boolean;
|
|
13
|
+
trigger: string;
|
|
14
|
+
asChild: boolean;
|
|
15
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToOption<MagicAccordionTriggerProps>, {
|
|
16
|
+
disabled: boolean;
|
|
17
|
+
trigger: string;
|
|
18
|
+
asChild: boolean;
|
|
19
|
+
}>>>, {
|
|
20
|
+
asChild: boolean;
|
|
21
|
+
disabled: MaybeRef<boolean>;
|
|
22
|
+
trigger: Interaction;
|
|
23
|
+
}, {}>;
|
|
24
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
25
|
+
export default _default;
|
|
26
|
+
type __VLS_WithDefaults<P, D> = {
|
|
27
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
28
|
+
default: D[K];
|
|
29
|
+
}> : P[K];
|
|
30
|
+
};
|
|
31
|
+
type __VLS_Prettify<T> = {
|
|
32
|
+
[K in keyof T]: T[K];
|
|
33
|
+
} & {};
|
|
34
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
35
|
+
new (): {
|
|
36
|
+
$slots: S;
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
40
|
+
type __VLS_TypePropsToOption<T> = {
|
|
41
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
42
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
43
|
+
} : {
|
|
44
|
+
type: import('vue').PropType<T[K]>;
|
|
45
|
+
required: true;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<primitive
|
|
3
|
+
:as-child="asChild"
|
|
4
|
+
:class="['magic-accordion-view', { '-active': view.active }]"
|
|
5
|
+
>
|
|
6
|
+
<slot />
|
|
7
|
+
</primitive>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script lang="ts" setup>
|
|
11
|
+
import { computed, inject, onBeforeUnmount, provide } from 'vue'
|
|
12
|
+
import { Primitive } from '@maas/vue-primitive'
|
|
13
|
+
import { uuid } from '@maas/vue-equipment/utils'
|
|
14
|
+
import {
|
|
15
|
+
MagicAccordionInstanceId,
|
|
16
|
+
MagicAccordionViewActive,
|
|
17
|
+
MagicAccordionViewId,
|
|
18
|
+
} from '../symbols'
|
|
19
|
+
import { useAccordionView } from '../composables/private/useAccordionView'
|
|
20
|
+
|
|
21
|
+
interface MagicAccordionViewProps {
|
|
22
|
+
asChild?: boolean
|
|
23
|
+
id?: string
|
|
24
|
+
activeOnMounted?: boolean
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const props = defineProps<MagicAccordionViewProps>()
|
|
28
|
+
|
|
29
|
+
const instanceId = inject(MagicAccordionInstanceId, undefined)
|
|
30
|
+
|
|
31
|
+
if (!instanceId) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
'MagicAccordionView must be nested inside MagicAccordionProvider'
|
|
34
|
+
)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const mappedId = computed(() => props.id ?? `magic-accordion-view-${uuid()}`)
|
|
38
|
+
|
|
39
|
+
// Register view
|
|
40
|
+
const { initializeView, deleteView } = useAccordionView(instanceId)
|
|
41
|
+
|
|
42
|
+
const view = initializeView({
|
|
43
|
+
id: mappedId.value,
|
|
44
|
+
active: props.activeOnMounted ?? false,
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
// Pass id and active state to children
|
|
48
|
+
provide(MagicAccordionViewId, mappedId.value)
|
|
49
|
+
provide(MagicAccordionViewActive, view.active)
|
|
50
|
+
|
|
51
|
+
// Lifecycle
|
|
52
|
+
onBeforeUnmount(() => {
|
|
53
|
+
deleteView(mappedId.value)
|
|
54
|
+
})
|
|
55
|
+
</script>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
interface MagicAccordionViewProps {
|
|
2
|
+
asChild?: boolean;
|
|
3
|
+
id?: string;
|
|
4
|
+
activeOnMounted?: boolean;
|
|
5
|
+
}
|
|
6
|
+
declare function __VLS_template(): {
|
|
7
|
+
default?(_: {}): any;
|
|
8
|
+
};
|
|
9
|
+
declare const __VLS_component: import("vue").DefineComponent<__VLS_TypePropsToOption<MagicAccordionViewProps>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToOption<MagicAccordionViewProps>>>, {}, {}>;
|
|
10
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
|
|
11
|
+
export default _default;
|
|
12
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
13
|
+
new (): {
|
|
14
|
+
$slots: S;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
18
|
+
type __VLS_TypePropsToOption<T> = {
|
|
19
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
20
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
21
|
+
} : {
|
|
22
|
+
type: import('vue').PropType<T[K]>;
|
|
23
|
+
required: true;
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type MaybeRef } from 'vue';
|
|
2
|
+
type UseModalCallbackArgs = {
|
|
3
|
+
viewId: string;
|
|
4
|
+
instanceId: MaybeRef<string>;
|
|
5
|
+
};
|
|
6
|
+
export declare function useAccordionCallback(args: UseModalCallbackArgs): {
|
|
7
|
+
onBeforeEnter: (_el?: Element) => void;
|
|
8
|
+
onEnter: (_el?: Element) => void;
|
|
9
|
+
onAfterEnter: (_el?: Element) => Promise<void>;
|
|
10
|
+
onBeforeLeave: (_el?: Element) => void;
|
|
11
|
+
onLeave: (_el?: Element) => void;
|
|
12
|
+
onAfterLeave: (_el?: Element) => void;
|
|
13
|
+
};
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { toValue } from "vue";
|
|
2
|
+
import { useMagicEmitter } from "@maas/vue-equipment/plugins";
|
|
3
|
+
export function useAccordionCallback(args) {
|
|
4
|
+
const { viewId, instanceId } = args;
|
|
5
|
+
const emitter = useMagicEmitter();
|
|
6
|
+
function onBeforeEnter(_el) {
|
|
7
|
+
emitter.emit("beforeEnter", { id: toValue(instanceId), viewId });
|
|
8
|
+
}
|
|
9
|
+
function onEnter(_el) {
|
|
10
|
+
emitter.emit("enter", { id: toValue(instanceId), viewId });
|
|
11
|
+
}
|
|
12
|
+
async function onAfterEnter(_el) {
|
|
13
|
+
emitter.emit("afterEnter", { id: toValue(instanceId), viewId });
|
|
14
|
+
}
|
|
15
|
+
function onBeforeLeave(_el) {
|
|
16
|
+
emitter.emit("beforeLeave", { id: toValue(instanceId), viewId });
|
|
17
|
+
}
|
|
18
|
+
function onLeave(_el) {
|
|
19
|
+
emitter.emit("leave", { id: toValue(instanceId), viewId });
|
|
20
|
+
}
|
|
21
|
+
function onAfterLeave(_el) {
|
|
22
|
+
emitter.emit("afterLeave", { id: toValue(instanceId), viewId });
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
onBeforeEnter,
|
|
26
|
+
onEnter,
|
|
27
|
+
onAfterEnter,
|
|
28
|
+
onBeforeLeave,
|
|
29
|
+
onLeave,
|
|
30
|
+
onAfterLeave
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Ref, type MaybeRef } from 'vue';
|
|
2
|
+
import type { AccordionState, MagicAccordionOptions } from '../../types/index.js';
|
|
3
|
+
export declare function useAccordionState(instanceId: MaybeRef<string>): {
|
|
4
|
+
initializeState: (options?: MagicAccordionOptions) => AccordionState;
|
|
5
|
+
deleteState: () => void;
|
|
6
|
+
accordionStateStore: Ref<AccordionState[]>;
|
|
7
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ref, reactive, toValue } from "vue";
|
|
2
|
+
import { defu } from "defu";
|
|
3
|
+
import { defaultOptions } from "../../utils/defaultOptions.mjs";
|
|
4
|
+
const accordionStateStore = ref([]);
|
|
5
|
+
export function useAccordionState(instanceId) {
|
|
6
|
+
function createState(id) {
|
|
7
|
+
const state = {
|
|
8
|
+
id,
|
|
9
|
+
options: defaultOptions,
|
|
10
|
+
views: []
|
|
11
|
+
};
|
|
12
|
+
return reactive(state);
|
|
13
|
+
}
|
|
14
|
+
function addState(id) {
|
|
15
|
+
const instance = createState(id);
|
|
16
|
+
accordionStateStore.value = [...accordionStateStore.value, instance];
|
|
17
|
+
return instance;
|
|
18
|
+
}
|
|
19
|
+
function initializeState(options) {
|
|
20
|
+
let instance = accordionStateStore.value.find((instance2) => {
|
|
21
|
+
return instance2.id === toValue(instanceId);
|
|
22
|
+
});
|
|
23
|
+
if (!instance) {
|
|
24
|
+
instance = addState(toValue(instanceId));
|
|
25
|
+
}
|
|
26
|
+
if (options) {
|
|
27
|
+
const mappedOptions = defu(options, defaultOptions);
|
|
28
|
+
instance.options = mappedOptions;
|
|
29
|
+
}
|
|
30
|
+
return instance;
|
|
31
|
+
}
|
|
32
|
+
function deleteState() {
|
|
33
|
+
accordionStateStore.value = accordionStateStore.value.filter(
|
|
34
|
+
(x) => x.id !== toValue(instanceId)
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
initializeState,
|
|
39
|
+
deleteState,
|
|
40
|
+
accordionStateStore
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type MaybeRef, type Ref } from 'vue';
|
|
2
|
+
import { Primitive } from '@maas/vue-primitive';
|
|
3
|
+
import type { Interaction } from '../../types.js';
|
|
4
|
+
interface UseAccordionTriggerArgs {
|
|
5
|
+
instanceId: MaybeRef<string>;
|
|
6
|
+
viewId: string;
|
|
7
|
+
trigger: Interaction;
|
|
8
|
+
disabled: MaybeRef<boolean>;
|
|
9
|
+
elRef: Ref<InstanceType<typeof Primitive> | undefined>;
|
|
10
|
+
}
|
|
11
|
+
export declare function useAccordionTrigger(args: UseAccordionTriggerArgs): {
|
|
12
|
+
onMouseenter: () => void;
|
|
13
|
+
onClick: () => void;
|
|
14
|
+
onEnter: (e: KeyboardEvent) => void;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { toValue } from "vue";
|
|
2
|
+
import { useAccordionView } from "./useAccordionView.mjs";
|
|
3
|
+
import { useFocus } from "@vueuse/core";
|
|
4
|
+
export function useAccordionTrigger(args) {
|
|
5
|
+
const { instanceId, viewId, elRef, disabled, trigger } = args;
|
|
6
|
+
const { selectView, unselectView, getView } = useAccordionView(instanceId);
|
|
7
|
+
const view = getView(viewId);
|
|
8
|
+
const { focused } = useFocus(elRef);
|
|
9
|
+
function onMouseenter() {
|
|
10
|
+
if (!toValue(disabled) && trigger === "mouseenter") {
|
|
11
|
+
selectView(viewId);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function onClick() {
|
|
15
|
+
if (!toValue(disabled) && trigger === "click") {
|
|
16
|
+
if (view?.active) {
|
|
17
|
+
unselectView(viewId);
|
|
18
|
+
} else {
|
|
19
|
+
selectView(viewId);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function onEnter(e) {
|
|
24
|
+
if (focused.value && !toValue(disabled) && !view?.active) {
|
|
25
|
+
e.preventDefault();
|
|
26
|
+
e.stopPropagation();
|
|
27
|
+
selectView(viewId);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
onMouseenter,
|
|
32
|
+
onClick,
|
|
33
|
+
onEnter
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type MaybeRef } from 'vue';
|
|
2
|
+
import { type AccordionView } from '../../types.js';
|
|
3
|
+
type InitializeViewArgs = Pick<AccordionView, 'id' | 'active'>;
|
|
4
|
+
export declare function useAccordionView(instanceId: MaybeRef<string>): {
|
|
5
|
+
initializeView: (args: InitializeViewArgs) => AccordionView;
|
|
6
|
+
deleteView: (id: string) => void;
|
|
7
|
+
getView: (id: string) => AccordionView | undefined;
|
|
8
|
+
selectView: (id: string) => void;
|
|
9
|
+
unselectView: (id: string) => void;
|
|
10
|
+
unselectAllViews: () => void;
|
|
11
|
+
};
|
|
12
|
+
export {};
|