@studiometa/js-toolkit
Version:
A set of useful little bits of JavaScript to boost your project! 🚀
40 lines (39 loc) • 1.6 kB
TypeScript
import type { Base, BaseConfig, BaseConstructor } from './index.js';
/**
* Add a task to the main queue.
*/
export declare function addToQueue(fn: () => unknown): Promise<unknown>;
/**
* Get the selector for a given component.
*/
export declare function getSelector(nameOrSelector: string): string;
/**
* Get a list of elements based on the name of a component.
*
* @param {string} nameOrSelector
* The name or selector to used for this component.
* @param {HTMLElement|Document} element
* The root element on which to query the selector, defaults to `document`.
* @returns {Array<HTMLElement>}
* A list of elements on which the component should be mounted.
*/
export declare function getComponentElements(nameOrSelector: string, element?: HTMLElement | Document): HTMLElement[];
/**
* Test if an event is defined in the given config.
*/
export declare function eventIsDefinedInConfig(event: string, config: BaseConfig): boolean;
/**
* Test if an event can be used on the given element.
*/
export declare function eventIsNative(event: string, element: HTMLElement): boolean;
/**
* Get the target of a given event.
*/
export declare function getEventTarget(instance: Base, event: string, config: BaseConfig): Base['$el'];
/**
* Get all mounted instances or the ones from a given component.
*/
export declare function getInstances(): Set<Base>;
export declare function getInstances<T extends BaseConstructor = BaseConstructor>(ctor: T): Set<InstanceType<T>>;
export declare function addInstance(instance: Base): void;
export declare function deleteInstance(instance: Base): void;