@paperlinkai/chat
Version:
PaperLink AI Chat Widget - Easy integration for any website
64 lines (63 loc) • 2.13 kB
TypeScript
/**
* DOM utility functions for widget manipulation
*/
export declare class DOMUtils {
/**
* Safely query selector with error handling
*/
static querySelector<T extends Element = Element>(selector: string, parent?: Document | Element): T | null;
/**
* Create element with attributes and styles
*/
static createElement<K extends keyof HTMLElementTagNameMap>(tagName: K, options?: {
id?: string;
className?: string;
textContent?: string;
attributes?: Record<string, string>;
styles?: Partial<CSSStyleDeclaration>;
innerHTML?: string;
}): HTMLElementTagNameMap[K];
/**
* Check if element is visible in viewport
*/
static isElementVisible(element: Element): boolean;
/**
* Scroll element into view smoothly
*/
static scrollIntoView(element: Element, behavior?: ScrollBehavior): void;
/**
* Debounce function for performance optimization
*/
static debounce<T extends (...args: any[]) => any>(func: T, delay: number): (...args: Parameters<T>) => void;
/**
* Throttle function for performance optimization
*/
static throttle<T extends (...args: any[]) => any>(func: T, delay: number): (...args: Parameters<T>) => void;
/**
* Generate unique ID
*/
static generateId(prefix?: string): string;
/**
* Check if element has specific class
*/
static hasClass(element: Element, className: string): boolean;
/**
* Add event listener with cleanup
*/
static addEventListener<K extends keyof HTMLElementEventMap>(element: Element | Window | Document, type: K, listener: (this: Element, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): () => void;
/**
* Get computed style property value
*/
static getComputedStyle(element: Element, property: string): string;
/**
* Check if device is mobile
*/
static isMobileDevice(): boolean;
/**
* Get viewport dimensions
*/
static getViewportDimensions(): {
width: number;
height: number;
};
}