Shivam Mishra
2024-10-02 13:06:30 +05:30
committed by GitHub
parent e0bf2bd9d4
commit 42f6621afb
661 changed files with 15939 additions and 31194 deletions

View File

@@ -1,43 +1,38 @@
<script>
export default {
props: {
x: {
type: Number,
default: 0,
},
y: {
type: Number,
default: 0,
},
},
data() {
return {
left: this.x,
top: this.y,
show: false,
};
},
computed: {
style() {
return {
top: this.top + 'px',
left: this.left + 'px',
};
},
},
mounted() {
this.$nextTick(() => this.$el.focus());
},
};
<script setup>
import { ref, computed, onMounted, nextTick, defineEmits } from 'vue';
const { x, y } = defineProps({
x: { type: Number, default: 0 },
y: { type: Number, default: 0 },
});
const emit = defineEmits(['close']);
const left = ref(x);
const top = ref(y);
const style = computed(() => ({
top: top.value + 'px',
left: left.value + 'px',
}));
const target = ref();
onMounted(() => {
nextTick(() => {
target.value.focus();
});
});
</script>
<template>
<div
class="fixed outline-none z-[9999] cursor-pointer"
:style="style"
tabindex="0"
@blur="$emit('close')"
>
<slot />
</div>
<Teleport to="body">
<div
ref="target"
class="fixed outline-none z-[9999] cursor-pointer"
:style="style"
tabindex="0"
@blur="emit('close')"
>
<slot />
</div>
</Teleport>
</template>