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