Some checks failed
Lock Threads / action (push) Has been cancelled
Mark stale issues and pull requests / stale (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot EE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot EE docker images / merge (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/amd64, ubuntu-latest) (push) Has been cancelled
Publish Chatwoot CE docker images / build (linux/arm64, ubuntu-22.04-arm) (push) Has been cancelled
Publish Chatwoot CE docker images / merge (push) Has been cancelled
Run Chatwoot CE spec / lint-backend (push) Has been cancelled
Run Chatwoot CE spec / lint-frontend (push) Has been cancelled
Run Chatwoot CE spec / frontend-tests (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (0, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (1, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (10, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (11, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (12, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (13, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (14, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (15, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (2, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (3, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (4, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (5, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (6, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (7, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (8, 16) (push) Has been cancelled
Run Chatwoot CE spec / backend-tests (9, 16) (push) Has been cancelled
Run Linux nightly installer / nightly (push) Has been cancelled
- Add Logistics component with progress tracking - Add OrderDetail component for order information - Support data-driven steps and actions - Add blue color scale to widget SCSS - Fix node overflow and progress bar rendering issues - Add English translations for dashboard components Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
98 lines
2.2 KiB
Vue
98 lines
2.2 KiB
Vue
<script setup>
|
|
import {
|
|
computed,
|
|
onMounted,
|
|
nextTick,
|
|
onUnmounted,
|
|
useTemplateRef,
|
|
inject,
|
|
} from 'vue';
|
|
import { useWindowSize, useElementBounding, useScrollLock } from '@vueuse/core';
|
|
|
|
import TeleportWithDirection from 'dashboard/components-next/TeleportWithDirection.vue';
|
|
|
|
const props = defineProps({
|
|
x: { type: Number, default: 0 },
|
|
y: { type: Number, default: 0 },
|
|
});
|
|
|
|
const emit = defineEmits(['close']);
|
|
|
|
const elementToLock = inject('contextMenuElementTarget', null);
|
|
|
|
const menuRef = useTemplateRef('menuRef');
|
|
|
|
const scrollLockElement = computed(() => {
|
|
if (!elementToLock?.value) return null;
|
|
return elementToLock.value?.$el;
|
|
});
|
|
|
|
const isLocked = useScrollLock(scrollLockElement);
|
|
|
|
const { width: windowWidth, height: windowHeight } = useWindowSize();
|
|
const { width: menuWidth, height: menuHeight } = useElementBounding(menuRef);
|
|
|
|
const calculatePosition = (x, y, menuW, menuH, windowW, windowH) => {
|
|
const PADDING = 16;
|
|
// Initial position
|
|
let left = x;
|
|
let top = y;
|
|
// Boundary checks
|
|
const isOverflowingRight = left + menuW > windowW - PADDING;
|
|
const isOverflowingBottom = top + menuH > windowH - PADDING;
|
|
// Adjust position if overflowing
|
|
if (isOverflowingRight) left = windowW - menuW - PADDING;
|
|
if (isOverflowingBottom) top = windowH - menuH - PADDING;
|
|
return {
|
|
left: Math.max(PADDING, left),
|
|
top: Math.max(PADDING, top),
|
|
};
|
|
};
|
|
|
|
const position = computed(() => {
|
|
if (!menuRef.value) return { top: `${props.y}px`, left: `${props.x}px` };
|
|
|
|
const { left, top } = calculatePosition(
|
|
props.x,
|
|
props.y,
|
|
menuWidth.value,
|
|
menuHeight.value,
|
|
windowWidth.value,
|
|
windowHeight.value
|
|
);
|
|
|
|
return {
|
|
top: `${top}px`,
|
|
left: `${left}px`,
|
|
};
|
|
});
|
|
|
|
onMounted(() => {
|
|
isLocked.value = true;
|
|
nextTick(() => menuRef.value?.focus());
|
|
});
|
|
|
|
const handleClose = () => {
|
|
isLocked.value = false;
|
|
emit('close');
|
|
};
|
|
|
|
onUnmounted(() => {
|
|
isLocked.value = false;
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<TeleportWithDirection to="body">
|
|
<div
|
|
ref="menuRef"
|
|
class="fixed outline-none z-[9999] cursor-pointer"
|
|
:style="position"
|
|
tabindex="0"
|
|
@blur="handleClose"
|
|
>
|
|
<slot />
|
|
</div>
|
|
</TeleportWithDirection>
|
|
</template>
|