/** * Get the parent of the specified node in the DOM tree. * * @param {HTMLElement} element Element from which traversing is started. * @param {number} [level=0] Traversing deep level. * @returns {HTMLElement|null} */ export declare function getParent(element: HTMLElement | Node, level?: number): HTMLElement | null; /** * Check if the provided element is a child of the provided Handsontable container. * * @param {HTMLElement} element Element to be analyzed. * @param {HTMLElement} thisHotContainer The Handsontable container. * @returns {boolean} */ export declare function isInternalElement(element: HTMLElement, thisHotContainer: HTMLElement): boolean; /** * Gets the event target element cast to the specified HTML element type. * Centralizes the `event.target as HTMLElement` cast pattern. * * @param {Event} event The event. * @returns {T|null} The target element or null. */ export declare function eventTargetEl(event: Event): T | null; /** * Gets `frameElement` of the specified frame. Returns null if it is a top frame or if script has no access to read property. * * @param {Window} frame Frame from which should be get frameElement in safe way. * @returns {HTMLIFrameElement|null} */ export declare function getFrameElement(frame: Window): HTMLIFrameElement | null; /** * Gets parent frame of the specified frame. Returns null if it is a top frame or if script has no access to read property. * * @param {Window} frame Frame from which should get frameElement in a safe way. * @returns {Window|null} */ export declare function getParentWindow(frame: Window): Window | null; /** * Checks if script has access to read from parent frame of specified frame. * * @param {Window} frame Frame from which should get frameElement in a safe way. * @returns {boolean} */ export declare function hasAccessToParentWindow(frame: Window): boolean; /** * Goes up the DOM tree (including given element) until it finds an parent element that matches the nodes or nodes name. * This method goes up through web components. * * @param {Node} element Element from which traversing is started. * @param {Array} [nodes] Array of elements or Array of elements name (in uppercase form). * @param {Node} [until] The element until the traversing ends. * @returns {Node|null} */ export declare function closest(element: HTMLElement, nodes?: Array, until?: Node): HTMLElement | null; /** * Goes "down" the DOM tree (including given element) until it finds an element that matches the nodes or nodes name. * * @param {HTMLElement} element Element from which traversing is started. * @param {Array} nodes Array of elements or Array of elements name. * @param {HTMLElement} [until] The list of elements until the traversing ends. * @returns {HTMLElement|null} */ export declare function closestDown(element: HTMLElement | Node | Element | null, nodes: Array, until?: HTMLElement): HTMLElement | null; /** * Traverses up the DOM tree from the given element and finds parent elements that have a specified class name * or match a provided class name regular expression. * * @param {HTMLElement} element - The element from which to start traversing. * @param {string|RegExp} className - The class name or class name regular expression to check. * @returns {{element: HTMLElement, classNames: string[]}} - Returns an object containing the matched parent element and an array of matched class names. */ export declare function findFirstParentWithClass(element: HTMLElement, className: string | RegExp): { element: HTMLElement | undefined; classNames: string[]; }; /** * Goes up the DOM tree and checks if element is child of another element. * * @param {HTMLElement} child Child element An element to check. * @param {object|string} parent Parent element OR selector of the parent element. * If string provided, function returns `true` for the first occurrence of element with that class. * @returns {boolean} */ export declare function isChildOf(child: HTMLElement | Document, parent: HTMLElement | Document | string): boolean; /** * Counts index of element within its parent. * WARNING: for performance reasons, assumes there are only element nodes (no text nodes). This is true * for Walkotnable, otherwise would need to check for nodeType or use previousElementSibling. * * @see http://jsperf.com/sibling-index/10 * @param {Element} element The element to check. * @returns {number} */ export declare function index(element: Element): number; /** * Check if the provided overlay contains the provided element. * * @param {string} overlayType The type of the overlay. * @param {HTMLElement} element An element to check. * @param {HTMLElement} root The root element. * @returns {boolean} */ export declare function overlayContainsElement(overlayType: string, element: HTMLElement, root: HTMLElement): boolean; /** * Checks whether the provided TH belongs to the bottom-most visual layer of column headers. * The function treats headers that use `rowspan` and reach the last header row as bottom-most. * * @param {HTMLTableCellElement} TH The TH element to check. * @returns {boolean} */ export declare function isBottomMostColumnHeader(TH: HTMLTableCellElement): boolean; /** * Checks if element has class name. * * @param {HTMLElement} element An element to check. * @param {string} className Class name to check. * @returns {boolean} */ export declare function hasClass(element: HTMLElement, className: string): boolean; /** * Add class name to an element. * * @param {HTMLElement} element An element to process. * @param {string|Array} className Class name as string or array of strings. */ export declare function addClass(element: HTMLElement, className: string | string[]): void; /** * Remove class name from an element. * * @param {HTMLElement} element An element to process. * @param {string|RegExp|Array} className Class name as string or array of strings. */ export declare function removeClass(element: HTMLElement, className: string | string[] | RegExp | (string | RegExp)[]): void; /** * Set a single attribute or multiple attributes at once. * * @param {HTMLElement} domElement The HTML element to be modified. * @param {Array[]|string} attributes If setting multiple attributes at once, `attributes` holds an array containing the * attributes to be added. Each element of the array should be an array in a form of `[attributeName, * attributeValue]`. If setting a single attribute, `attributes` holds the name of the attribute. * @param {string|number|undefined} [attributeValue] If setting a single attribute, `attributeValue` holds the attribute * value. */ export declare function setAttribute(domElement: HTMLElement, attributes?: [string, string | number | boolean][] | string, attributeValue?: string | number | boolean): void; /** * Remove a single attribute or multiple attributes from the provided element at once. * * @param {HTMLElement} domElement The HTML element to be processed. * @param {Array|string} attributesToRemove If removing multiple attributes, `attributesToRemove` * holds an array of attribute names to be removed from the provided element. If removing a single attribute, it * holds the attribute name. */ export declare function removeAttribute(domElement: HTMLElement, attributesToRemove?: (string | RegExp)[] | string | RegExp): void; /** * @param {Node} element An element from the text is removed. */ export declare function removeTextNodes(element: Node): void; /** * Remove children function * WARNING - this doesn't unload events and data attached by jQuery * http://jsperf.com/jquery-html-vs-empty-vs-innerhtml/9 * http://jsperf.com/jquery-html-vs-empty-vs-innerhtml/11 - no siginificant improvement with Chrome remove() method. * * @param {HTMLElement} element An element to clear. */ export declare function empty(element: HTMLElement): void; export declare const HTML_CHARACTERS: RegExp; /** * Shared "warn once" key for every missing-sanitizer warning, so that all DOM * write surfaces (headers, context menu, dialogs, notifications, editors) * collapse into a single warning per Handsontable instance. */ export declare const SANITIZER_WARN_KEY = "sanitizer"; /** * Insert content into element trying to avoid innerHTML method. * * @param {HTMLElement} element An element to write into. * @param {string} content The text to write. * @param {boolean|function(string, string): string} [sanitizer] When a function, use it as the sanitizer; when `false`, * write the content as raw HTML on purpose (no warning); when `true` (the default), write the content as raw HTML and * warn once that no sanitizer is configured. * @param {string} [context] The sanitization context passed as the second argument to a custom sanitizer function, and * used in the missing-sanitizer warning to identify the write surface. * @param {object} [scope] Object the "warn once" state is bound to (for example, `hot.rootGridElement`), so the warning * is shown at most once per Handsontable instance. */ export declare function fastInnerHTML(element: HTMLElement, content: string, sanitizer?: boolean | ((html: string, context: string) => string), context?: string, scope?: object): void; /** * Insert text content into element. * * @param {HTMLElement} element An element to write into. * @param {string} content The text to write. */ export declare function fastInnerText(element: HTMLElement, content: string): void; /** * Returns true if element is attached to the DOM and visible, false otherwise. * * @param {HTMLElement} element An element to check. * @returns {boolean} */ export declare function isVisible(element: HTMLElement): boolean; /** * Returns true if the element has the height set to `0` or `0px` and overflow to `hidden` (height deliberately set to be 0). * * @param {HTMLElement} element The element to check. * @returns {boolean} `true` if the element has height set to `0` or `0px` and overflow is set to `hidden`, `false` otherwise. */ export declare function hasZeroHeight(element: HTMLElement): boolean; /** * Returns elements top and left offset relative to the document. Function is not compatible with jQuery offset. * * @param {HTMLElement} element An element to get the offset position from. * @returns {object} Returns object with `top` and `left` props. */ export declare function offset(element: HTMLElement): { left: number; top: number; }; /** * Returns the document's scrollTop property. * * @param {Window} [rootWindow] The document window owner. * @returns {number} */ export declare function getWindowScrollTop(rootWindow?: Window): number; /** * Returns the document's scrollLeft property. * * @param {Window} [rootWindow] The document window owner. * @returns {number} */ export declare function getWindowScrollLeft(rootWindow?: Window): number; /** * Returns the provided element's scrollTop property. * * @param {HTMLElement} element An element to get the scroll top position from. * @param {Window} [rootWindow] The document window owner. * @returns {number} */ export declare function getScrollTop(element: HTMLElement | Window, rootWindow?: Window): number; /** * Returns the provided element's scrollLeft property. * * @param {HTMLElement} element An element to get the scroll left position from. * @param {Window} [rootWindow] The document window owner. * @returns {number} */ export declare function getScrollLeft(element: HTMLElement | Window, rootWindow?: Window): number; /** * Returns a DOM element responsible for scrolling of the provided element. * * @param {HTMLElement} element An element to get the scrollable element from. * @returns {HTMLElement} Element's scrollable parent. */ export declare function getScrollableElement(element: HTMLElement): HTMLElement | Window; /** * Get the maximum available `scrollTop` value for the provided element. * * @param {HTMLElement} element The element to get the maximum scroll top value from. * @returns {number} The maximum scroll top value. */ export declare function getMaximumScrollTop(element: HTMLElement): number; /** * Get the maximum available `scrollLeft` value for the provided element. * * @param {HTMLElement} element The element to get the maximum scroll left value from. * @returns {number} The maximum scroll left value. */ export declare function getMaximumScrollLeft(element: HTMLElement): number; /** * Returns a DOM element responsible for trimming the provided element. * * @param {HTMLElement} base Base element. * @returns {HTMLElement} Base element's trimming parent. */ export declare function getTrimmingContainer(base: HTMLElement): HTMLElement | Window; /** * Returns a style property for the provided element. (Be it an inline or external style). * * @param {HTMLElement} element An element to get the style from. * @param {string} prop Wanted property. * @param {Window} [rootWindow] The document window owner. * @returns {string|undefined} Element's style property. */ export declare function getStyle(element: HTMLElement | Window, prop: string, rootWindow?: Window): string | undefined; /** * Verifies if element fit to provided CSSRule. * * @param {Element} element Element to verify with selector text. * @param {CSSRule} rule Selector text from CSSRule. * @returns {boolean} */ export declare function matchesCSSRules(element: Element, rule: CSSRule): boolean; /** * Returns the element's outer width. * * @param {HTMLElement} element An element to get the width from. * @returns {number} Element's outer width. */ export declare function outerWidth(element: HTMLElement): number; /** * Returns the element's outer height. * * @param {HTMLElement} element An element to get the height from. * @returns {number} Element's outer height. */ export declare function outerHeight(element: HTMLElement): number; /** * Returns the element's inner height. * * @param {HTMLElement} element An element to get the height from. * @returns {number} Element's inner height. */ export declare function innerHeight(element: HTMLElement | Window): number; /** * Returns the element's inner width. * * @param {HTMLElement} element An element to get the width from. * @returns {number} Element's inner width. */ export declare function innerWidth(element: HTMLElement | Window): number; /** * @param {HTMLElement} element An element to which the event is added. * @param {string} event The event name. * @param {Function} callback The callback to add. */ export declare function addEvent(element: HTMLElement, event: string, callback: (event?: Event) => void): void; /** * @param {HTMLElement} element An element from which the event is removed. * @param {string} event The event name. * @param {Function} callback The function reference to remove. */ export declare function removeEvent(element: HTMLElement, event: string, callback: () => void): void; /** * Returns caret position in text input. * * @author https://stackoverflow.com/questions/263743/how-to-get-caret-position-in-textarea * @param {HTMLInputElement|HTMLTextAreaElement} el An element to check. * @returns {number} */ export declare function getCaretPosition(el: HTMLInputElement | HTMLTextAreaElement): number; /** * Returns end of the selection in text input. * * @param {HTMLInputElement|HTMLTextAreaElement} el An element to check. * @returns {number} */ export declare function getSelectionEndPosition(el: HTMLInputElement | HTMLTextAreaElement): number; /** * Returns text under selection. * * @param {Window} [rootWindow] The document window owner. * @returns {string} */ export declare function getSelectionText(rootWindow?: Window): string; /** * Cross-platform helper to clear text selection. * * @param {Window} [rootWindow] The document window owner. */ export declare function clearTextSelection(rootWindow?: Window): void; /** * Sets caret position in text input. * * @author http://blog.vishalon.net/index.php/javascript-getting-and-setting-caret-position-in-textarea/ * @param {HTMLInputElement|HTMLTextAreaElement} element An element to process. * @param {number} pos The selection start position. * @param {number} endPos The selection end position. */ export declare function setCaretPosition(element: HTMLInputElement | HTMLTextAreaElement, pos: number, endPos: number | undefined): void; /** * Returns the fractional scaling compensation for scrollbar width calculation. * * @param {Document} rootDocument The onwer of the document. * @returns {number} The compensation for the scrollbar width, when the device pixel ratio is not an integer. */ export declare function getFractionalScalingCompensation(rootDocument?: Document): number; /** * Returns the computed width of the native browser scroll bar. * * @param {Document} [rootDocument] The owner of the document. * @returns {number} The computed width of the native browser scroll bar. */ export declare function getScrollbarWidth(rootDocument?: Document): number; /** * Checks if the provided element has a vertical scrollbar. * * @param {HTMLElement|Window} element An element to check. * @returns {boolean} */ export declare function hasVerticalScrollbar(element: HTMLElement | Window): boolean; /** * Checks if the provided element has a vertical scrollbar. * * @param {HTMLElement|Window} element An element to check. * @returns {boolean} */ export declare function hasHorizontalScrollbar(element: HTMLElement | Window): boolean; /** * Sets overlay position depending on it's type and used browser. * * @param {HTMLElement} overlayElem An element to process. * @param {number|string} left The left position of the overlay. * @param {number|string} top The top position of the overlay. */ export declare function setOverlayPosition(overlayElem: HTMLElement, left: string | number, top: string | number): void; /** * @param {HTMLElement} element An element to process. * @returns {number|Array} */ export declare function getCssTransform(element: HTMLElement): number | [string, string]; /** * @param {HTMLElement} element An element to process. */ export declare function resetCssTransform(element: HTMLElement): void; /** * Determines if the given DOM element is an input field. * Notice: By 'input' we mean input, textarea and select nodes. * * @param {HTMLElement} element - DOM element. * @returns {boolean} */ export declare function isInput(element: HTMLElement): boolean; /** * Determines if the given DOM element is an input field placed OUTSIDE of HOT. * Notice: By 'input' we mean input, textarea and select nodes which have defined 'data-hot-input' attribute. * * @param {HTMLElement} element - DOM element. * @returns {boolean} */ export declare function isOutsideInput(element: HTMLElement): boolean; /** * Check if the given DOM element can be focused (by using "select" method). * * @param {HTMLElement} element - DOM element. */ export declare function selectElementIfAllowed(element: HTMLElement): void; /** * Check if the provided element is detached from DOM. * * @param {HTMLElement} element HTML element to be checked. * @returns {boolean} `true` if the element is detached, `false` otherwise. */ export declare function isDetached(element: HTMLElement): boolean; /** * Set up an observer to recognize when the provided element first becomes visible and trigger a callback when it * happens. * * @param {HTMLElement} elementToBeObserved Element to be observed. * @param {Function} callback The callback function. */ export declare function observeVisibilityChangeOnce(elementToBeObserved: HTMLElement, callback: () => void): void; /** * Add a `contenteditable` attribute, select the contents and optionally add the `invisibleSelection` * class to the provided element. * * @param {HTMLElement} element Element to be processed. * @param {boolean} [invisibleSelection=true] `true` if the class should be added to the element. * @param {boolean} [ariaHidden=true] `true` if the `aria-hidden` attribute should be added to the processed element. */ export declare function makeElementContentEditableAndSelectItsContent(element: HTMLElement, invisibleSelection?: boolean, ariaHidden?: boolean): void; /** * Remove the `contenteditable` attribute, deselect the contents and optionally remove the `invisibleSelection` * class from the provided element. * * @param {HTMLElement} selectedElement The element to be deselected. * @param {boolean} [removeInvisibleSelectionClass=true] `true` if the class should be removed from the element. */ export declare function removeContentEditableFromElementAndDeselect(selectedElement: HTMLElement, removeInvisibleSelectionClass?: boolean): void; /** * Run the provided callback while the provided element is selected and modified to have the `contenteditable` * attribute added. Optionally, the selection can be configured to be invisible. * * @param {HTMLElement} element Element to be selected. * @param {Function} callback Callback to be called. * @param {boolean} [invisibleSelection=true] `true` if the selection should be invisible. */ export declare function runWithSelectedContendEditableElement(element: HTMLElement, callback: () => void, invisibleSelection?: boolean): void; /** * Check if the element is HTMLElement. * * @param {*} element Element to check. * @returns {boolean} `true` if the element is HTMLElement. */ export declare function isHTMLElement(element: unknown): element is HTMLElement; /** * Check if the element is an HTMLTableCellElement (TD or TH). Cross-realm safe: uses the * element's own realm's constructor via `ownerDocument.defaultView`. * * @param {unknown} element Element to check. * @returns {boolean} `true` if the element is an HTMLTableCellElement. */ export declare function isHTMLTableCellElement(element: unknown): element is HTMLTableCellElement; /** * Check if the element is an HTMLInputElement. * * @param {HTMLElement} element Element to check. * @returns {boolean} `true` if the element is an HTMLInputElement. */ export declare function isHTMLInputElement(element: HTMLElement): element is HTMLInputElement; /** * Check if the node is a ShadowRoot (a document fragment attached to a host element). * * @param {Node} node Node to check. * @returns {boolean} `true` if the node is a ShadowRoot. */ export declare function isShadowRoot(node: Node): node is ShadowRoot; /** * Gets a child node at the specified index cast to the specified HTML element type. * * @param {ParentNode} parent The parent node. * @param {number} index The child index. * @returns {T|null} The child element or null. */ export declare function getChildEl(parent: ParentNode, index: number): T | null;