tool.d.ts 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. import { Dom, KeyValue } from '@antv/x6-common';
  2. import { NodeTool, EdgeTool } from '../registry/tool';
  3. import { View } from './view';
  4. import { CellView } from './cell';
  5. import { Markup } from './markup';
  6. export declare class ToolsView extends View {
  7. tools: ToolsView.ToolItem[] | null;
  8. options: ToolsView.Options;
  9. cellView: CellView;
  10. svgContainer: SVGGElement;
  11. htmlContainer: HTMLDivElement;
  12. get name(): string | undefined;
  13. get graph(): import("..").Graph;
  14. get cell(): import("..").Cell<import("..").Cell.Properties>;
  15. protected get [Symbol.toStringTag](): string;
  16. constructor(options?: ToolsView.Options);
  17. protected createContainer(svg: boolean, options: ToolsView.Options): SVGElement | HTMLElement;
  18. config(options: ToolsView.ConfigOptions): this;
  19. update(options?: ToolsView.UpdateOptions): this;
  20. focus(focusedTool: ToolsView.ToolItem | null): this;
  21. blur(blurredTool: ToolsView.ToolItem | null): this;
  22. hide(): this;
  23. show(): this;
  24. remove(): this;
  25. mount(): this;
  26. }
  27. export declare namespace ToolsView {
  28. interface Options extends ConfigOptions {
  29. className?: string;
  30. }
  31. interface ConfigOptions {
  32. view?: CellView;
  33. name?: string;
  34. local?: boolean;
  35. items?: (ToolItem | string | NodeTool.NativeNames | NodeTool.NativeItem | NodeTool.ManaualItem | EdgeTool.NativeNames | EdgeTool.NativeItem | EdgeTool.ManaualItem)[] | null;
  36. }
  37. interface UpdateOptions {
  38. toolId?: string;
  39. }
  40. }
  41. export declare namespace ToolsView {
  42. const toStringTag: string;
  43. function isToolsView(instance: any): instance is ToolsView;
  44. }
  45. export declare namespace ToolsView {
  46. class ToolItem<TargetView extends CellView = CellView, Options extends ToolItem.Options = ToolItem.Options> extends View {
  47. protected static defaults: ToolItem.Options;
  48. static getDefaults<T extends ToolItem.Options>(): T;
  49. static config<T extends ToolItem.Options = ToolItem.Options>(options: Partial<T>): void;
  50. static getOptions<T extends ToolItem.Options = ToolItem.Options>(options: Partial<T>): T;
  51. readonly options: Options;
  52. container: HTMLElement | SVGElement;
  53. parent: ToolsView;
  54. protected cellView: TargetView;
  55. protected visible: boolean;
  56. protected childNodes: KeyValue<Element>;
  57. get graph(): import("..").Graph;
  58. get cell(): import("..").Cell<import("..").Cell.Properties>;
  59. get name(): string | undefined;
  60. protected get [Symbol.toStringTag](): string;
  61. constructor(options?: Partial<Options>);
  62. protected init(): void;
  63. protected getOptions(options: Partial<Options>): Options;
  64. delegateEvents(): this;
  65. config(view: CellView, toolsView: ToolsView): this;
  66. render(): this;
  67. protected onRender(): void;
  68. update(): this;
  69. protected stamp(elem: Element): void;
  70. show(): this;
  71. hide(): this;
  72. isVisible(): boolean;
  73. focus(): this;
  74. blur(): this;
  75. protected guard(evt: Dom.EventObject): any;
  76. }
  77. namespace ToolItem {
  78. interface Options {
  79. name?: string;
  80. tagName?: string;
  81. isSVGElement?: boolean;
  82. className?: string;
  83. markup?: Exclude<Markup, string>;
  84. events?: View.Events | null;
  85. documentEvents?: View.Events | null;
  86. focusOpacity?: number;
  87. }
  88. }
  89. namespace ToolItem {
  90. type Definition = typeof ToolItem | (new (options: ToolItem.Options) => ToolItem);
  91. function define<T extends Options>(options: T): typeof ToolItem;
  92. }
  93. namespace ToolItem {
  94. const toStringTag: string;
  95. function isToolItem(instance: any): instance is ToolItem;
  96. }
  97. }