tooltip.d.ts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import { default as default_2 } from '@thednp/position-observer';
  2. import { TouchEvent as TouchEvent_2 } from '@thednp/shorty';
  3. /** Returns a new `BaseComponent` instance. */
  4. declare class BaseComponent {
  5. element: Element;
  6. options?: BaseOptions;
  7. /**
  8. * @param target `Element` or selector string
  9. * @param config component instance options
  10. */
  11. constructor(target: Element | string, config?: BaseOptions);
  12. get version(): string;
  13. get name(): string;
  14. get defaults(): {};
  15. /** just to have something to extend from */
  16. _toggleEventListeners: () => void;
  17. /** Removes component from target element. */
  18. dispose(): void;
  19. }
  20. declare interface BaseOptions {
  21. [key: string]: unknown;
  22. }
  23. /** Creates a new `Tooltip` instance. */
  24. declare class Tooltip extends BaseComponent {
  25. static selector: string;
  26. static init: (element: Element) => Tooltip;
  27. static getInstance: (element: Element) => Tooltip | null;
  28. static styleTip: (self: Tooltip) => void;
  29. element: Element & HTMLOrSVGElement;
  30. options: TooltipOptions;
  31. btn?: HTMLElement;
  32. tooltip: HTMLElement;
  33. container: HTMLElement;
  34. offsetParent: Element | Window;
  35. arrow: HTMLElement;
  36. enabled: boolean;
  37. id: string;
  38. _observer: default_2;
  39. /**
  40. * @param target the target element
  41. * @param config the instance options
  42. */
  43. constructor(target: Element | string, config?: Partial<TooltipOptions>);
  44. /**
  45. * Returns component name string.
  46. */
  47. get name(): string;
  48. /**
  49. * Returns component default options.
  50. */
  51. get defaults(): TooltipOptions;
  52. /** Handles the focus event on iOS. */
  53. handleFocus: () => void;
  54. /** Shows the tooltip. */
  55. handleShow: () => void;
  56. show(): void;
  57. /** Hides the tooltip. */
  58. handleHide: () => void;
  59. hide(): void;
  60. /** Updates the tooltip position. */
  61. update: () => void;
  62. /** Toggles the tooltip visibility. */
  63. toggle: () => void;
  64. /** Enables the tooltip. */
  65. enable(): void;
  66. /** Disables the tooltip. */
  67. disable(): void;
  68. /** Toggles the `disabled` property. */
  69. toggleEnabled(): void;
  70. /**
  71. * Handles the `touchstart` event listener for `Tooltip`
  72. *
  73. * @this {Tooltip}
  74. * @param {TouchEvent} e the `Event` object
  75. */
  76. handleTouch: ({ target }: TouchEvent_2) => void;
  77. /**
  78. * Toggles on/off the `Tooltip` event listeners.
  79. *
  80. * @param add when `true`, event listeners are added
  81. */
  82. _toggleEventListeners: (add?: boolean) => void;
  83. /** Removes the `Tooltip` from the target element. */
  84. dispose(): void;
  85. }
  86. export default Tooltip;
  87. declare interface TooltipOptions extends BaseOptions {
  88. template: string | HTMLElement;
  89. title: string | HTMLElement;
  90. customClass: string;
  91. trigger: string;
  92. placement: "top" | "bottom" | "left" | "right";
  93. sanitizeFn?: (str: string) => string;
  94. animation: boolean;
  95. delay: number;
  96. content: string | HTMLElement;
  97. dismissible: boolean;
  98. btnClose: string | HTMLElement;
  99. }
  100. export { }