2023-07-27 07:31:52 +02:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
<template>
|
2023-08-09 02:08:47 +02:00
|
|
|
<MkModal ref="modal" v-slot="{ type, maxHeight }" :manualShowing="manualShowing" :zPriority="'high'" :src="src" :transparentBg="true" @click="click" @close="onModalClose" @closed="onModalClosed">
|
|
|
|
<MkMenu :items="items" :align="align" :width="width" :max-height="maxHeight" :asDrawer="type === 'drawer'" :class="{ [$style.drawer]: type === 'drawer' }" @close="onMenuClose" @hide="hide"/>
|
2021-12-16 18:14:40 +01:00
|
|
|
</MkModal>
|
2020-10-17 13:12:00 +02:00
|
|
|
</template>
|
|
|
|
|
2022-01-30 06:11:52 +01:00
|
|
|
<script lang="ts" setup>
|
2023-08-09 02:08:47 +02:00
|
|
|
import { ref } from 'vue';
|
2022-09-06 11:21:49 +02:00
|
|
|
import MkModal from './MkModal.vue';
|
|
|
|
import MkMenu from './MkMenu.vue';
|
2022-01-30 06:11:52 +01:00
|
|
|
import { MenuItem } from '@/types/menu';
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-01-30 06:11:52 +01:00
|
|
|
defineProps<{
|
|
|
|
items: MenuItem[];
|
|
|
|
align?: 'center' | string;
|
|
|
|
width?: number;
|
|
|
|
viaKeyboard?: boolean;
|
|
|
|
src?: any;
|
|
|
|
}>();
|
2021-08-08 05:19:10 +02:00
|
|
|
|
2022-01-30 06:11:52 +01:00
|
|
|
const emit = defineEmits<{
|
2022-05-26 15:53:09 +02:00
|
|
|
(ev: 'closed'): void;
|
2023-01-06 02:11:47 +01:00
|
|
|
(ev: 'closing'): void;
|
2022-01-30 06:11:52 +01:00
|
|
|
}>();
|
2021-08-08 05:19:10 +02:00
|
|
|
|
2023-01-03 05:37:32 +01:00
|
|
|
let modal = $shallowRef<InstanceType<typeof MkModal>>();
|
2023-08-09 02:08:47 +02:00
|
|
|
const manualShowing = ref(true);
|
|
|
|
const hiding = ref(false);
|
|
|
|
|
|
|
|
function click() {
|
|
|
|
close();
|
|
|
|
}
|
|
|
|
|
|
|
|
function onModalClose() {
|
|
|
|
emit('closing');
|
|
|
|
}
|
|
|
|
|
|
|
|
function onMenuClose() {
|
|
|
|
close();
|
|
|
|
if (hiding.value) {
|
|
|
|
// hidingであればclosedを発火
|
|
|
|
emit('closed');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function onModalClosed() {
|
|
|
|
if (!hiding.value) {
|
|
|
|
// hidingでなければclosedを発火
|
|
|
|
emit('closed');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function hide() {
|
|
|
|
manualShowing.value = false;
|
|
|
|
hiding.value = true;
|
|
|
|
|
|
|
|
// closeは呼ぶ必要がある
|
|
|
|
modal?.close();
|
|
|
|
}
|
|
|
|
|
|
|
|
function close() {
|
|
|
|
manualShowing.value = false;
|
|
|
|
|
|
|
|
// closeは呼ぶ必要がある
|
|
|
|
modal?.close();
|
|
|
|
}
|
2020-10-17 13:12:00 +02:00
|
|
|
</script>
|
2021-12-16 18:14:40 +01:00
|
|
|
|
2023-01-14 07:02:14 +01:00
|
|
|
<style lang="scss" module>
|
|
|
|
.drawer {
|
|
|
|
border-radius: 24px;
|
|
|
|
border-bottom-right-radius: 0;
|
|
|
|
border-bottom-left-radius: 0;
|
2021-12-16 18:14:40 +01:00
|
|
|
}
|
|
|
|
</style>
|