You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
629 B
29 lines
629 B
import { create } from "zustand";
|
|
|
|
import { ContextMenuItem } from "@/typings/contextMenu";
|
|
|
|
interface Location {
|
|
x: number;
|
|
y: number;
|
|
}
|
|
|
|
interface ContextMenuStore {
|
|
show: boolean;
|
|
location: Location;
|
|
items: ContextMenuItem[];
|
|
showContextMenu: (x: number, y: number, items: ContextMenuItem[]) => void;
|
|
hide: () => void;
|
|
}
|
|
|
|
const useContextMenuStore = create<ContextMenuStore>((set) => ({
|
|
show: false,
|
|
location: { x: 0, y: 0 },
|
|
items: [],
|
|
showContextMenu: (x, y, items): void => {
|
|
set({ show: true, location: { x, y }, items });
|
|
},
|
|
hide: (): void => set({ show: false })
|
|
}));
|
|
|
|
export default useContextMenuStore;
|