import type { IDocument } from '@antv/g'; import type { AnimationResult } from '../animation'; import type { DisplayObject, IAnimation } from '../shapes'; import { Group } from '../shapes'; export type _Element = DisplayObject & { __data__?: any; __toData__?: any[]; __fromElements__?: DisplayObject[]; __facet__?: boolean; }; /** * A simple implementation of d3-selection for @antv/g. * It has the core features of d3-selection and extended ability. * Every methods of selection returns new selection if elements * are mutated(e.g. append, remove), otherwise return the selection itself(e.g. attr, style). * @see https://github.com/d3/d3-selection * @see https://github.com/antvis/g * @todo Nested selections. * @todo More useful functor. */ export declare class Selection { #private; static registry: Record _Element>; private _elements; private _parent; private _data; private _enter; private _exit; private _update; private _merge; private _split; private _document; private _transitions; private _facetElements; constructor(elements?: Iterable<_Element>, data?: T[] | [T, _Element[]][], parent?: _Element, document?: IDocument | null, selections?: [Selection, Selection, Selection, Selection, Selection], transitions?: Promise[], updateElements?: _Element[]); selectAll(selector: string | _Element[]): Selection; selectFacetAll(selector: string | _Element[]): Selection; /** * @todo Replace with querySelector which has bug now. */ select(selector: string | _Element): Selection; append(node: string | ((data: T, i: number) => _Element)): Selection; maybeAppend(id: string, node: string | (() => _Element)): Selection; maybeAppendByClassName(className: any, node: string | (() => _Element)): Selection; maybeAppendByName(name: string, node: string | (() => _Element)): Selection; /** * Bind data to elements, and produce three selection: * Enter: Selection with empty elements and data to be bind to elements. * Update: Selection with elements to be updated. * Exit: Selection with elements to be removed. */ data(data: T[], id?: (d: T, index?: number) => any, groupId?: (d: T, index?: number) => any): Selection; merge(other: Selection): Selection; createElement(type: string): _Element; /** * Apply callback for each selection(enter, update, exit) * and merge them into one selection. */ join(enter?: (selection: Selection) => any, update?: (selection: Selection) => any, exit?: (selection: Selection) => any, merge?: (selection: Selection) => any, split?: (selection: Selection) => any): Selection; remove(): Selection; each(callback: (datum: T, index: number) => any): Selection; attr(key: string, value: any): Selection; style(key: string, value: any, callbackable?: boolean): Selection; styles(style?: Record, callbackable?: boolean): Selection; update(option: any, callbackable?: boolean): Selection; /** if current stage is maybeAppend, skip update stage */ maybeUpdate(option: any, callbackable?: boolean): Selection; transition(callback?: (datum: T, index: number) => (null | IAnimation) | (null | IAnimation)[]): Selection; on(event: string, handler: any): this; call(callback: (selection: Selection, ...args: any[]) => any, ...args: any[]): Selection; node(): T; nodes(): _Element[]; transitions(): AnimationResult[]; parent(): DisplayObject; } export declare function select(node: DisplayObject): Selection; export declare function maybeAppend(parent: Group, selector: string, node: string | ((data: T, i: number) => _Element)): Selection;