@studiometa/js-toolkit
Version:
A set of useful little bits of JavaScript to boost your project! 🚀
110 lines (109 loc) • 2.85 kB
TypeScript
import type { Base } from '../index.js';
import { AbstractManager } from './AbstractManager.js';
export type EventManagerCallbackParams<T extends Event = Event> = {
event: T;
args: Array<any>;
index: number;
target: Element | Base | Promise<Base> | typeof window | typeof document | null;
};
/**
* Event management class.
*
* @todo Prevent binding of `onChildOrRefEvent` to the root element
* @todo Use event delegation?
*/
export declare class EventsManager extends AbstractManager {
__methodsCache: Map<string, string[]>;
/**
* Event listener object for the root element.
*/
__rootElementHandler: EventListenerObject;
/**
* Event listener object for the root element.
*
* @type {EventListenerObject}
*/
__documentHandler: {
/**
* @param {Event|CustomEvent} event
* @return {void}
*/
handleEvent: (event: any) => void;
};
/**
* Event listener object for the root element.
*
* @type {EventListenerObject}
*/
__windowHandler: {
/**
* @param {Event|CustomEvent} event
* @return {void}
*/
handleEvent: (event: any) => void;
};
/**
* Event listener object for the refs.
*/
__refsHandler: EventListenerObject;
/**
* Event listener object for the children.
*/
__childrenHandler: EventListenerObject;
/**
* Class constructor.
*/
constructor(base: Base);
/**
* Bind event methods to the given ref elements.
*
* @param {string} name
* The name of the ref.
* @param {HTMLElement[]} elements
* The elements of the ref.
* @return {void}
*/
bindRef(name: string, elements: HTMLElement[]): void;
/**
* Bind event methods to the given ref elements.
*
* @param {string} name
* The name of the ref.
* @param {HTMLElement[]} elements
* The elements of the ref.
* @return {void}
*/
unbindRef(name: string, elements: HTMLElement[]): void;
/**
* Bind event methods to the given child instance.
*
* @param {string} name
* The name of the ref.
* @param {Base} instance
* A base instance.
* @return {void}
*/
bindChild(name: string, instance: Base): void;
/**
* Unbind event methods to the given child instance.
*
* @param {string} name
* The name of the ref.
* @param {Base} instance
* A base instance.
* @return {void}
*/
unbindChild(name: string, instance: Base): void;
/**
* Bind event methods on the root element.
*
* @return {void}
*/
bindRootElement(): void;
/**
* Unbind event method from the root element.
*
* @return {void}
*/
unbindRootElement(): void;
}