@aotearoan/neon
Version:
Neon is a lightweight design library of Vue 3 components with minimal dependencies.
34 lines (33 loc) • 1.3 kB
TypeScript
/**
* Utility class for assisting with closing events for popup containers like modals, dropdowns, selects & drawers.
* Detects click & touch events outside the popup element as well as escape key triggers.
*/
export declare class NeonClosableUtils {
private readonly target;
private readonly closeCallback;
private _open;
/**
* Initialise utility to listen to keyboard, mouse & touch events.
*
* @param target The popup <em>closable</em> element.
* @param closeCallback Callback function triggered when an event fires that should close the target
* element.
*/
constructor(target: HTMLElement, closeCallback: () => void);
/**
* Inform the class that the target is now open. This adds the global <em>neon-closable--open</em> class to the
* document body to prevent page scrolling while a popup is open.
*/
open(): void;
/**
* Destroy the listeners. Call this in the parent component's onUnmounted method.
*/
destroy(): void;
escapeKeyListener(event: KeyboardEvent): void;
/**
* Handle closing of the target element. This triggers the closeCallback & removes the global
* <em>neon-closable--open</em> class from the document body.
*/
close(): void;
private handleOutsideClick;
}