import type { Percent } from "./Percent"; import type { IPointerEvent } from "../render/backend/Renderer"; import type { Sprite } from "../render/Sprite"; import * as $type from "./Type"; import type { IBounds } from "./IBounds"; import { DisposerClass, IDisposer } from "./Disposer"; /** * ============================================================================ * DOM FUNCTIONS * ============================================================================ * @hidden */ /** * Execute a function when DOM is ready. * * @since 5.0.2 * @param f Callback */ export declare function ready(f: () => void): void; /** * Removes a DOM element. * @param el Target element */ export declare function removeElement(el: HTMLElement): void; /** * Function that adds a disposable event listener directly to a DOM element. * * @ignore Exclude from docs * @param dom A DOM element to add event to * @param type Event type * @param listener Event listener * @returns Disposable event */ export declare function addEventListener(dom: EventTarget, type: string, listener: (event: E) => void, options?: any): IDisposer; /** * Function that adds an event listener which is triggered when the browser's zoom changes. * * @param listener Event listener * @returns Disposable event */ export declare function onZoom(listener: () => void): IDisposer; /** * @ignore */ export declare function supports(cap: "touchevents" | "pointerevents" | "mouseevents" | "wheelevents" | "keyboardevents"): boolean; /** * @ignore */ export declare function getPointerId(event: IPointerEvent): any; /** * Removes focus from any element by shifting focus to body. * * @ignore */ export declare function blur(): void; /** * Focuses element. * * @ignore */ export declare function focus(el: HTMLElement): void; /** * @ignore */ export declare function getRendererEvent(key: string): string; /** * Determines if pointer event originated from a touch pointer or mouse. * * @param ev Original event * @return Touch pointer? */ export declare function isTouchEvent(ev: MouseEvent | Touch): boolean; /** * Sets style property on DOM element. * * @ignore Exclude from docs */ export declare function setStyle(dom: HTMLElement, property: string, value: string | undefined): void; /** * Gets style property value on a DOM element. * * @ignore Exclude from docs */ export declare function getStyle(dom: HTMLElement, property: string): string | undefined; /** * Gets the target of the event, works for shadow DOM too. */ export declare function getEventTarget(event: Event | Touch): Node | null; /** * Checks of element `a` contains element `b`. * * @param a Aleged ascendant * @param b Aleged descendant * @return Contains? */ export declare function contains(a: Element, b: Element): boolean; /** * Returns `true` if pointer event originated on an element within Root. * * @since 5.2.8 * @param event Event * @param target Target element */ export declare function isLocalEvent(event: IPointerEvent, target: Sprite): boolean | null; /** * Disables or enables interactivity of a DOM element. * * @param target Target element * @param interactive Interactive? */ export declare function setInteractive(target: HTMLElement, interactive: boolean): void; /** * Returns a normalized key name from a keyboard event. * * @ignore */ export declare function getEventKey(event: KeyboardEvent): string; /** * Returns the shadow root of the element or null * * @param a Node * @return Root */ export declare function getShadowRoot(a: Node): ShadowRoot | null; /** * Defines a class for a CSS rule. * * Can be used to dynamically add CSS to the document. */ export declare class StyleRule extends DisposerClass { private _root; /** * CSS rule. */ private _rule; /** * A CSS selector text. * * E.g.: `.myClass p` * * @param selector CSS selector */ set selector(selector: string); /** * @return CSS selector */ get selector(): string; /** * Constructor. * * @param selector CSS selector * @param styles An object of style attribute - value pairs */ constructor(element: ShadowRoot | null, selector: string, styles: { [name: string]: string; }, nonce?: string); protected _dispose(): void; /** * Sets the same style properties with browser-specific prefixes. * * @param name Attribute name * @param value Attribute value */ private _setVendorPrefixName; /** * Sets a value for specific style attribute. * * @param name Attribute * @param value Value */ setStyle(name: string, value: string): void; } /** * Defines a class for an entire CSS style sheet. * * Can be used to dynamically add CSS to the document. */ export declare class StyleSheet extends DisposerClass { private _element; /** * Constructor. * * @param text CSS stylesheet */ constructor(element: ShadowRoot | null, text: string, nonce?: string); protected _dispose(): void; } /** * Adds a class name to an HTML or SVG element. * * @ignore Exclude from docs * @param element Element * @param className Class name to add */ export declare function addClass(element: HTMLElement | SVGElement, className: string): void; /** * Removes a class name from an HTML or SVG element. * * @ignore Exclude from docs * @param element Element * @param className Class name to add */ export declare function removeClass(element: HTMLElement, className: string): void; /** * Returns `true` if the current device is running iOS. * * @return Is iOS? */ export declare function iOS(): boolean; /** * Returns a safe canvas resolution for the current device. * Returns `1` on iOS to avoid memory issues, `undefined` otherwise. * * @return Resolution or undefined */ export declare function getSafeResolution(): number | undefined; /** * Converts a value that can be a number or [[Percent]] to an absolute number * relative to the given full value. * * @param percent Input value (number or Percent) * @param full Full reference value * @return Absolute value */ export declare function relativeToValue(percent: number | Percent | undefined | null, full: number): number; /** * Returns number of decimals * * @ignore Exclude from docs * @param number Input number * @return Number of decimals */ export declare function decimalPlaces(number: number): number; /** * ============================================================================ * STRING FORMATTING FUNCTIONS * ============================================================================ * @hidden */ /** * Pads a string with additional characters to certain length. * * @param value A numeric value * @param len Result string length in characters * @param char A character to use for padding * @return Padded value as string */ export declare function padString(value: any, len?: number, char?: string): string; /** * Removes whitespace from the beginning of a string. * * @param text Source string * @return Trimmed string */ export declare function trimLeft(text: string): string; /** * Removes whitespace from the end of a string. * * @param text Source string * @return Trimmed string */ export declare function trimRight(text: string): string; /** * Removes whitespace from both ends of a string. * * @param text Source string * @return Trimmed string */ export declare function trim(text: string): string; /** * Truncates a string to a maximum length, appending an ellipsis. * * @param text Source string * @param maxLength Maximum character length * @param breakWords Allow breaking mid-word? * @param ellipsis Ellipsis string to append * @return Truncated string */ export declare function truncateTextWithEllipsis(text: string, maxLength: number, breakWords?: boolean, ellipsis?: string): string; /** * Tries to determine format type. * * @ignore Exclude from docs * @param format Format string * @return Format type ("string" | "number" | "date" | "duration") */ export declare function getFormat(format: string): string; /** * Cleans up format: * * Strips out formatter hints * * @ignore Exclude from docs * @param format Format * @return Cleaned format */ export declare function cleanFormat(format: string): string; /** * Strips all tags from the string. * * @param text Source string * @return String without tags */ export declare function stripTags(text: string): string; /** * Strips inline formatting tags (square brackets) from the string. * * @param text Source string * @return String without tags */ export declare function stripFormatTags(text: string): string; /** * Removes new lines and tags from a string. * * @param text String to conver * @return Converted string */ export declare function plainText(text: string): string; /** * Sanitizes an HTML string by stripping out constructs that are practically * only used for cross-site scripting (XSS) attacks, while leaving legitimate * markup intact. Specifically it removes: * * * `