2023-07-27 07:31:52 +02:00
|
|
|
<!--
|
2024-02-13 16:59:27 +01:00
|
|
|
SPDX-FileCopyrightText: syuilo and misskey-project
|
2023-07-27 07:31:52 +02:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
-->
|
|
|
|
|
2020-10-17 13:12:00 +02:00
|
|
|
<template>
|
2024-07-12 09:25:44 +02:00
|
|
|
<MkModal ref="modal" v-slot="{ type, maxHeight }" :manualShowing="manualShowing" :zPriority="'high'" :src="src" :transparentBg="true" :returnFocusTo="returnFocusTo" @click="click" @close="onModalClose" @closed="onModalClosed">
|
|
|
|
<MkMenu :items="items" :align="align" :width="width" :max-height="maxHeight" :asDrawer="type === 'drawer'" :returnFocusTo="returnFocusTo" :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-12-07 06:42:09 +01:00
|
|
|
import { ref, shallowRef } from 'vue';
|
2022-09-06 11:21:49 +02:00
|
|
|
import MkModal from './MkModal.vue';
|
|
|
|
import MkMenu from './MkMenu.vue';
|
2023-12-12 02:26:37 +01:00
|
|
|
import { MenuItem } from '@/types/menu.js';
|
2020-10-17 13:12:00 +02:00
|
|
|
|
2022-01-30 06:11:52 +01:00
|
|
|
defineProps<{
|
|
|
|
items: MenuItem[];
|
|
|
|
align?: 'center' | string;
|
|
|
|
width?: number;
|
|
|
|
src?: any;
|
2024-07-12 09:25:44 +02:00
|
|
|
returnFocusTo?: HTMLElement | null;
|
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<{
|
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-12-07 06:42:09 +01:00
|
|
|
const 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は呼ぶ必要がある
|
2023-12-07 06:42:09 +01:00
|
|
|
modal.value?.close();
|
2023-08-09 02:08:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function close() {
|
|
|
|
manualShowing.value = false;
|
|
|
|
|
|
|
|
// closeは呼ぶ必要がある
|
2023-12-07 06:42:09 +01:00
|
|
|
modal.value?.close();
|
2023-08-09 02:08:47 +02:00
|
|
|
}
|
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>
|