2020-10-17 13:12:00 +02:00
|
|
|
<template>
|
2023-04-08 02:01:42 +02:00
|
|
|
<MkModal
|
|
|
|
ref="modal"
|
|
|
|
v-slot="{ type, maxHeight }"
|
|
|
|
:z-priority="'high'"
|
|
|
|
:src="src"
|
|
|
|
:transparent-bg="true"
|
|
|
|
@click="modal.close()"
|
|
|
|
@closed="emit('closed')"
|
2023-04-29 01:06:21 +02:00
|
|
|
tabindex="-1"
|
|
|
|
v-focus
|
2023-04-08 02:01:42 +02:00
|
|
|
>
|
|
|
|
<MkMenu
|
|
|
|
:items="items"
|
|
|
|
:align="align"
|
|
|
|
:width="width"
|
|
|
|
:max-height="maxHeight"
|
|
|
|
:as-drawer="type === 'drawer'"
|
|
|
|
class="sfhdhdhq"
|
2023-05-07 01:26:24 +02:00
|
|
|
:class="{
|
|
|
|
drawer: type === 'drawer',
|
|
|
|
...classMap(classes),
|
|
|
|
}"
|
2023-04-08 02:01:42 +02:00
|
|
|
@close="modal.close()"
|
|
|
|
/>
|
|
|
|
</MkModal>
|
2020-10-17 13:12:00 +02:00
|
|
|
</template>
|
|
|
|
|
2022-01-30 06:11:52 +01:00
|
|
|
<script lang="ts" setup>
|
2023-04-08 02:01:42 +02:00
|
|
|
import MkModal from "./MkModal.vue";
|
|
|
|
import MkMenu from "./MkMenu.vue";
|
2023-05-07 01:26:24 +02:00
|
|
|
import { MenuClasses, MenuItem } from "@/types/menu";
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-01-30 06:11:52 +01:00
|
|
|
defineProps<{
|
|
|
|
items: MenuItem[];
|
2023-04-08 02:01:42 +02:00
|
|
|
align?: "center" | string;
|
2022-01-30 06:11:52 +01:00
|
|
|
width?: number;
|
|
|
|
viaKeyboard?: boolean;
|
|
|
|
src?: any;
|
2023-05-07 01:26:24 +02:00
|
|
|
classes?: MenuClasses;
|
2022-01-30 06:11:52 +01:00
|
|
|
}>();
|
2021-08-08 05:19:10 +02:00
|
|
|
|
2022-01-30 06:11:52 +01:00
|
|
|
const emit = defineEmits<{
|
2023-04-08 02:01:42 +02:00
|
|
|
(ev: "closed"): void;
|
2022-01-30 06:11:52 +01:00
|
|
|
}>();
|
2021-08-08 05:19:10 +02:00
|
|
|
|
2022-01-30 06:11:52 +01:00
|
|
|
let modal = $ref<InstanceType<typeof MkModal>>();
|
2023-05-07 01:26:24 +02:00
|
|
|
|
|
|
|
function classMap(classes?: MenuClasses) {
|
|
|
|
if (!classes) return {};
|
|
|
|
|
|
|
|
return (
|
|
|
|
Array.isArray(classes)
|
|
|
|
? classes
|
|
|
|
: classes.value
|
|
|
|
).reduce((acc, cls) => {
|
|
|
|
acc[cls] = true;
|
|
|
|
return acc;
|
|
|
|
}, {});
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
</script>
|
2021-12-16 18:14:40 +01:00
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.sfhdhdhq {
|
|
|
|
&.drawer {
|
|
|
|
border-radius: 24px;
|
|
|
|
border-bottom-right-radius: 0;
|
|
|
|
border-bottom-left-radius: 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|