/** * D3 Selection Polyfill - A lightweight DOM selection and manipulation utility. * * This is a drop-in replacement for d3-selection, implementing only the methods * used in the Vega chart rendering system. * * Supported methods: select, selectAll, append, attr, property, text, datum, * call, node, nodes, each, remove, clone, transition, duration. * * @see VD-5022 - [Zero Dependencies] remove d3 dependency */ declare type SelectionCallback = (this: GElement, d?: Datum, i?: number, nodes?: GElement[]) => any; /** * A lightweight selection class mimicking d3-selection's chainable API. * Wraps an array of DOM elements and provides attribute/property/child manipulation. */ export declare class D3SelectionPolyfill { private _groups; private _datum; /** * @param {Element[]} elements - Array of DOM elements to wrap. * @param {*} [datum] - Optional bound datum for the selection. */ constructor(elements: GElement[], datum?: Datum); /** * Selects the first descendant element matching the selector. * * @template DescElement * @template Datum * @template GElement * @param {string} selector - CSS selector string. * @returns {D3SelectionPolyfill} A new selection wrapping the matched element. */ select(selector: string): D3SelectionPolyfill; /** * Selects all descendant elements matching the selector. * * @template DescElement * @template NewDatum * @template GElement * @template Datum * @param {string} selector - CSS selector string. * @returns {D3SelectionPolyfill} A new selection wrapping all matched elements. */ selectAll(selector: string): D3SelectionPolyfill; /** * Appends a new child element to each element in the selection. * Accepts either a tag name string or a factory function that returns a DOM element. * * @template ChildElement * @template Datum * @template GElement * @param {string | Function} tagOrFactory - Tag name (e.g. 'g', 'path') or a factory function. * @returns {D3SelectionPolyfill} A new selection wrapping the appended elements. */ append(tagOrFactory: string | (() => ChildElement)): D3SelectionPolyfill; /** * Sets or gets an attribute on each element. * If value is a function, it is called with the bound datum. * * @param {...*} args - Attribute name, and optionally a value or function returning a value. * @returns {any} This selection for chaining, or the attribute value if getting. */ attr(...args: any[]): any; /** * Sets a JavaScript property on each element. * * @param {string} name - Property name. * @param {unknown} value - Property value. * @returns {this} This selection for chaining. */ property(name: string, value: unknown): this; /** * Sets the text content of each element. * * @param {string} value - Text content string. * @returns {this} This selection for chaining. */ text(value: string): this; /** * Binds a datum to the selection. * * @template NewDatum * @template GElement * @template PElement * @template PDatum * @param {*} data - The datum to bind. * @returns {D3SelectionPolyfill} A new selection with the bound datum. */ datum(data: NewDatum): D3SelectionPolyfill; /** * Calls a function with this selection as argument. Used for grouping operations. * * @param {Function} fn - Function to call. * @param {...*} args - Additional arguments. * @returns {this} This selection for chaining. */ call(fn: (selection: this, ...args: any[]) => void, ...args: any[]): this; /** * Returns the first DOM node in the selection, or null. * * @template GElement * @returns {GElement | null} The first element or null. */ node(): GElement | null; /** * Returns all DOM nodes in the selection as an array. * * @template GElement * @returns {GElement[]} Array of elements. */ nodes(): GElement[]; /** * Iterates over each element, calling the provided function. * The function is called with `this` set to the current DOM element. * * @param {Function} fn - Callback function. * @returns {this} This selection for chaining. */ each(fn: SelectionCallback): this; /** * Removes all elements in the selection from the DOM. * * @returns {this} This selection for chaining. */ remove(): this; /** * Clones each element in the selection (shallow clone) and inserts after the original. * * @template GElement * @template Datum * @template PElement * @template PDatum * @returns {D3SelectionPolyfill} A new selection wrapping the cloned elements. */ clone(): D3SelectionPolyfill; /** * Creates a transition-like object. This is a simplified polyfill that * applies attribute changes immediately (no actual animation), which is * sufficient for Vega's usage of hover path swapping. * * @param {*} [_name] - Transition name (ignored in polyfill). * @returns {this} This selection for chaining (acts as a no-op). */ transition(_name?: unknown): this; /** * Sets the transition duration. No-op in this polyfill since * transitions are applied immediately. * * @param {number} _ms - Duration in milliseconds (ignored). * @returns {this} This selection for chaining. */ duration(_ms: number): this; } /** * Selects a DOM element by wrapping it in a D3SelectionPolyfill. * Mimics d3.select(). * * @template GElement * @param {Element | EventTarget} element - A DOM element or EventTarget to wrap. * @returns {D3SelectionPolyfill} A new D3SelectionPolyfill wrapping the element. */ export declare function select(element: GElement | EventTarget): D3SelectionPolyfill; /** * Creates a detached SVG element (e.g., 'svg:text', 'svg:circle', 'svg:path'). * Mimics d3.create(). * * @template GElement * @param {string} qualifiedName - A qualified name like 'svg:text' or 'svg:circle'. * @returns {D3SelectionPolyfill} A new D3SelectionPolyfill wrapping the created element. */ export declare function create(qualifiedName: string): D3SelectionPolyfill; export {};