/** * Set attributes on an element with performance optimizations * @param element * @param attributes */ declare const setAttributes: (element: E, attributes?: object) => E; /** * Remove attributes from an element * @param element * @param attributes */ declare const removeAttributes: (element: HTMLElement, attributes?: string[]) => HTMLElement; /** * Batch attribute operations for better performance when setting many attributes * @param element */ declare const batchAttributes: (element: HTMLElement, operations: Array<{ action: "set" | "remove"; key: string; value?: unknown; }>) => HTMLElement; /** * Check if element has attribute * @param element * @param attribute */ declare const hasAttribute: (element: HTMLElement, attribute: string) => boolean; /** * Get attribute value with default * @param element * @param attribute * @param defaultValue */ declare const getAttribute: (element: HTMLElement, attribute: string, defaultValue?: string) => string; /** * Normalize classes to array of unique strings with optimization and caching * @param classes */ declare const normalizeClasses: (...classes: (string | string[])[]) => string[]; /** * Add prefixed classes to element with optimizations * @param element * @param classes */ declare const addClass: (element: HTMLElement, ...classes: (string | string[])[]) => HTMLElement; /** * Remove prefixed classes from element with optimizations * @param element * @param classes */ declare const removeClass: (element: HTMLElement, ...classes: (string | string[])[]) => HTMLElement; /** * Toggle prefixed classes on element with optimizations * @param element * @param classes */ declare const toggleClass: (element: HTMLElement, ...classes: (string | string[])[]) => HTMLElement; /** * Check if element has all specified prefixed classes with optimizations * @param element * @param classes */ declare const hasClass: (element: HTMLElement, ...classes: (string | string[])[]) => boolean; /** Event manager interface for handling DOM events */ interface EventManager { /** * Add an event listener with options * @param event * @param handler * @param options */ on: (event: string, handler: (e: T) => void, options?: AddEventListenerOptions) => EventManager; /** * Remove an event listener * @param event * @param handler */ off: (event: string, handler: (e: T) => void) => EventManager; /** Temporarily disable all event listeners */ pause: () => EventManager; /** Re-enable all event listeners */ resume: () => EventManager; /** Remove all event listeners and clean up */ destroy: () => void; /** Get all active handlers */ getHandlers: () => Map; /** * Check if a specific handler exists * @param event * @param handler */ hasHandler: (event: string, handler: (e: T) => void) => boolean; } /** Handler information */ interface HandlerInfo { original: EventListener; enhanced: EventListener; event: string; options: AddEventListenerOptions; } /** * Creates an event manager to handle DOM events with enhanced functionality. * @param element */ declare const createEventManager: (element: HTMLElement) => EventManager; /** * The focused element as seen from a node's own root: the shadow root it lives in, or the document. * @param node */ declare const activeElementOf: (node: Node) => Element | null; /** The element that really has focus, looked for through open shadow roots: where focus goes back to after an overlay closes, when the overlay may sit in another root than whatever opened it. */ declare const deepActiveElement: () => Element | null; declare const tabStops: (container: Element) => HTMLElement[]; declare const wrapTab: (container: HTMLElement, event: KeyboardEvent) => void; /** A value the browser's Trusted Types API accepts for innerHTML. */ interface TrustedHTMLLike { toString(): string; } /** Markup a component accepts: a string, or a TrustedHTML from a policy. */ type HTMLInput = string | TrustedHTMLLike; interface HTMLPolicy { /** Called with every markup string before it is written. */ sanitize: (html: string) => HTMLInput; } /** Sets the policy every component's markup goes through, or clears it with null. */ declare const configureHTML: (next: HTMLPolicy | null) => void; /** The policy in force, if any. */ declare const getHTMLPolicy: () => HTMLPolicy | null; /** Writes markup into an element, through the policy when one is set. */ declare const setHTML: (element: Element, html: HTMLInput | null | undefined) => void; /** How an element is promoted to the browser's top layer: */ type TopLayerKind = "popover-auto" | "popover-manual" | "modal"; interface TopLayerOptions { kind: TopLayerKind; } type Layered = Omit & Partial>; /** * Whether the browser can show an element of this kind in the top layer: `showPopover` for the popovers, `HTMLDialogElement.prototype.showModal` for a modal. * @param kind */ declare const supportsTopLayer: (kind: TopLayerKind) => boolean; /** * Shows an element in the top layer, above everything else on the page whatever its z-index and whatever clips or transforms its ancestors. * @param element * @param options */ declare const showInTopLayer: (element: Layered, { kind }: TopLayerOptions) => boolean; /** * Takes an element out of the top layer. * @param element */ declare const hideFromTopLayer: (element: Layered) => void; /** * Reports the closes the browser makes on its own: a light dismiss or Escape for `popover="auto"` (a `toggle` event to `closed`), Escape or a form for a modal dialog (its `close` event, which follows an uncanceled `cancel`). * @param element * @param callback */ declare const onTopLayerClose: (element: HTMLElement, callback: () => void) => (() => void); /** A modal outside the top layer: makes everything but `keep` inert, as showModal() does for a top-layer dialog. */ declare const inertOutside: (keep: Element) => (() => void); interface EventsFrom { after: (event: Event) => boolean; stop: () => void; } declare const eventsFrom: (element: HTMLElement) => EventsFrom; interface ModalEscape { opening: boolean; stop: () => void; } declare const onModalEscape: (element: HTMLElement, escape: () => void, d?: (() => unknown) | false) => ModalEscape; /** Whether the arrow keys, Home and End belong to an element: a text input, a textarea or editable content, where they move the caret. */ declare const isTextEditable: (element: EventTarget | null | undefined) => boolean; interface RovingOptions { /** The composite: it receives the key and focus listeners. */ container: HTMLElement; /** The focus targets in order. */ targets: () => HTMLElement[]; /** Whether Up and Down move focus instead of Left and Right. */ vertical?: () => boolean; } interface Roving { /** Puts the one tab stop back on the current target, or the first enabled one. */ sync(): void; /** Removes the listeners and disabled-state observer. */ destroy(): void; } /** A roving tab index over a composite's focus targets (the WAI-ARIA toolbar pattern): one tab stop, kept on the target focused last; the arrow keys along the layout, Left and Right following the reading direction; Home and End to the ends. */ declare const createRoving: ({ container, targets, vertical }: RovingOptions) => Roving; export type { EventManager, HTMLInput, HTMLPolicy, Roving, RovingOptions, TopLayerKind, TopLayerOptions, TrustedHTMLLike }; export { activeElementOf, addClass, batchAttributes, configureHTML, createEventManager, createRoving, deepActiveElement, getAttribute, getHTMLPolicy, hasAttribute, hasClass, hideFromTopLayer, inertOutside, isTextEditable, normalizeClasses, onTopLayerClose, removeAttributes, removeClass, setAttributes, setHTML, showInTopLayer, supportsTopLayer, toggleClass }; export type { CreateElementOptions, ForwardedEventPayload } from "./create.js"; export { createElement, createSVGElement } from "./create.js";