UNPKG

@momentum-ui/react-collaboration

Version:

Cisco Momentum UI Framework for React Collaboration Applications

39 lines (38 loc) 1.89 kB
/** * An event target to handle communication between instances of Dialog and Popover. * This will enable us to keep track of Popover instances (specifically those with hideOnEsc = true) * which are opened while an Dialog is rendered. While such Popover instances remain open, the Dialog * will not close on Esc. * * This operates on the assumption that any Popover instance that is opened after an Dialog is * rendered on the screen is part of the content of said Dialog and should be closed before the Dialog * itself. */ export declare enum EventType { TIPPY_INSTANCE_ADDED = "tippyInstanceAdded", TIPPY_INSTANCE_REMOVED = "tippyInstanceRemoved" } type EventHandler = (data?: unknown) => void; /** * Dispatch a custom event to the event target. * @param eventType The category, allowing for listeners to listen to specific events * @param data The data associated with the event (provided in the custom event detail) */ declare const dispatchEvent: (eventType: EventType, data?: unknown) => void; /** * Add a listener for a specific type (category) of event. * This wraps the provided event handler to obfuscate the use of the custom event. * Due to this the event listener is stored against an ID which can be used to remove it later. * @param eventType The category of event * @param handler The handler function to call, expecting a type and data arguments * @returns The ID of the listener added */ declare const addListener: (eventType: EventType, handler: EventHandler) => string; /** * Remove a listener for a specific type (category) of event. * Removes the stored listener based on the event type and handler ID provided. * @param eventType The category of event * @param id The ID of the listener to be removed */ declare const removeListener: (eventType: EventType, id: string) => void; export { dispatchEvent, addListener, removeListener };