export const createEvent = (ref)=>{
    if (ref.current) {
        const event = new Event('change', {
            bubbles: true
        });
        Object.defineProperty(event, 'target', {
            writable: false,
            value: ref.current
        });
        const syntheticEvent = createSyntheticEvent(event);
        return syntheticEvent;
    }
    return null;
};
const createSyntheticEvent = (event)=>{
    let isDefaultPrevented = false;
    let isPropagationStopped = false;
    const preventDefault = ()=>{
        isDefaultPrevented = true;
        event.preventDefault();
    };
    const stopPropagation = ()=>{
        isPropagationStopped = true;
        event.stopPropagation();
    };
    return {
        nativeEvent: event,
        currentTarget: event.currentTarget,
        target: event.target,
        bubbles: event.bubbles,
        cancelable: event.cancelable,
        defaultPrevented: event.defaultPrevented,
        eventPhase: event.eventPhase,
        isTrusted: event.isTrusted,
        preventDefault,
        isDefaultPrevented: ()=>isDefaultPrevented,
        stopPropagation,
        isPropagationStopped: ()=>isPropagationStopped,
        persist: ()=>{},
        timeStamp: event.timeStamp,
        type: event.type
    };
};
