index.d.ts 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. import { DisplayObject, Group } from '../../shapes';
  2. import { GUI } from '../../core';
  3. import type { PoptipStyleProps, PoptipOptions } from './types';
  4. export type { PoptipStyleProps as PoptipCfg, PoptipOptions };
  5. export { getPositionXY } from './utils';
  6. type PoptipCallbackOptions = {
  7. html?: string;
  8. target?: HTMLElement | DisplayObject | false;
  9. } & Pick<PoptipStyleProps, 'position' | 'arrowPointAtCenter' | 'follow' | 'offset'>;
  10. export declare class Poptip extends GUI<PoptipStyleProps> {
  11. static tag: string;
  12. get visible(): boolean;
  13. private static defaultOptions;
  14. /** 容器 HTML 元素节点 */
  15. private container;
  16. /** 显影控制 */
  17. private visibility;
  18. /** 所有绑定的目标对象 */
  19. private map;
  20. /** 节点样式 */
  21. private domStyles;
  22. constructor(options: PoptipOptions);
  23. render(attributes: PoptipStyleProps, container: Group): void;
  24. /**
  25. * poptip 组件更新
  26. */
  27. update(cfg?: Partial<PoptipStyleProps>): void;
  28. /**
  29. * 绑定元素
  30. */
  31. bind(element: HTMLElement | DisplayObject, callback?: PoptipCallbackOptions | ((e: any) => PoptipCallbackOptions)): void;
  32. unbind(element: HTMLElement | DisplayObject): void;
  33. /**
  34. * 清空容器内容
  35. */
  36. clear(): void;
  37. /**
  38. * 清除
  39. */
  40. destroy(): void;
  41. /**
  42. * 显示 + 改变位置
  43. * @param x 可选 改变位置 x 方向
  44. * @param y 可选 改变位置 y 方向
  45. * @param text 文本变化
  46. */
  47. showTip(x?: number, y?: number, options?: Pick<PoptipStyleProps, 'text' | 'position' | 'offset'>): void;
  48. /**
  49. * 隐藏
  50. */
  51. hideTip(): void;
  52. /**
  53. * 获取内部容器 HTMLElement
  54. * @returns this.element:HTMLElement;
  55. */
  56. getContainer(): HTMLElement;
  57. getClassName(): string;
  58. /**
  59. * 初始化容器
  60. */
  61. private initShape;
  62. /**
  63. * 更新 HTML 上的内容
  64. */
  65. private updatePoptipElement;
  66. /**
  67. * 应用样式表
  68. */
  69. private applyStyles;
  70. /**
  71. * 将相对于指针的偏移量生效到dom元素上
  72. * @param x 盒子相对于页面 x 的位置
  73. * @param y 盒子相对于页面 y 的位置
  74. */
  75. private setOffsetPosition;
  76. }