/** * Common Utilities * Shared utility functions used across the component library */ /** * Generate a unique ID with optional prefix * @param prefix - Optional prefix for the ID (default: 'id') */ export declare function generateUniqueId(prefix?: string): string; /** * Reset ID counter (useful for testing) */ export declare function resetIdCounter(): void; /** * Debounce a function * @param fn - Function to debounce * @param delay - Delay in milliseconds */ export declare function debounce any>(fn: T, delay: number): (...args: Parameters) => void; /** * Throttle a function * @param fn - Function to throttle * @param delay - Delay in milliseconds */ export declare function throttle any>(fn: T, delay: number): (...args: Parameters) => void; /** * Add a class to an element * @param element - The element * @param className - Class name to add */ export declare function addClass(element: HTMLElement, className: string): void; /** * Remove a class from an element * @param element - The element * @param className - Class name to remove */ export declare function removeClass(element: HTMLElement, className: string): void; /** * Toggle a class on an element * @param element - The element * @param className - Class name to toggle * @param force - Optional force add/remove */ export declare function toggleClass(element: HTMLElement, className: string, force?: boolean): void; /** * Check if element has a class * @param element - The element * @param className - Class name to check */ export declare function hasClass(element: HTMLElement, className: string): boolean; /** * Get all data attributes from an element as an object */ export declare function getDataAttributes(element: HTMLElement): Record; /** * Set a data attribute on an element * @param element - The element * @param key - Data attribute name (without 'data-' prefix) * @param value - The value to set */ export declare function setDataAttribute(element: HTMLElement, key: string, value: string | null): void; /** * Get the value of a data attribute * @param element - The element * @param key - Data attribute name (without 'data-' prefix) */ export declare function getDataAttribute(element: HTMLElement, key: string): string | undefined; /** * Dispatch a custom event from an element * @param element - The element to dispatch from * @param eventName - Name of the custom event * @param detail - Optional detail object to include in the event */ export declare function dispatchCustomEvent(element: HTMLElement | Document | Window, eventName: string, detail?: T): void; /** * Listen for a custom event * @param element - The element to listen on * @param eventName - Name of the custom event * @param handler - Callback function * @returns Cleanup function to remove listener */ export declare function onCustomEvent(element: HTMLElement | Document | Window, eventName: string, handler: (detail: T) => void): () => void; /** * Get the offset position of an element relative to the viewport */ export declare function getElementOffset(element: HTMLElement): { top: number; left: number; }; /** * Check if an element is in the viewport */ export declare function isElementInViewport(element: HTMLElement): boolean; /** * Scroll element into view * @param element - The element to scroll into view * @param options - Scroll behavior options */ export declare function scrollIntoView(element: HTMLElement, options?: ScrollIntoViewOptions): void; /** * Get computed style value */ export declare function getComputedValue(element: HTMLElement, property: string): string; /** * Wait for a specific time * @param ms - Time in milliseconds */ export declare function wait(ms: number): Promise; /** * Wait for an element to appear in the DOM * @param selector - CSS selector to wait for * @param timeout - Timeout in milliseconds (default: 5000) */ export declare function waitForElement(selector: string, timeout?: number): Promise; /** * Clone an object deeply */ export declare function deepClone(obj: T): T; /** * Merge objects */ export declare function mergeObjects>(target: T, ...sources: Partial[]): T; /** * Get the prefixed CSS property name (for vendor prefixes) */ export declare function getPrefixedProperty(property: string): string; /** * Check if browser supports a CSS feature */ export declare function supportsCSSFeature(property: string, value: string): boolean; /** * Request animation frame with promise */ export declare function requestAnimationFramePromise(): Promise; /** * Convert camelCase to kebab-case */ export declare function camelToKebab(str: string): string; /** * Convert kebab-case to camelCase */ export declare function kebabToCamel(str: string): string; /** * Check if an element has slotted content for a given slot name * @param el - The host element to check * @param name - The slot name to check for * @param checkTextContent - Whether to check text content for default slot (default: false) */ export declare function hasSlot(el: HTMLElement, name: string, checkTextContent?: boolean): boolean; /** * Build a class string from a record of class names and their active states * @param classes - Object with class names as keys and boolean values for active state */ export declare function buildClassString(classes: Record): string;