index.d.ts 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /**
  2. * Append a node to an element
  3. *
  4. * @param {SVGElement} element
  5. * @param {SVGElement} node
  6. *
  7. * @return {SVGElement} the element
  8. */
  9. export function append(element: Element, node: SVGElement): typeof element;
  10. /**
  11. * Append a node to a target element and return the appended node.
  12. *
  13. * @param {SVGElement} element
  14. * @param {SVGElement} node
  15. *
  16. * @return {SVGElement} the appended node
  17. */
  18. export function appendTo(element: Element, target: SVGElement): typeof element;
  19. /**
  20. * Prepend a node to an element
  21. *
  22. * @param {SVGElement} element
  23. * @param {SVGElement} node
  24. *
  25. * @return {SVGElement} the element
  26. */
  27. export function prepend(element: Element, node: SVGElement): typeof element;
  28. /**
  29. * Prepend a node to a target element and return the prepended node.
  30. *
  31. * @param {SVGElement} element
  32. * @param {SVGElement} node
  33. *
  34. * @return {SVGElement} the prepended node
  35. */
  36. export function prependTo(element: Element, target: SVGElement): typeof element;
  37. export interface KeyValue {
  38. [key: string]: any;
  39. }
  40. export function attr(node: SVGElement, name: string): string;
  41. export function attr(node: SVGElement, name: string, value: number | string): typeof node;
  42. export function attr(node: SVGElement, attrs: KeyValue): typeof node;
  43. export function attr(node: SVGElement, name: string, value: number | string): typeof node | string;
  44. /**
  45. * Wrap `el` in a `ClassList`.
  46. *
  47. * @param {Element} el
  48. * @return {ClassList}
  49. * @api public
  50. */
  51. export function classes<T extends Element>(el: T): ClassList<T>;
  52. export class ClassList<T extends Element> {
  53. public list: T["classList"];
  54. public el: T;
  55. constructor(el: T);
  56. add(name: string): this;
  57. remove(name: string | RegExp): this;
  58. removeMatching(re: RegExp): this;
  59. toggle(name: string, force?: boolean): this;
  60. array(): string[];
  61. has(name: string): boolean;
  62. contains(name: string): boolean;
  63. }
  64. /**
  65. * Removes all children from the given element
  66. *
  67. * @param {DOMElement} element
  68. * @return {DOMElement} the element (for chaining)
  69. */
  70. export function clear<T extends Element>(element: T): T;
  71. export function clone<T extends Node>(element: T): T;
  72. /**
  73. * Create a specific type from name or SVG markup.
  74. *
  75. * @param {String} name the name or markup of the element
  76. * @param {Object} [attrs] attributes to set on the element
  77. *
  78. * @returns {SVGElement}
  79. */
  80. export function create(name: "a"): SVGAElement;
  81. export function create(name: "circle"): SVGCircleElement;
  82. export function create(name: "clipPath"): SVGClipPathElement;
  83. export function create(name: "componentTransferFunction"): SVGComponentTransferFunctionElement;
  84. export function create(name: "defs"): SVGDefsElement;
  85. export function create(name: "desc"): SVGDescElement;
  86. export function create(name: "ellipse"): SVGEllipseElement;
  87. export function create(name: "feBlend"): SVGFEBlendElement;
  88. export function create(name: "feColorMatrix"): SVGFEColorMatrixElement;
  89. export function create(name: "feComponentTransfer"): SVGFEComponentTransferElement;
  90. export function create(name: "feComposite"): SVGFECompositeElement;
  91. export function create(name: "feConvolveMatrix"): SVGFEConvolveMatrixElement;
  92. export function create(name: "feDiffuseLighting"): SVGFEDiffuseLightingElement;
  93. export function create(name: "feDisplacementMap"): SVGFEDisplacementMapElement;
  94. export function create(name: "feDistantLight"): SVGFEDistantLightElement;
  95. export function create(name: "feFlood"): SVGFEFloodElement;
  96. export function create(name: "feFuncA"): SVGFEFuncAElement;
  97. export function create(name: "feFuncB"): SVGFEFuncBElement;
  98. export function create(name: "feFuncG"): SVGFEFuncGElement;
  99. export function create(name: "feFuncR"): SVGFEFuncRElement;
  100. export function create(name: "feGaussianBlur"): SVGFEGaussianBlurElement;
  101. export function create(name: "feImage"): SVGFEImageElement;
  102. export function create(name: "feMerge"): SVGFEMergeElement;
  103. export function create(name: "feMergeNode"): SVGFEMergeNodeElement;
  104. export function create(name: "feMorphology"): SVGFEMorphologyElement;
  105. export function create(name: "feOffset"): SVGFEOffsetElement;
  106. export function create(name: "fePointLight"): SVGFEPointLightElement;
  107. export function create(name: "feSpecularLighting"): SVGFESpecularLightingElement;
  108. export function create(name: "feSpotLight"): SVGFESpotLightElement;
  109. export function create(name: "feTile"): SVGFETileElement;
  110. export function create(name: "feTurbulence"): SVGFETurbulenceElement;
  111. export function create(name: "filter"): SVGFilterElement;
  112. export function create(name: "foreignObject"): SVGForeignObjectElement;
  113. export function create(name: "g"): SVGGElement;
  114. export function create(name: "image"): SVGImageElement;
  115. export function create(name: "gradient"): SVGGradientElement;
  116. export function create(name: "line"): SVGLineElement;
  117. export function create(name: "linearGradient"): SVGLinearGradientElement;
  118. export function create(name: "marker"): SVGMarkerElement;
  119. export function create(name: "mask"): SVGMaskElement;
  120. export function create(name: "path"): SVGPathElement;
  121. export function create(name: "metadata"): SVGMetadataElement;
  122. export function create(name: "pattern"): SVGPatternElement;
  123. export function create(name: "polygon"): SVGPolygonElement;
  124. export function create(name: "polyline"): SVGPolylineElement;
  125. export function create(name: "radialGradient"): SVGRadialGradientElement;
  126. export function create(name: "rect"): SVGRectElement;
  127. export function create(name: "svg"): SVGSVGElement;
  128. export function create(name: "script"): SVGScriptElement;
  129. export function create(name: "stop"): SVGStopElement;
  130. export function create(name: "style"): SVGStyleElement;
  131. export function create(name: "switch"): SVGSwitchElement;
  132. export function create(name: "symbol"): SVGSymbolElement;
  133. export function create(name: "tspan"): SVGTSpanElement;
  134. export function create(name: "textContent"): SVGTextContentElement;
  135. export function create(name: "text"): SVGTextElement;
  136. export function create(name: "textPath"): SVGTextPathElement;
  137. export function create(name: "textPositioning"): SVGTextPositioningElement;
  138. export function create(name: "title"): SVGTitleElement;
  139. export function create(name: "use"): SVGUseElement;
  140. export function create(name: "view"): SVGViewElement;
  141. export function create(name: string): SVGElement;
  142. export function create(name: string, attrs?: KeyValue): Element;
  143. export function on(node: Node, event: string, listener: Function, useCapture?: boolean): void;
  144. export function off(node: Node, event: string, listener: Function, useCapture?: boolean): void;
  145. export function createPoint(): SVGPoint;
  146. export function createPoint(x: number, y: number): SVGPoint;
  147. export function createMatrix(): SVGMatrix;
  148. export function createMatrix(a: number, b: number, c: number, d: number, e: number, f: number): SVGMatrix;
  149. export function createTransform(matrix?: SVGMatrix): SVGTransform;
  150. export function innerSVG(element: Element, svg: string): typeof element;
  151. export function innerSVG(element: Element): string;
  152. export function innerSVG(element: Element, svg?: string): typeof element | string;
  153. export function select(node: Node, selector: string): Node | null;
  154. export function select<K extends keyof HTMLElementTagNameMap>(node: K, selector: string): HTMLElementTagNameMap[K] | null;
  155. export function select<K extends keyof SVGElementTagNameMap>(node: K, selector: string): SVGElementTagNameMap[K] | null;
  156. export function select<E extends Element = Element>(node: E, selector: string): E | null;
  157. export function selectAll<K extends keyof HTMLElementTagNameMap>(node: K, selector: string): HTMLElementTagNameMap[K][];
  158. export function selectAll<K extends keyof SVGElementTagNameMap>(node: K, selector: string): SVGElementTagNameMap[K][];
  159. export function selectAll<E extends Element = Element>(node: E, selector: string): E[];
  160. export function remove(el: Node): void;
  161. export function replace(element: Node, replacement: Node): typeof replacement;
  162. export function transform(node: Node): SVGTransform;
  163. export function transform(node: Node, transforms?: SVGTransform | SVGTransform[]): SVGTransform | void;