/** * DOM Utils methods. * * @export * @abstract * @class DOMUtils */ export declare abstract class DOMUtils { /** * Returns the value of a cookie. * * @static * @param {(string | null)} name Cookie's name. * @return {String} Cookie's value. * @memberof DOMUtils */ static getCookie(name: string): string | null; /** * Returns the value of a Local Storage key. * * @static * @template T * @param {string} key Local Storage key name. * @return {T} Local Storage value. * @memberof DOMUtils */ static getStorage(key: string): T; /** * Changes the value of a key in LocalStorage. * * @static * @param {string} key Key's name. * @param {object} data Key's value. * @memberof DOMUtils */ static setStorage(key: string, data: object): void; /** * Find elements matched by a selector. * * @static * @param {string} selector Search selector. * @param {NodeSelector} [element=document] Relative element. * @return {(HTMLElement[] | null)} Found elements. * @memberof DOMUtils */ static find(selector: string, element?: ParentNode): HTMLElement[] | null; /** * Find the first element matched by a selector. * * @static * @param {string} selector Search selector. * @param {NodeSelector} [element=document] Relative element. * @return {(HTMLElement[] | null)} Found element. * @memberof DOMUtils */ static findOne(selector: string, element?: ParentNode): HTMLElement; /** * Get element by ID. * * @static * @param {string} id ID to search for. * @return {(HTMLElement | null)} Found element. * @memberof DOMUtils */ static findById(id: string): HTMLElement | null; /** * Find elements by tag. * * @static * @param {string} tag Tag to search for. * @return {(HTMLElement[] | null)} Found elements. * @memberof DOMUtils */ static findByTag(tag: string): HTMLElement[] | null; /** * Find first element by tag. * * @static * @param {string} tag Tag to search for. * @return {(HTMLElement | null)} Found element. * @memberof DOMUtils */ static findOneByTag(tag: string): HTMLElement | null; /** * Find the previous element of a selector. * * @static * @param {HTMLElement} element Root search element * @param {string} selector Search selector * @return {(HTMLElement | null)} Found element * @memberof DOMUtils */ static previous(element: HTMLElement, selector?: string): HTMLElement | null; /** * Find the next element of a selector. * * @static * @param {HTMLElement} element Root search element * @param {string} selector Search selector * @return {(HTMLElement | null)} Found element * @memberof DOMUtils */ static next(element: HTMLElement, selector?: string): HTMLElement | null; /** * Find the parent element of a selector. * * @static * @param {HTMLElement} element Root search element * @param {string} selector Search selector * @return {(HTMLElement | null)} Found element * @memberof DOMUtils */ static parent(element: HTMLElement, selector?: string): HTMLElement | null; /** * Remove an element from the DOM. * * @static * @param {(HTMLElement | null)} element Element to be removed. * @memberof DOMUtils */ static remove(element: HTMLElement | null): void; /** * Create a new Element. * * @static * @param {string} tag Element's tag. * @return {HTMLElement} Created element. * @memberof DOMUtils */ static create(tag: string): HTMLElement; /** * Add a new event to an element. * * @static * @param {EventTarget} element Element to add the event. * @param {string} type Event type. * @param {(e: Event) => void} callback Event callback. * @memberof DOMUtils */ /** * Add a new event to an element. * * @static * @param {EventTarget} element Element to add the event. * @param {string} type Event type. * @param {Function} callback Event callback. * @memberof DOMUtils */ static addEvent(element: EventTarget, type: string, callback: (e: Event) => void): void; /** * Remove an event from an element. * * @static * @param {EventTarget} element Element to remove the event from. * @param {string} type Event type. * @param {Function} callback Event callback. * @memberof DOMUtils */ static removeEvent(element: EventTarget, type: string, callback: (e: Event) => void): void; /** * Trigger a customized event. * * @static * @param {string} type Event type. * @param {EventTarget} [target=window] Event target. Global if not present. * @memberof DOMUtils */ static triggerEvent(type: string, target?: EventTarget): void; /** * Wrap HTML in an element. * * @static * @param {string} tag Wrapper tag. * @param {string} html Content. * @return {HTMLElement} Created element. * @memberof DOMUtils */ static wrapCreate(tag: string, html: string): HTMLElement; /** * Validate if an element has a class. * * @static * @param {HTMLElement} element Element to validate. * @param {string} className Class to search for. * @return {boolean} If it has. * @memberof DOMUtils */ static hasClass(element: HTMLElement, className: string): boolean; /** * Add a class to an element. * * @static * @param {HTMLElement} element Element to add class to. * @param {string} className Class to add. * @memberof DOMUtils */ static addClass(element: HTMLElement, className: string): void; /** * Remove class from element. * * @static * @param {HTMLElement | HTMLElement[]} elements Element to remove class from. * @param {...string[]} classList Class to remove. * @memberof DOMUtils */ static removeClass(elements: HTMLElement | HTMLElement[], ...classList: string[]): void; /** * Toggle class in an element. * * @static * @param {HTMLElement} element Element to toggle. * @param {string} className Class to toggle. * @memberof DOMUtils */ static toggleClass(element: HTMLElement, className: string): void; /** * Check if is a child element. * * @static * @param {HTMLElement} parent Parent element. * @param {HTMLElement} child Possible child element. * @return {boolean} If parent contains child. * @memberof DOMUtils */ static isDescendant(parent: HTMLElement, child: HTMLElement): boolean; /** * Events debounce. * * @static * @param {Function} method Debounce method. * @param {number} delay Delay (in ms). * @memberof DOMUtils */ static debounce(method: () => void, delay: number): void; /** * Events first debounce. * * @static * @static * @param {Function} method Debounce method. * @param {number} delay Delay (in ms). * @memberof DOMUtils */ static firstDebounce(method: (...args: T[]) => void, delay: number, ...args: T[]): void; /** * Check if text matches, ignoring diacritics. * * @static * @param {string} text Original text. * @param {string} match Text to match. * @return {boolean} If matches. * @memberof DOMUtils */ static textMatch(text: string, match: string): boolean; /** * Compare two objects. * * @static * @param {*} leftObject Object A. * @param {*} rightObject Object B. * @return {boolean} If equals * @memberof DOMUtils */ static deepEquals(leftObject: T, rightObject: U): boolean; /** * Remove diacritics from text. * * @static * @param {string} text Text to change. * @return {string} Text without diacritics. * @memberof DOMUtils */ static removeDiacritics(text: string): string; }