2023-07-27 08:31:52 +03:00
|
|
|
<!--
|
2024-02-13 17:59:27 +02:00
|
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 08:31:52 +03:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-10-17 14:12:00 +03:00
|
|
|
<template>
|
2023-08-09 03:08:47 +03: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 19:14:40 +02:00
|
|
|
</MkModal>
|
2020-10-17 14:12:00 +03:00
|
|
|
</template>
|
|
|
|
|
2022-01-30 07:11:52 +02:00
|
|
|
<script lang="ts" setup>
|
2023-12-07 07:42:09 +02:00
|
|
|
import { ref, shallowRef } from 'vue';
|
2022-09-06 12:21:49 +03:00
|
|
|
import MkModal from './MkModal.vue';
|
|
|
|
import MkMenu from './MkMenu.vue';
|
2023-12-12 03:26:37 +02:00
|
|
|
import { MenuItem } from '@/types/menu.js';
|
2020-10-17 14:12:00 +03:00
|
|
|
|
2022-01-30 07:11:52 +02:00
|
|
|
defineProps<{
|
|
|
|
items: MenuItem[];
|
|
|
|
align?: 'center' | string;
|
|
|
|
width?: number;
|
|
|
|
viaKeyboard?: boolean;
|
|
|
|
src?: any;
|
|
|
|
}>();
|
2021-08-08 06:19:10 +03:00
|
|
|
|
2022-01-30 07:11:52 +02:00
|
|
|
const emit = defineEmits<{
|
2022-05-26 16:53:09 +03:00
|
|
|
(ev: 'closed'): void;
|
2023-01-06 03:11:47 +02:00
|
|
|
(ev: 'closing'): void;
|
2022-01-30 07:11:52 +02:00
|
|
|
}>();
|
2021-08-08 06:19:10 +03:00
|
|
|
|
2023-12-07 07:42:09 +02:00
|
|
|
const modal = shallowRef<InstanceType<typeof MkModal>>();
|
2023-08-09 03:08:47 +03: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は呼ぶ必要がある
|
2023-12-07 07:42:09 +02:00
|
|
|
modal.value?.close();
|
2023-08-09 03:08:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function close() {
|
|
|
|
manualShowing.value = false;
|
|
|
|
|
|
|
|
// closeは呼ぶ必要がある
|
2023-12-07 07:42:09 +02:00
|
|
|
modal.value?.close();
|
2023-08-09 03:08:47 +03:00
|
|
|
}
|
2020-10-17 14:12:00 +03:00
|
|
|
</script>
|
2021-12-16 19:14:40 +02:00
|
|
|
|
2023-01-14 08:02:14 +02:00
|
|
|
<style lang="scss" module>
|
|
|
|
.drawer {
|
|
|
|
border-radius: 24px;
|
|
|
|
border-bottom-right-radius: 0;
|
|
|
|
border-bottom-left-radius: 0;
|
2021-12-16 19:14:40 +02:00
|
|
|
}
|
|
|
|
</style>
|