2023-07-26 22:31:52 -07:00
|
|
|
<!--
|
|
|
|
SPDX-FileCopyrightText: syuilo and other misskey contributors
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-10-17 04:12:00 -07:00
|
|
|
<template>
|
2023-08-08 17:08:47 -07: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 09:14:40 -08:00
|
|
|
</MkModal>
|
2020-10-17 04:12:00 -07:00
|
|
|
</template>
|
|
|
|
|
2022-01-29 21:11:52 -08:00
|
|
|
<script lang="ts" setup>
|
2023-08-08 17:08:47 -07:00
|
|
|
import { ref } from 'vue';
|
2022-09-06 02:21:49 -07:00
|
|
|
import MkModal from './MkModal.vue';
|
|
|
|
import MkMenu from './MkMenu.vue';
|
2022-01-29 21:11:52 -08:00
|
|
|
import { MenuItem } from '@/types/menu';
|
2020-10-17 04:12:00 -07:00
|
|
|
|
2022-01-29 21:11:52 -08:00
|
|
|
defineProps<{
|
|
|
|
items: MenuItem[];
|
|
|
|
align?: 'center' | string;
|
|
|
|
width?: number;
|
|
|
|
viaKeyboard?: boolean;
|
|
|
|
src?: any;
|
|
|
|
}>();
|
2021-08-07 20:19:10 -07:00
|
|
|
|
2022-01-29 21:11:52 -08:00
|
|
|
const emit = defineEmits<{
|
2022-05-26 06:53:09 -07:00
|
|
|
(ev: 'closed'): void;
|
2023-01-05 17:11:47 -08:00
|
|
|
(ev: 'closing'): void;
|
2022-01-29 21:11:52 -08:00
|
|
|
}>();
|
2021-08-07 20:19:10 -07:00
|
|
|
|
2023-01-02 20:37:32 -08:00
|
|
|
let modal = $shallowRef<InstanceType<typeof MkModal>>();
|
2023-08-08 17:08:47 -07: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 04:12:00 -07:00
|
|
|
</script>
|
2021-12-16 09:14:40 -08:00
|
|
|
|
2023-01-13 22:02:14 -08:00
|
|
|
<style lang="scss" module>
|
|
|
|
.drawer {
|
|
|
|
border-radius: 24px;
|
|
|
|
border-bottom-right-radius: 0;
|
|
|
|
border-bottom-left-radius: 0;
|
2021-12-16 09:14:40 -08:00
|
|
|
}
|
|
|
|
</style>
|