1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | export type BaseType = Element | EnterElement | Document | Window | null;
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | export type KeyType = string | number;
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 | export interface ArrayLike<T> {
|
24 | length: number;
|
25 | item(index: number): T | null;
|
26 | [index: number]: T;
|
27 | }
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | export interface EnterElement {
|
34 | ownerDocument: Document;
|
35 | namespaceURI: string;
|
36 | appendChild(newChild: Node): Node;
|
37 | insertBefore(newChild: Node, refChild: Node): Node;
|
38 | querySelector(selectors: string): Element;
|
39 | querySelectorAll(selectors: string): NodeListOf<Element>;
|
40 | }
|
41 |
|
42 |
|
43 |
|
44 |
|
45 | export type ContainerElement = HTMLElement | SVGSVGElement | SVGGElement;
|
46 |
|
47 |
|
48 |
|
49 |
|
50 | export interface ClientPointEvent {
|
51 | clientX: number;
|
52 | clientY: number;
|
53 | }
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 | export interface CustomEventParameters {
|
60 | |
61 |
|
62 |
|
63 | bubbles: boolean;
|
64 | |
65 |
|
66 |
|
67 | cancelable: boolean;
|
68 | |
69 |
|
70 |
|
71 | detail: any;
|
72 | }
|
73 |
|
74 |
|
75 |
|
76 |
|
77 | export type ValueFn<T extends BaseType, Datum, Result> = (
|
78 | this: T,
|
79 | datum: Datum,
|
80 | index: number,
|
81 | groups: T[] | ArrayLike<T>,
|
82 | ) => Result;
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 | export interface TransitionLike<GElement extends BaseType, Datum> {
|
95 | selection(): Selection<GElement, Datum, any, any>;
|
96 | on(type: string, listener: null): TransitionLike<GElement, Datum>;
|
97 | on(type: string, listener: ValueFn<GElement, Datum, void>): TransitionLike<GElement, Datum>;
|
98 | tween(name: string, tweenFn: null): TransitionLike<GElement, Datum>;
|
99 | tween(name: string, tweenFn: ValueFn<GElement, Datum, ((t: number) => void)>): TransitionLike<GElement, Datum>;
|
100 | }
|
101 |
|
102 | // --------------------------------------------------------------------------
|
103 | // All Selection related interfaces and function
|
104 | // --------------------------------------------------------------------------
|
105 |
|
106 | /**
|
107 | * Select the first element that matches the specified selector string. If no elements match the selector, returns an empty selection.
|
108 | * If multiple elements match the selector, only the first matching element (in document order) will be selected.
|
109 | *
|
110 | * The first generic "GElement" refers to the type of element to be selected. The second generic "OldDatum" refers to the type of the
|
111 | * datum, on the selected element. This is useful when re-selecting an element with a previously set, know datum type.
|
112 | *
|
113 | * @param selector CSS selector string
|
114 | */
|
115 | // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
116 | export function select<GElement extends BaseType, OldDatum>(
|
117 | selector: string,
|
118 | ): Selection<GElement, OldDatum, HTMLElement, any>;
|
119 | /**
|
120 | * Select the specified node element.
|
121 | *
|
122 | * The first generic "GElement" refers to the type of element to be selected. The second generic "OldDatum" refers to the type of the
|
123 | * datum, on the selected element. This is useful when re-selecting an element with a previously set, know datum type.
|
124 | *
|
125 | * @param node An element to be selected
|
126 | */
|
127 | // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
128 | export function select<GElement extends BaseType, OldDatum>(
|
129 | node: GElement,
|
130 | ): Selection<GElement, OldDatum, null, undefined>;
|
131 |
|
132 | /**
|
133 | * Create an empty selection.
|
134 | */
|
135 | export function selectAll(selector?: null): Selection<null, undefined, null, undefined>;
|
136 | /**
|
137 | * Select all elements that match the specified selector string. The elements will be selected in document order (top-to-bottom).
|
138 | * If no elements in the document match the selector, returns an empty selection.
|
139 | *
|
140 | * The first generic "GElement" refers to the type of element to be selected. The second generic "OldDatum" refers to the type of the
|
141 | * datum, of a selected element. This is useful when re-selecting elements with a previously set, know datum type.
|
142 | *
|
143 | * @param selector CSS selector string
|
144 | */
|
145 | // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
146 | export function selectAll<GElement extends BaseType, OldDatum>(
|
147 | selector: string,
|
148 | ): Selection<GElement, OldDatum, HTMLElement, any>;
|
149 | /**
|
150 | * Select the specified array, array-like, or iterable of nodes.
|
151 | * This is useful if you already have a reference to nodes, such as `this.childNodes` within an event listener or a global such as `document.links`.
|
152 | * The nodes may instead be an iterable, or a pseudo-array such as a NodeList.
|
153 | *
|
154 | * The first generic "GElement" refers to the type of element to be selected.
|
155 | * The second generic "OldDatum" refers to the type of the datum, of a selected element.
|
156 | *
|
157 | * @param nodes An array, array-like, or iterable of nodes
|
158 | */
|
159 | // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
160 | export function selectAll<GElement extends BaseType, OldDatum>(
|
161 | nodes: GElement[] | ArrayLike<GElement> | Iterable<GElement>,
|
162 | ): Selection<GElement, OldDatum, null, undefined>;
|
163 |
|
164 | /**
|
165 | * A D3 Selection of elements.
|
166 | *
|
167 | * The first generic "GElement" refers to the type of the selected element(s).
|
168 | * The second generic "Datum" refers to the type of the datum of a selected element(s).
|
169 | * The third generic "PElement" refers to the type of the parent element(s) in the D3 selection.
|
170 | * The fourth generic "PDatum" refers to the type of the datum of the parent element(s).
|
171 | */
|
172 | export interface Selection<GElement extends BaseType, Datum, PElement extends BaseType, PDatum> {
|
173 | // Sub-selection -------------------------
|
174 |
|
175 | /**
|
176 | * For each selected element, select the first descendant element that matches the specified selector string.
|
177 | * If no element matches the specified selector for the current element, the element at the current index will
|
178 | * be null in the returned selection. If multiple elements match the selector, only the first matching element
|
179 | * in document order is selected. Selection.select does not affect grouping: it preserves the existing group
|
180 | * structure and indexes, and propagates data (if any) to selected children.
|
181 | *
|
182 | * If the current element has associated data, this data is propagated to the
|
183 | * corresponding selected element.
|
184 | *
|
185 | * The generic represents the type of the descendant element to be selected.
|
186 | *
|
187 | * @param selector CSS selector string
|
188 | */
|
189 | // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
190 | select<DescElement extends BaseType>(selector: string): Selection<DescElement, Datum, PElement, PDatum>;
|
191 | /**
|
192 | * Create an empty sub-selection. Selection.select does not affect grouping: it preserves the existing group
|
193 | * structure and indexes.
|
194 | */
|
195 | // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
196 | select<DescElement extends BaseType>(selector: null): Selection<null, undefined, PElement, PDatum>;
|
197 | /**
|
198 | * For each selected element, select the descendant element returned by the selector function.
|
199 | * If no element is returned by the selector function for the current element, the element at the
|
200 | * current index will be null in the returned selection. Selection.select does not affect grouping:
|
201 | * it preserves the existing group structure and indexes, and propagates data (if any) to selected children.
|
202 | *
|
203 | * If the current element has associated data, this data is propagated to the
|
204 | * corresponding selected element.
|
205 | *
|
206 | * The generic represents the type of the descendant element to be selected.
|
207 | *
|
208 | * @param selector A selector function, which is evaluated for each selected element, in order, being passed the current datum (d),
|
209 | * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]).
|
210 | * It must return an element, or null if there is no matching element.
|
211 | */
|
212 | select<DescElement extends BaseType>(
|
213 | selector: ValueFn<GElement, Datum, DescElement>,
|
214 | ): Selection<DescElement, Datum, PElement, PDatum>;
|
215 |
|
216 | /**
|
217 | * Create an empty sub-selection. Selection.selectAll does affect grouping: The elements in the returned
|
218 | * selection are grouped by their corresponding parent node in this selection, the group at the current index will be empty.
|
219 | */
|
220 | selectAll(selector?: null): Selection<null, undefined, GElement, Datum>;
|
221 | /**
|
222 | * For each selected element, selects the descendant elements that match the specified selector string. The elements in the returned
|
223 | * selection are grouped by their corresponding parent node in this selection. If no element matches the specified selector
|
224 | * for the current element, the group at the current index will be empty. Selection.selectAll does affect grouping: each selected descendant
|
225 | * is grouped by the parent element in the originating selection.
|
226 | *
|
227 | * The selected elements do not inherit data from this selection; use selection.data to propagate data to children.
|
228 | *
|
229 | * The first generic "DescElement" refers to the type of descendant element to be selected. The second generic "OldDatum" refers to the type of the
|
230 | * datum, of a selected element. This is useful when re-selecting elements with a previously set, know datum type.
|
231 | *
|
232 | * @param selector CSS selector string
|
233 | */
|
234 | // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
235 | selectAll<DescElement extends BaseType, OldDatum>(
|
236 | selector: string,
|
237 | ): Selection<DescElement, OldDatum, GElement, Datum>;
|
238 | /**
|
239 | * For each selected element, selects the descendant elements returned by the selector function. The elements in the returned
|
240 | * selection are grouped by their corresponding parent node in this selection. If no element matches the specified selector
|
241 | * for the current element, the group at the current index will be empty. Selection.selectAll does affect grouping: each selected descendant
|
242 | * is grouped by the parent element in the originating selection.
|
243 | *
|
244 | * The selected elements do not inherit data from this selection; use selection.data to propagate data to children.
|
245 | *
|
246 | * The first generic "DescElement" refers to the type of descendant element to be selected. The second generic "OldDatum" refers to the type of the
|
247 | * datum, of a selected element. This is useful when re-selecting elements with a previously set, know datum type.
|
248 | *
|
249 | * @param selector A selector function which is evaluated for each selected element, in order, being passed the current datum (d),
|
250 | * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). It must return an array of elements
|
251 | * (or an iterable, or a pseudo-array, such as a NodeList), or the empty array if there are no matching elements.
|
252 | */
|
253 | // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
254 | selectAll<DescElement extends BaseType, OldDatum>(
|
255 | selector: ValueFn<GElement, Datum, DescElement[] | ArrayLike<DescElement> | Iterable<DescElement>>,
|
256 | ): Selection<DescElement, OldDatum, GElement, Datum>;
|
257 |
|
258 | /**
|
259 | * Filters the selection, returning a new selection that contains only the elements for
|
260 | * which the specified filter is true.
|
261 | *
|
262 | * The returned filtered selection preserves the parents of this selection, but like array.filter,
|
263 | * it does not preserve indexes as some elements may be removed; use selection.select to preserve the index, if needed.
|
264 | *
|
265 | * @param selector A CSS selector string to match when filtering.
|
266 | */
|
267 | filter(selector: string): Selection<GElement, Datum, PElement, PDatum>;
|
268 | /**
|
269 | * Filters the selection, returning a new selection that contains only the elements for
|
270 | * which the specified filter is true.
|
271 | *
|
272 | * The returned filtered selection preserves the parents of this selection, but like array.filter,
|
273 | * it does not preserve indexes as some elements may be removed; use selection.select to preserve the index, if needed.
|
274 | *
|
275 | * The generic refers to the type of element which will be selected after applying the filter, i.e. if the element types
|
276 | * contained in a pre-filter selection are narrowed to a subset as part of the filtering.
|
277 | *
|
278 | * @param selector A CSS selector string to match when filtering.
|
279 | */
|
280 | // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
281 | filter<FilteredElement extends BaseType>(selector: string): Selection<FilteredElement, Datum, PElement, PDatum>;
|
282 | /**
|
283 | * Filter the selection, returning a new selection that contains only the elements for
|
284 | * which the specified filter is true.
|
285 | *
|
286 | * The returned filtered selection preserves the parents of this selection, but like array.filter,
|
287 | * it does not preserve indexes as some elements may be removed; use selection.select to preserve the index, if needed.
|
288 | *
|
289 | * @param selector A value function which is evaluated for each selected element, in order, being passed the current datum (d),
|
290 | * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). This function should return true
|
291 | * for an element to be included, and false otherwise.
|
292 | */
|
293 | filter(selector: ValueFn<GElement, Datum, boolean>): Selection<GElement, Datum, PElement, PDatum>;
|
294 | /**
|
295 | * Filter the selection, returning a new selection that contains only the elements for
|
296 | * which the specified filter is true.
|
297 | *
|
298 | * The returned filtered selection preserves the parents of this selection, but like array.filter,
|
299 | * it does not preserve indexes as some elements may be removed; use selection.select to preserve the index, if needed.
|
300 | *
|
301 | * @param selector A value function which is evaluated for each selected element, in order, being passed the current datum (d),
|
302 | * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). This function should return true
|
303 | * for an element to be included, and false otherwise.
|
304 | */
|
305 | // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
306 | filter<FilteredElement extends BaseType>(
|
307 | selector: ValueFn<GElement, Datum, boolean>,
|
308 | ): Selection<FilteredElement, Datum, PElement, PDatum>;
|
309 |
|
310 | /**
|
311 | * Returns a new selection merging this selection with the specified other selection or transition.
|
312 | * The returned selection has the same number of groups and the same parents as this selection.
|
313 | * Any missing (null) elements in this selection are filled with the corresponding element,
|
314 | * if present (not null), from the specified selection. (If the other selection has additional groups or parents,
|
315 | * they are ignored.)
|
316 | *
|
317 | * This method is commonly used to merge the enter and update selections after a data-join.
|
318 | * After modifying the entering and updating elements separately, you can merge the two selections and
|
319 | * perform operations on both without duplicate code.
|
320 | *
|
321 | * This method is not intended for concatenating arbitrary selections, however: if both this selection
|
322 | * and the specified other selection have (non-null) elements at the same index, this selection’s element
|
323 | * is returned in the merge and the other selection’s element is ignored.
|
324 | *
|
325 | * @param other Selection to be merged.
|
326 | */
|
327 | merge(
|
328 | other: Selection<GElement, Datum, PElement, PDatum> | TransitionLike<GElement, Datum>,
|
329 | ): Selection<GElement, Datum, PElement, PDatum>;
|
330 |
|
331 | /**
|
332 | * Returns a new selection with the (first) child of each element of the current selection matching the selector.
|
333 | * Selects the first child that matches (if any).
|
334 | *
|
335 | * The generic represents the type of the descendant element to be selected.
|
336 | *
|
337 | * @param selector CSS selector string
|
338 | */
|
339 | // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
340 | selectChild<DescElement extends BaseType>(selector?: string): Selection<DescElement, Datum, PElement, PDatum>;
|
341 | /**
|
342 | * Returns a new selection with the (first) child of each element of the current selection matching the selector.
|
343 | *
|
344 | * The first generic represents the type of the descendant element to be selected.
|
345 | * The second generic represents the type of any of the child elements.
|
346 | *
|
347 | * @param selector A selector function, which is evaluated for each of the children nodes, in order, being passed the child (child), the child’s index (i), and the list of children (children);
|
348 | * the method selects the first child for which the selector return truthy, if any.
|
349 | */
|
350 | // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
351 | selectChild<ResultElement extends BaseType, ChildElement extends BaseType>(
|
352 | selector: (child: ChildElement, i: number, children: ChildElement[]) => boolean,
|
353 | ): Selection<ResultElement, Datum, PElement, PDatum>;
|
354 |
|
355 | /**
|
356 | * Returns a new selection with the children of each element of the current selection matching the selector.
|
357 | * Selects the children that match (if any)
|
358 | *
|
359 | * The first generic represents the type of the descendant element to be selected.
|
360 | * The second generic refers to the type of the datum of the element to be selected.
|
361 | *
|
362 | * @param selector CSS selector string
|
363 | */
|
364 | // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
365 | selectChildren<DescElement extends BaseType, OldDatum>(
|
366 | selector?: string,
|
367 | ): Selection<DescElement, OldDatum, GElement, Datum>;
|
368 | /**
|
369 | * Returns a new selection with the children of each element of the current selection matching the selector.
|
370 | *
|
371 | * The first generic represents the type of the descendant element to be selected.
|
372 | * The second generic refers to the type of the datum of the element to be selected.
|
373 | * The third generic represents the type of any of the child elements.
|
374 | *
|
375 | * @param selector A selector function, which is evaluated for each of the children nodes, in order, being passed the child (child), the child’s index (i), and the list of children (children);
|
376 | * the method selects the first child for which the selector return truthy, if any.
|
377 | */
|
378 | // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
379 | selectChildren<ResultElement extends BaseType, ResultDatum, ChildElement extends BaseType>(
|
380 | selector: (child: ChildElement, i: number, children: ChildElement[]) => boolean,
|
381 | ): Selection<ResultElement, ResultDatum, GElement, Datum>;
|
382 |
|
383 | /**
|
384 | * Returns the selection (for symmetry with transition.selection).
|
385 | */
|
386 | selection(): this;
|
387 |
|
388 | // Modifying -------------------------------
|
389 |
|
390 | /**
|
391 | * Return the current value of the specified attribute for the first (non-null) element in the selection.
|
392 | * This is generally useful only if you know that the selection contains exactly one element.
|
393 | *
|
394 | * @param name Name of the attribute
|
395 | */
|
396 | attr(name: string): string;
|
397 | /**
|
398 | * Sets the attribute with the specified name to the specified value on the selected elements and returns this selection.
|
399 | * If the value is a constant, all elements are given the same attribute value;
|
400 | * otherwise, if the value is a function, it is evaluated for each selected element, in order, being passed the current datum (d),
|
401 | * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]).
|
402 | * The function’s return value is then used to set each element’s attribute.
|
403 | * A null value will remove the specified attribute.
|
404 | */
|
405 | attr(
|
406 | name: string,
|
407 | value:
|
408 | | null
|
409 | | string
|
410 | | number
|
411 | | boolean
|
412 | | ReadonlyArray<string | number>
|
413 | | ValueFn<GElement, Datum, null | string | number | boolean | ReadonlyArray<string | number>>,
|
414 | ): this;
|
415 |
|
416 | /**
|
417 | * Returns true if and only if the first (non-null) selected element has the specified classes.
|
418 | * This is generally useful only if you know the selection contains exactly one element.
|
419 | *
|
420 | * @param names A string of space-separated class names.
|
421 | */
|
422 | classed(names: string): boolean;
|
423 | /**
|
424 | * Assigns or unassigns the specified CSS class names on the selected elements by setting
|
425 | * the class attribute or modifying the classList property and returns this selection.
|
426 | * If the constant value is truthy, then all elements are assigned the specified classes; otherwise, the classes are unassigned.
|
427 | *
|
428 | * @param names A string of space-separated class names.
|
429 | * @param value A boolean flag (true = assign / false = unassign)
|
430 | */
|
431 | classed(names: string, value: boolean): this;
|
432 | /**
|
433 | * Assigns or unassigns the specified CSS class names on the selected elements by setting
|
434 | * the class attribute or modifying the classList property and returns this selection.
|
435 | * The assign/unassign status for the individual selected elements is determined by the boolean return
|
436 | * value of the value function.
|
437 | *
|
438 | * @param names A string of space-separated class names.
|
439 | * @param value A value function which is evaluated for each selected element, in order,
|
440 | * being passed the current datum (d), the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]).
|
441 | * The function’s return value is then used to assign or unassign classes on each element.
|
442 | */
|
443 | classed(names: string, value: ValueFn<GElement, Datum, boolean>): this;
|
444 |
|
445 | /**
|
446 | * Returns the current value of the specified style property for the first (non-null) element in the selection.
|
447 | * The current value is defined as the element’s inline value, if present, and otherwise its computed value.
|
448 | * Accessing the current style value is generally useful only if you know the selection contains exactly one element.
|
449 | *
|
450 | * @param name Name of the style
|
451 | */
|
452 | style(name: string): string;
|
453 | /**
|
454 | * Clear the style with the specified name for the selected elements and returns this selection.
|
455 | *
|
456 | * @param name Name of the style
|
457 | * @param value null,to clear the style
|
458 | */
|
459 | style(name: string, value: null): this;
|
460 | /**
|
461 | * Sets the value of the style with the specified name for the selected elements and returns this selection.
|
462 | * All elements are given the same style value.
|
463 | *
|
464 | * @param name Name of the style
|
465 | * @param value Constant value for the style
|
466 | * @param priority An optional priority flag, either null or the string important (without the exclamation point)
|
467 | */
|
468 | style(name: string, value: string | number | boolean, priority?: null | "important"): this;
|
469 | /**
|
470 | * Sets the value of the style with the specified name for the selected elements and returns this selection.
|
471 | * The value for the individual selected elements is determined by the value function.
|
472 | *
|
473 | * @param name Name of the style
|
474 | * @param value A value function which is evaluated for each selected element, in order, being passed the current datum (d),
|
475 | * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). A null value will clear the style.
|
476 | * @param priority An optional priority flag, either null or the string important (without the exclamation point)
|
477 | */
|
478 | style(
|
479 | name: string,
|
480 | value: ValueFn<GElement, Datum, string | number | boolean | null>,
|
481 | priority?: null | "important",
|
482 | ): this;
|
483 |
|
484 | /**
|
485 | * Return the current value of the specified property for the first (non-null) element in the selection.
|
486 | * This is generally useful only if you know that the selection contains exactly one element.
|
487 | *
|
488 | * @param name Name of the property
|
489 | */
|
490 | property(name: string): any;
|
491 | /**
|
492 | * Look up a local variable on the first node of this selection. Note that this is not equivalent to `local.get(selection.node())` in that it will not look up locals set on the parent node(s).
|
493 | *
|
494 | * @param name The `d3.local` variable to look up.
|
495 | */
|
496 | property<T>(name: Local<T>): T | undefined;
|
497 | /**
|
498 | * Sets the property with the specified name to the specified value on selected elements.
|
499 | * If the value is a constant, then all elements are given the same property value;
|
500 | * otherwise, if the value is a function, it is evaluated for each selected element, in order, being passed the current datum (d),
|
501 | * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]).
|
502 | * The function’s return value is then used to set each element’s property. A null value will delete the specified property.
|
503 | */
|
504 | property(name: string, value: ValueFn<GElement, Datum, any> | null): this;
|
505 | /**
|
506 | * Sets the value of the property with the specified name for the selected elements and returns this selection.
|
507 | * All elements are given the same property value.
|
508 | *
|
509 | * @param name Name of the property
|
510 | * @param value Constant value for the property
|
511 | */
|
512 | property(name: string, value: any): this;
|
513 | /**
|
514 | * Store a value in a `d3.local` variable.
|
515 | * This is equivalent to `selection.each(function (d, i, g) { name.set(this, value.call(this, d, i, g)); })` but more concise.
|
516 | *
|
517 | * @param name A `d3.local` variable
|
518 | * @param value A callback that returns the value to store
|
519 | */
|
520 | property<T>(name: Local<T>, value: ValueFn<GElement, Datum, T>): this;
|
521 | /**
|
522 | * Store a value in a `d3.local` variable for each node in the selection.
|
523 | * This is equivalent to `selection.each(function () { name.set(this, value); })` but more concise.
|
524 | *
|
525 | * @param name A `d3.local` variable
|
526 | * @param value A callback that returns the value to store
|
527 | */
|
528 | property<T>(name: Local<T>, value: T): this;
|
529 |
|
530 | /**
|
531 | * Returns the text content for the first (non-null) element in the selection.
|
532 | * This is generally useful only if you know the selection contains exactly one element.
|
533 | */
|
534 | text(): string;
|
535 | /**
|
536 | * Sets the text content to the specified value on all selected elements, replacing any existing child elements.
|
537 | * If the value is a constant, then all elements are given the same text content;
|
538 | * otherwise, if the value is a function, it is evaluated for each selected element, in order, being passed the current datum (d),
|
539 | * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]).
|
540 | * The function’s return value is then used to set each element’s text content.
|
541 | * A null value will clear the content.
|
542 | */
|
543 | text(value: null | string | number | boolean | ValueFn<GElement, Datum, string | number | boolean | null>): this;
|
544 |
|
545 | /**
|
546 | * Returns a string representation of the inner HTML for the first (non-null) element in the selection.
|
547 | * This is generally useful only if you know the selection contains exactly one element.
|
548 | */
|
549 | html(): string;
|
550 | /**
|
551 | * Sets the inner HTML to the specified value on all selected elements, replacing any existing child elements.
|
552 | * If the value is a constant, then all elements are given the same inner HTML;
|
553 | * otherwise, if the value is a function, it is evaluated for each selected element, in order, being passed the current datum (d),
|
554 | * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]).
|
555 | * The function’s return value is then used to set each element’s inner HTML.
|
556 | * A null value will clear the content.
|
557 | */
|
558 | html(value: null | string | ValueFn<GElement, Datum, string | null>): this;
|
559 |
|
560 | /**
|
561 | * Appends a new element of this type (tag name) as the last child of each selected element,
|
562 | * or before the next following sibling in the update selection if this is an enter selection.
|
563 | * The latter behavior for enter selections allows you to insert elements into the DOM in an order consistent with the new bound data;
|
564 | * however, note that selection.order may still be required if updating elements change order
|
565 | * (i.e., if the order of new data is inconsistent with old data).
|
566 | *
|
567 | * This method returns a new selection containing the appended elements.
|
568 | * Each new element inherits the data of the current elements, if any.
|
569 | *
|
570 | * @param type A string representing the tag name.
|
571 | */
|
572 | append<K extends keyof ElementTagNameMap>(type: K): Selection<ElementTagNameMap[K], Datum, PElement, PDatum>;
|
573 | /**
|
574 | * Appends a new element of this type (tag name) as the last child of each selected element,
|
575 | * or before the next following sibling in the update selection if this is an enter selection.
|
576 | * The latter behavior for enter selections allows you to insert elements into the DOM in an order consistent with the new bound data;
|
577 | * however, note that selection.order may still be required if updating elements change order
|
578 | * (i.e., if the order of new data is inconsistent with old data).
|
579 | *
|
580 | * This method returns a new selection containing the appended elements.
|
581 | * Each new element inherits the data of the current elements, if any.
|
582 | *
|
583 | * The generic refers to the type of the child element to be appended.
|
584 | *
|
585 | * @param type A string representing the tag name. The specified name may have a namespace prefix, such as svg:text
|
586 | * to specify a text attribute in the SVG namespace. If no namespace is specified, the namespace will be inherited
|
587 | * from the parent element; or, if the name is one of the known prefixes, the corresponding namespace will be used
|
588 | * (for example, svg implies svg:svg)
|
589 | */
|
590 | // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
591 | append<ChildElement extends BaseType>(type: string): Selection<ChildElement, Datum, PElement, PDatum>;
|
592 | /**
|
593 | * Appends a new element of the type provided by the element creator function as the last child of each selected element,
|
594 | * or before the next following sibling in the update selection if this is an enter selection.
|
595 | * The latter behavior for enter selections allows you to insert elements into the DOM in an order consistent with the new bound data;
|
596 | * however, note that selection.order may still be required if updating elements change order
|
597 | * (i.e., if the order of new data is inconsistent with old data).
|
598 | *
|
599 | * This method returns a new selection containing the appended elements.
|
600 | * Each new element inherits the data of the current elements, if any.
|
601 | *
|
602 | * The generic refers to the type of the child element to be appended.
|
603 | *
|
604 | * @param type A creator function which is evaluated for each selected element, in order, being passed the current datum (d),
|
605 | * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). This function should return
|
606 | * an element to be appended. (The function typically creates a new element, but it may instead return an existing element.)
|
607 | */
|
608 | append<ChildElement extends BaseType>(
|
609 | type: ValueFn<GElement, Datum, ChildElement>,
|
610 | ): Selection<ChildElement, Datum, PElement, PDatum>;
|
611 |
|
612 | /**
|
613 | * Inserts a new element of the specified type (tag name) before the first element matching the specified
|
614 | * before selector for each selected element. For example, a before selector :first-child will prepend nodes before the first child.
|
615 | * If before is not specified, it defaults to null. (To append elements in an order consistent with bound data, use selection.append.)
|
616 | *
|
617 | * This method returns a new selection containing the appended elements.
|
618 | * Each new element inherits the data of the current elements, if any.
|
619 | *
|
620 | * The generic refers to the type of the child element to be appended.
|
621 | *
|
622 | * @param type A string representing the tag name for the element type to be inserted.
|
623 | * @param before One of:
|
624 | * * A CSS selector string for the element before which the insertion should occur.
|
625 | * * A child selector function which is evaluated for each selected element, in order, being passed the current datum (d),
|
626 | * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). This function should return the child element
|
627 | * before which the element should be inserted.
|
628 | */
|
629 | insert<K extends keyof ElementTagNameMap>(
|
630 | type: K,
|
631 | before?: string | ValueFn<GElement, Datum, BaseType>,
|
632 | ): Selection<ElementTagNameMap[K], Datum, PElement, PDatum>;
|
633 | /**
|
634 | * Inserts a new element of the specified type (tag name) before the first element matching the specified
|
635 | * before selector for each selected element. For example, a before selector :first-child will prepend nodes before the first child.
|
636 | * If before is not specified, it defaults to null. (To append elements in an order consistent with bound data, use selection.append.)
|
637 | *
|
638 | * This method returns a new selection containing the appended elements.
|
639 | * Each new element inherits the data of the current elements, if any.
|
640 | *
|
641 | * The generic refers to the type of the child element to be appended.
|
642 | *
|
643 | * @param type One of:
|
644 | * * A string representing the tag name for the element type to be inserted. The specified name may have a namespace prefix,
|
645 | * such as svg:text to specify a text attribute in the SVG namespace. If no namespace is specified, the namespace will be inherited
|
646 | * from the parent element; or, if the name is one of the known prefixes, the corresponding namespace will be used
|
647 | * (for example, svg implies svg:svg)
|
648 | * * A creator function which is evaluated for each selected element, in order, being passed the current datum (d),
|
649 | * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). This function should return
|
650 | * an element to be inserted. (The function typically creates a new element, but it may instead return an existing element.)
|
651 | * @param before One of:
|
652 | * * A CSS selector string for the element before which the insertion should occur.
|
653 | * * A child selector function which is evaluated for each selected element, in order, being passed the current datum (d),
|
654 | * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]). This function should return the child element
|
655 | * before which the element should be inserted.
|
656 | */
|
657 | insert<ChildElement extends BaseType>(
|
658 | type: string | ValueFn<GElement, Datum, ChildElement>,
|
659 | before?: string | ValueFn<GElement, Datum, BaseType>,
|
660 | ): Selection<ChildElement, Datum, PElement, PDatum>;
|
661 |
|
662 | /**
|
663 | * Removes the selected elements from the document.
|
664 | * Returns this selection (the removed elements) which are now detached from the DOM.
|
665 | */
|
666 | remove(): this;
|
667 |
|
668 | /**
|
669 | * Inserts clones of the selected elements immediately following the selected elements and returns a selection of the newly
|
670 | * added clones. If deep is true, the descendant nodes of the selected elements will be cloned as well. Otherwise, only the elements
|
671 | * themselves will be cloned.
|
672 | *
|
673 | * @param deep Perform deep cloning if this flag is set to true.
|
674 | */
|
675 | clone(deep?: boolean): Selection<GElement, Datum, PElement, PDatum>;
|
676 |
|
677 | /**
|
678 | * Return a new selection that contains a copy of each group in this selection sorted according
|
679 | * to the compare function. After sorting, re-inserts elements to match the resulting order (per selection.order).
|
680 | *
|
681 | * Note that sorting is not guaranteed to be stable; however, it is guaranteed to have the same
|
682 | * behavior as your browser’s built-in sort method on arrays.
|
683 | *
|
684 | * @param comparator An optional comparator function, which defaults to "ascending". The function is passed
|
685 | * two elements’ data a and b to compare. It should return either a negative, positive, or zero value.
|
686 | * If negative, then a should be before b; if positive, then a should be after b; otherwise, a and b are
|
687 | * considered equal and the order is arbitrary.
|
688 | */
|
689 | sort(comparator?: (a: Datum, b: Datum) => number): this;
|
690 |
|
691 | /**
|
692 | * Re-insert elements into the document such that the document order of each group matches the selection order.
|
693 | * This is equivalent to calling selection.sort if the data is already sorted, but much faster.
|
694 | */
|
695 | order(): this;
|
696 |
|
697 | /**
|
698 | * Re-insert each selected element, in order, as the last child of its parent.
|
699 | */
|
700 | raise(): this;
|
701 |
|
702 | /**
|
703 | * Re-insert each selected element, in order, as the first child of its parent.
|
704 | */
|
705 | lower(): this;
|
706 |
|
707 | // Data Join ---------------------------------
|
708 |
|
709 | /**
|
710 | * Returns the array of data for the selected elements.
|
711 | */
|
712 | data(): Datum[];
|
713 | /**
|
714 | * Joins the specified array of data with the selected elements, returning a new selection that represents
|
715 | * the update selection: the elements successfully bound to data. Also defines the enter and exit selections on
|
716 | * the returned selection, which can be used to add or remove elements to correspond to the new data.
|
717 | *
|
718 | * The data is specified for each group in the selection. If the selection has multiple groups
|
719 | * (such as d3.selectAll followed by selection.selectAll), then data should typically be specified as a function.
|
720 | *
|
721 | * If a key function is not specified, then the first datum in data is assigned to the first selected element,
|
722 | * the second datum to the second selected element, and so on.
|
723 | * A key function may be specified to control which datum is assigned to which element, replacing the default join-by-index,
|
724 | * by computing a string identifier for each datum and element.
|
725 | *
|
726 | * The update and enter selections are returned in data order, while the exit selection preserves the selection
|
727 | * order prior to the join. If a key function is specified, the order of elements in the selection may not match
|
728 | * their order in the document; use selection.order or selection.sort as needed.
|
729 | *
|
730 | * This method cannot be used to clear bound data; use selection.datum instead.
|
731 | *
|
732 | * For details see: {@link https://github.com/d3/d3-selection#joining-data }
|
733 | *
|
734 | * The generic refers to the type of the new datum to be used for the selected elements.
|
735 | *
|
736 | * @param data The specified data is an array or iterable of arbitrary values (e.g., numbers or objects)
|
737 | * or a value function which will be evaluated for each group in order, being passed the group’s parent datum
|
738 | * (d, which may be undefined), the group index (i), and the selection’s parent nodes (nodes),
|
739 | * with this as the group’s parent element. The function returns an array or iterable of values for each group.
|
740 | * @param key An optional key function which is evaluated for each selected element, in order, being passed the
|
741 | * current datum (d), the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]); the returned string is the element’s key.
|
742 | * The key function is then also evaluated for each new datum in data, being passed the current datum (d),
|
743 | * the current index (i), and the group’s new data, with this as the group’s parent DOM element (nodes[i]); the returned string is the datum’s key.
|
744 | * The datum for a given key is assigned to the element with the matching key. If multiple elements have the same key,
|
745 | * the duplicate elements are put into the exit selection; if multiple data have the same key, the duplicate data are put into the enter selection.
|
746 | */
|
747 | data<NewDatum>(
|
748 | data: NewDatum[] | Iterable<NewDatum> | ValueFn<PElement, PDatum, NewDatum[] | Iterable<NewDatum>>,
|
749 | key?: ValueFn<GElement | PElement, Datum | NewDatum, KeyType>,
|
750 | ): Selection<GElement, NewDatum, PElement, PDatum>;
|
751 |
|
752 | /**
|
753 | * Appends, removes and reorders elements as necessary to match the data that was previously bound by `selection.data`, returning the merged enter and update selection.
|
754 | * This method is a convenient alternative to the more explicit `selection.enter`, `selection.exit`, `selection.append` and `selection.remove`.
|
755 | *
|
756 | * The "matching" logic is determined by the key function passed to `selection.data`.
|
757 | */
|
758 | // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
759 | join<K extends keyof ElementTagNameMap, OldDatum = Datum>(
|
760 | enter: K,
|
761 | update?: (
|
762 | elem: Selection<GElement, Datum, PElement, PDatum>,
|
763 | ) => Selection<GElement, Datum, PElement, PDatum> | TransitionLike<GElement, Datum> | undefined,
|
764 | exit?: (elem: Selection<GElement, OldDatum, PElement, PDatum>) => void,
|
765 | ): Selection<GElement | ElementTagNameMap[K], Datum, PElement, PDatum>;
|
766 | /**
|
767 | * Appends, removes and reorders elements as necessary to match the data that was previously bound by `selection.data`, returning the merged enter and update selection.
|
768 | * This method is a convenient alternative to the more explicit `selection.enter`, `selection.exit`, `selection.append` and `selection.remove`.
|
769 | *
|
770 | * The "matching" logic is determined by the key function passed to `selection.data`.
|
771 | */
|
772 | // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
773 | join<ChildElement extends BaseType, OldDatum = Datum>(
|
774 | enter:
|
775 | | string
|
776 | | ((
|
777 | elem: Selection<EnterElement, Datum, PElement, PDatum>,
|
778 | ) => Selection<ChildElement, Datum, PElement, PDatum> | TransitionLike<GElement, Datum>),
|
779 | update?: (
|
780 | elem: Selection<GElement, Datum, PElement, PDatum>,
|
781 | ) => Selection<GElement, Datum, PElement, PDatum> | TransitionLike<GElement, Datum> | undefined,
|
782 | exit?: (elem: Selection<GElement, OldDatum, PElement, PDatum>) => void,
|
783 | ): Selection<ChildElement | GElement, Datum, PElement, PDatum>;
|
784 |
|
785 | /**
|
786 | * Return the enter selection: placeholder nodes for each datum that had no corresponding DOM element
|
787 | * in the selection. (The enter selection is empty for selections not returned by selection.data.)
|
788 | */
|
789 | enter(): Selection<EnterElement, Datum, PElement, PDatum>;
|
790 |
|
791 | /**
|
792 | * Returns the exit selection: existing DOM elements in the selection for which no new datum was found.
|
793 | * (The exit selection is empty for selections not returned by selection.data.)
|
794 | *
|
795 | * IMPORTANT: The generic refers to the type of the old datum associated with the exit selection elements.
|
796 | * Ensure you set the generic to the correct type, if you need to access the data on the exit selection in
|
797 | * follow-up steps, e.g. to set styles as part of an exit transition before removing them.
|
798 | */
|
799 | // eslint-disable-next-line @definitelytyped/no-unnecessary-generics
|
800 | exit<OldDatum>(): Selection<GElement, OldDatum, PElement, PDatum>;
|
801 |
|
802 | /**
|
803 | * Returns the bound datum for the first (non-null) element in the selection.
|
804 | * This is generally useful only if you know the selection contains exactly one element.
|
805 | */
|
806 | datum(): Datum;
|
807 | /**
|
808 | * Delete the bound data for each element in the selection.
|
809 | */
|
810 | datum(value: null): Selection<GElement, undefined, PElement, PDatum>;
|
811 | /**
|
812 | * Sets the element’s bound data using the specified value function on all selected elements.
|
813 | * Unlike selection.data, this method does not compute a join and does not affect
|
814 | * indexes or the enter and exit selections.
|
815 | *
|
816 | * The generic refers to the type of the new datum to be used for the selected elements.
|
817 | *
|
818 | * @param value A value function which is evaluated for each selected element, in order,
|
819 | * being passed the current datum (d), the current index (i), and the current group (nodes),
|
820 | * with this as the current DOM element (nodes[i]). The function is then used to set each element’s new data.
|
821 | * A null value will delete the bound data.
|
822 | */
|
823 | datum<NewDatum>(value: ValueFn<GElement, Datum, NewDatum>): Selection<GElement, NewDatum, PElement, PDatum>;
|
824 | /**
|
825 | * Sets the element’s bound data to the specified value on all selected elements.
|
826 | * Unlike selection.data, this method does not compute a join and does not affect
|
827 | * indexes or the enter and exit selections.
|
828 | *
|
829 | * The generic refers to the type of the new datum to be used for the selected elements.
|
830 | *
|
831 | * @param value A value object to be used as the datum for each element.
|
832 | */
|
833 | datum<NewDatum>(value: NewDatum): Selection<GElement, NewDatum, PElement, PDatum>;
|
834 |
|
835 | // Event Handling -------------------
|
836 |
|
837 | /**
|
838 | * Return the currently-assigned listener for the specified event typename on the first (non-null) selected element,
|
839 | * if any, If multiple typenames are specified, the first matching listener is returned.
|
840 | *
|
841 | * @param typenames The typenames is a string event type, such as click, mouseover, or submit; any DOM event type supported by your browser may be used.
|
842 | * The type may be optionally followed by a period (.) and a name; the optional name allows multiple callbacks to be registered
|
843 | * to receive events of the same type, such as click.foo and click.bar. To specify multiple typenames, separate typenames with spaces,
|
844 | * such as "input change"" or "click.foo click.bar".
|
845 | */
|
846 | on(typenames: string): ((this: GElement, event: any, d: Datum) => void) | undefined;
|
847 | /**
|
848 | * Remove a listener for the specified event type names. To remove all listeners for a given name,
|
849 | * pass null as the listener and ".foo" as the typename, where foo is the name; to remove all listeners with no name, specify "." as the typename.
|
850 | *
|
851 | * @param typenames The typenames is a string event type, such as click, mouseover, or submit; any DOM event type supported by your browser may be used.
|
852 | * The type may be optionally followed by a period (.) and a name; the optional name allows multiple callbacks to be registered
|
853 | * to receive events of the same type, such as click.foo and click.bar. To specify multiple typenames, separate typenames with spaces,
|
854 | * such as "input change"" or "click.foo click.bar".
|
855 | * @param listener null to indicate removal of listener
|
856 | */
|
857 | on(typenames: string, listener: null): this;
|
858 | /**
|
859 | * Add an event listener for the specified event type names. If an event listener was previously registered for the same typename
|
860 | * on a selected element, the old listener is removed before the new listener is added.
|
861 | *
|
862 | * When a specified event is dispatched on a selected node, the specified listener will be evaluated for each selected element.
|
863 | *
|
864 | * @param typenames The typenames is a string event type, such as click, mouseover, or submit; any DOM event type supported by your browser may be used.
|
865 | * The type may be optionally followed by a period (.) and a name; the optional name allows multiple callbacks to be registered
|
866 | * to receive events of the same type, such as click.foo and click.bar. To specify multiple typenames, separate typenames with spaces,
|
867 | * such as "input change"" or "click.foo click.bar".
|
868 | * @param listener A listener function which will be evaluated for each selected element,
|
869 | * being passed the current event (event) and the current datum (d), with this as the current DOM element (event.currentTarget).
|
870 | * Listeners always see the latest datum for their element.
|
871 | * Note: while you can use event.pageX and event.pageY directly,
|
872 | * it is often convenient to transform the event position to the local coordinate system of that element that received the event using d3.pointer.
|
873 | * @param options An optional options object may specify characteristics about the event listener, such as wehether it is captures or passive; see element.addEventListener.
|
874 | */
|
875 | on(typenames: string, listener: (this: GElement, event: any, d: Datum) => void, options?: any): this;
|
876 |
|
877 | /**
|
878 | * Dispatches a custom event of the specified type to each selected element, in order.
|
879 | * An optional parameters map may be specified to set additional properties of the event.
|
880 | *
|
881 | * @param type Name of event to dispatch
|
882 | * @param parameters An optional value map with custom event parameters
|
883 | */
|
884 | dispatch(type: string, parameters?: CustomEventParameters): this;
|
885 | /**
|
886 | * Dispatches a custom event of the specified type to each selected element, in order.
|
887 | * An optional value function returning a parameters map for each element in the selection may be specified to set additional properties of the event.
|
888 | *
|
889 | * @param type Name of event to dispatch
|
890 | * @param parameters A value function which is evaluated for each selected element, in order,
|
891 | * being passed the current datum (d), the current index (i), and the current group (nodes),
|
892 | * with this as the current DOM element (nodes[i]). It must return the parameters map for the current element.
|
893 | */
|
894 | dispatch(type: string, parameters?: ValueFn<GElement, Datum, CustomEventParameters>): this;
|
895 |
|
896 | // Control Flow ----------------------
|
897 |
|
898 | /**
|
899 | * Invoke the specified function for each selected element, passing in the current datum (d),
|
900 | * the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]).
|
901 | * This method can be used to invoke arbitrary code for each selected element, and is useful for creating a context to access parent and child data simultaneously.
|
902 | *
|
903 | * @param func A function which is invoked for each selected element,
|
904 | * being passed the current datum (d), the current index (i), and the current group (nodes), with this as the current DOM element (nodes[i]).
|
905 | */
|
906 | each(func: ValueFn<GElement, Datum, void>): this;
|
907 |
|
908 | /**
|
909 | * Invoke the specified function exactly once, passing in this selection along with any optional arguments.
|
910 | * Returns this selection.
|
911 | *
|
912 | * @param func A function which is passed this selection as the first argument along with any optional arguments.
|
913 | * @param args List of optional arguments to be passed to the callback function.
|
914 | */
|
915 | call<Args extends any[]>(
|
916 | func: (selection: Selection<GElement, Datum, PElement, PDatum>, ...args: Args) => void,
|
917 | ...args: Args
|
918 | ): this;
|
919 |
|
920 | /**
|
921 | * Return true if this selection contains no (non-null) elements.
|
922 | */
|
923 | empty(): boolean;
|
924 |
|
925 | /**
|
926 | * Return an array of all (non-null) elements in this selection.
|
927 | */
|
928 | nodes(): GElement[];
|
929 |
|
930 | /**
|
931 | * Return the first (non-null) element in this selection. If the selection is empty, returns null.
|
932 | */
|
933 | node(): GElement | null;
|
934 |
|
935 | /**
|
936 | * Returns the total number of elements in this selection.
|
937 | */
|
938 | size(): number;
|
939 |
|
940 | /**
|
941 | * Returns an iterator over the selected (non-null) elements.
|
942 | */
|
943 | [Symbol.iterator](): Iterator<GElement>;
|
944 | }
|
945 |
|
946 | /**
|
947 | * Selects the root element, document.documentElement. This function can also be used to test for selections
|
948 | * (instanceof d3.selection) or to extend the selection prototype.
|
949 | */
|
950 | export type SelectionFn = () => Selection<HTMLElement, any, null, undefined>;
|
951 |
|
952 |
|
953 |
|
954 |
|
955 |
|
956 | export const selection: SelectionFn;
|
957 |
|
958 |
|
959 |
|
960 |
|
961 |
|
962 |
|
963 |
|
964 |
|
965 |
|
966 |
|
967 |
|
968 |
|
969 |
|
970 |
|
971 |
|
972 |
|
973 |
|
974 |
|
975 | export function pointer(event: any, target?: any): [number, number];
|
976 |
|
977 |
|
978 |
|
979 |
|
980 |
|
981 |
|
982 |
|
983 |
|
984 |
|
985 |
|
986 | export function pointers(event: any, target?: any): Array<[number, number]>;
|
987 |
|
988 |
|
989 |
|
990 |
|
991 |
|
992 |
|
993 |
|
994 |
|
995 |
|
996 |
|
997 |
|
998 |
|
999 |
|
1000 | export function style(node: Element, name: string): string;
|
1001 |
|
1002 |
|
1003 |
|
1004 |
|
1005 |
|
1006 | export interface Local<T> {
|
1007 | |
1008 |
|
1009 |
|
1010 |
|
1011 |
|
1012 | get(node: Element): T | undefined;
|
1013 | |
1014 |
|
1015 |
|
1016 |
|
1017 |
|
1018 |
|
1019 |
|
1020 | remove(node: Element): boolean;
|
1021 | |
1022 |
|
1023 |
|
1024 |
|
1025 |
|
1026 |
|
1027 | set(node: Element, value: T): T;
|
1028 | |
1029 |
|
1030 |
|
1031 |
|
1032 | toString(): string;
|
1033 | }
|
1034 |
|
1035 |
|
1036 |
|
1037 |
|
1038 |
|
1039 |
|
1040 |
|
1041 | export function local<T>(): Local<T>;
|
1042 |
|
1043 |
|
1044 |
|
1045 |
|
1046 |
|
1047 |
|
1048 |
|
1049 |
|
1050 | export interface NamespaceLocalObject {
|
1051 | |
1052 |
|
1053 |
|
1054 | space: string;
|
1055 | |
1056 |
|
1057 |
|
1058 | local: string;
|
1059 | }
|
1060 |
|
1061 |
|
1062 |
|
1063 |
|
1064 |
|
1065 |
|
1066 |
|
1067 |
|
1068 |
|
1069 |
|
1070 | export function namespace(prefixedLocal: string): NamespaceLocalObject | string;
|
1071 |
|
1072 |
|
1073 |
|
1074 |
|
1075 |
|
1076 |
|
1077 |
|
1078 |
|
1079 | export interface NamespaceMap {
|
1080 | [prefix: string]: string;
|
1081 | }
|
1082 |
|
1083 |
|
1084 |
|
1085 |
|
1086 | export const namespaces: NamespaceMap;
|
1087 |
|
1088 |
|
1089 |
|
1090 |
|
1091 |
|
1092 |
|
1093 |
|
1094 |
|
1095 |
|
1096 |
|
1097 |
|
1098 | export function window(DOMNode: Window | Document | Element): Window;
|
1099 |
|
1100 |
|
1101 |
|
1102 |
|
1103 |
|
1104 |
|
1105 |
|
1106 |
|
1107 |
|
1108 |
|
1109 |
|
1110 |
|
1111 | export function create<K extends keyof ElementTagNameMap>(
|
1112 | name: K,
|
1113 | ): Selection<ElementTagNameMap[K], undefined, null, undefined>;
|
1114 |
|
1115 |
|
1116 |
|
1117 |
|
1118 |
|
1119 |
|
1120 |
|
1121 |
|
1122 | export function create<NewGElement extends Element>(name: string): Selection<NewGElement, undefined, null, undefined>;
|
1123 |
|
1124 |
|
1125 |
|
1126 |
|
1127 |
|
1128 |
|
1129 |
|
1130 | export function creator<K extends keyof ElementTagNameMap>(name: K): (this: BaseType) => ElementTagNameMap[K];
|
1131 |
|
1132 |
|
1133 |
|
1134 |
|
1135 |
|
1136 |
|
1137 |
|
1138 |
|
1139 |
|
1140 |
|
1141 | export function creator<NewGElement extends Element>(name: string): (this: BaseType) => NewGElement;
|
1142 |
|
1143 |
|
1144 |
|
1145 |
|
1146 |
|
1147 |
|
1148 | export function matcher(selector: string): (this: BaseType) => boolean;
|
1149 |
|
1150 |
|
1151 |
|
1152 |
|
1153 |
|
1154 |
|
1155 |
|
1156 |
|
1157 |
|
1158 |
|
1159 |
|
1160 |
|
1161 |
|
1162 |
|
1163 | export function selector<DescElement extends Element>(selector: string): (this: BaseType) => DescElement;
|
1164 |
|
1165 |
|
1166 |
|
1167 |
|
1168 |
|
1169 |
|
1170 |
|
1171 |
|
1172 |
|
1173 | export function selectorAll<DescElement extends Element>(selector: string): (this: BaseType) => NodeListOf<DescElement>;
|