2024-08-26 19:09:43 +00:00
|
|
|
<!-- eslint-disable vue/multi-word-component-names -->
|
2023-11-10 23:50:43 +00:00
|
|
|
<template>
|
|
|
|
|
<div style="display: none">
|
|
|
|
|
<div v-bind="$attrs" ref="message">
|
|
|
|
|
<slot name="default" />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
2024-08-26 19:09:43 +00:00
|
|
|
<script setup lang="ts">
|
2023-11-10 23:50:43 +00:00
|
|
|
import * as bulmaToast from "bulma-toast";
|
2024-08-26 19:09:43 +00:00
|
|
|
import { onMounted, ref } from "vue";
|
|
|
|
|
|
|
|
|
|
const emit = defineEmits<{
|
2025-11-30 18:09:08 +00:00
|
|
|
(
|
|
|
|
|
event: "handle",
|
|
|
|
|
show: (options: bulmaToast.Options) => void,
|
|
|
|
|
hide: () => void,
|
|
|
|
|
): void;
|
2024-08-26 19:09:43 +00:00
|
|
|
}>();
|
|
|
|
|
|
|
|
|
|
const message = ref<HTMLDivElement | null>(null);
|
|
|
|
|
|
|
|
|
|
onMounted(() =>
|
2025-11-30 18:09:08 +00:00
|
|
|
emit(
|
|
|
|
|
"handle",
|
|
|
|
|
(options: bulmaToast.Options = {}) => {
|
2024-08-26 19:09:43 +00:00
|
|
|
if (!(message.value instanceof HTMLElement)) return;
|
|
|
|
|
|
|
|
|
|
bulmaToast.toast({
|
|
|
|
|
...options,
|
|
|
|
|
single: true,
|
|
|
|
|
message: message.value,
|
|
|
|
|
});
|
|
|
|
|
},
|
2025-11-30 18:09:08 +00:00
|
|
|
() => {
|
2024-08-26 19:09:43 +00:00
|
|
|
if (!(message.value instanceof HTMLElement)) return;
|
|
|
|
|
|
|
|
|
|
const toast_div = message.value.parentElement;
|
|
|
|
|
if (!(toast_div instanceof HTMLDivElement)) return;
|
|
|
|
|
|
|
|
|
|
const dbutton = toast_div.querySelector("button.delete");
|
|
|
|
|
if (!(dbutton instanceof HTMLButtonElement)) return;
|
|
|
|
|
|
|
|
|
|
dbutton.click();
|
|
|
|
|
},
|
2025-11-30 18:09:08 +00:00
|
|
|
),
|
2024-08-26 19:09:43 +00:00
|
|
|
);
|
2023-11-10 23:50:43 +00:00
|
|
|
</script>
|