import { createContext } from "react";

class ActionProvider {
    openPopup = (path, props={}, onSelect=(result)=>{}, onClose=()=>{}) => {};
    setOpenPopupListener = (handler=(path, props, onSelect, onClose)=>{ console.log('default openPopup handler'); }) => {
        this.openPopup = handler;
    };
}
const actionProvider = { value: null };
if(actionProvider.value == null) {
    actionProvider.value = new ActionProvider();
}

const context = { value: null };
if(context.value == null) {
    context.value = createContext(actionProvider.value);
}

export const ContextInitialValue = actionProvider.value;
export const PopupContext = context.value;
export const DefaultAction = { select:(result)=>{}, close:()=>{} };