import { create } from "zustand";

interface PopupStore {
  popup: React.ReactNode | null;
  setPopup: (popup: React.ReactNode) => void;
  align: "start" | "center" | "end";
  setAlign: (align: "start" | "center" | "end") => void;
  parentBoundingClientRect: DOMRect | null;
  setParentBoundingClientRect: (
    parentBoundingClientRect: DOMRect | null
  ) => void;
  side: "left" | "right" | "top" | "bottom" | null;
  setSide: (side: "left" | "right" | "top" | "bottom" | null) => void;
}

export const usePopupStore = create<PopupStore>((set) => ({
  popup: null,
  setPopup: (popup: React.ReactNode) => set({ popup }),
  align: "center",
  setAlign: (align: "start" | "center" | "end") => set({ align }),
  parentBoundingClientRect: null,
  setParentBoundingClientRect: (parentBoundingClientRect: DOMRect | null) =>
    set({ parentBoundingClientRect }),
  side: "left",
  setSide: (side: "left" | "right" | "top" | "bottom" | null) => set({ side }),
}));
