2022-07-07 20:05:46 +02:00
|
|
|
import { reactive, ref } from 'vue'
|
|
|
|
import ContextMenuBase from '@/components/ui/ContextMenuBase.vue'
|
2022-04-20 12:20:09 +02:00
|
|
|
|
2022-04-15 19:00:08 +02:00
|
|
|
export const useContextMenu = () => {
|
2022-04-24 11:29:14 +03:00
|
|
|
const base = ref<InstanceType<typeof ContextMenuBase>>()
|
2022-04-15 19:00:08 +02:00
|
|
|
|
2022-12-02 17:17:37 +01:00
|
|
|
const open = async (top: number, left: number) => await base.value?.open(top, left)
|
2022-04-15 19:00:08 +02:00
|
|
|
const close = () => base.value?.close()
|
|
|
|
|
2022-06-10 12:47:46 +02:00
|
|
|
const trigger = (func: Closure) => {
|
|
|
|
close()
|
|
|
|
func()
|
|
|
|
}
|
|
|
|
|
2022-04-15 19:00:08 +02:00
|
|
|
return {
|
2022-04-24 11:29:14 +03:00
|
|
|
ContextMenuBase,
|
2022-07-08 12:32:44 +02:00
|
|
|
base,
|
2022-04-15 19:00:08 +02:00
|
|
|
open,
|
2022-04-20 12:20:09 +02:00
|
|
|
close,
|
2022-07-08 12:32:44 +02:00
|
|
|
trigger
|
2022-04-15 19:00:08 +02:00
|
|
|
}
|
|
|
|
}
|