popover.d.ts 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. /** Returns a new `Popover` instance. */
  24. declare class Popover extends Tooltip {
  25. static selector: string;
  26. static init: (element: Element) => Popover;
  27. static getInstance: (element: Element) => Popover | null;
  28. static styleTip: (self: Tooltip) => void;
  29. options: PopoverOptions;
  30. /**
  31. * @param target the target element
  32. * @param config the instance options
  33. */
  34. constructor(target: Element | string, config?: Partial<PopoverOptions>);
  35. /**
  36. * Returns component name string.
  37. */
  38. get name(): string;
  39. /**
  40. * Returns component default options.
  41. */
  42. get defaults(): PopoverOptions;
  43. show: () => void;
  44. }
  45. export default Popover;
  46. declare interface PopoverOptions extends TooltipOptions {
  47. title: string | HTMLElement;
  48. content: string | HTMLElement;
  49. btnClose: string | HTMLElement;
  50. dismissible: boolean;
  51. }
  52. /** Creates a new `Tooltip` instance. */
  53. declare class Tooltip extends BaseComponent {
  54. static selector: string;
  55. static init: (element: Element) => Tooltip;
  56. static getInstance: (element: Element) => Tooltip | null;
  57. static styleTip: (self: Tooltip) => void;
  58. element: Element & HTMLOrSVGElement;
  59. options: TooltipOptions;
  60. btn?: HTMLElement;
  61. tooltip: HTMLElement;
  62. container: HTMLElement;
  63. offsetParent: Element | Window;
  64. arrow: HTMLElement;
  65. enabled: boolean;
  66. id: string;
  67. _observer: default_2;
  68. /**
  69. * @param target the target element
  70. * @param config the instance options
  71. */
  72. constructor(target: Element | string, config?: Partial<TooltipOptions>);
  73. /**
  74. * Returns component name string.
  75. */
  76. get name(): string;
  77. /**
  78. * Returns component default options.
  79. */
  80. get defaults(): TooltipOptions;
  81. /** Handles the focus event on iOS. */
  82. handleFocus: () => void;
  83. /** Shows the tooltip. */
  84. handleShow: () => void;
  85. show(): void;
  86. /** Hides the tooltip. */
  87. handleHide: () => void;
  88. hide(): void;
  89. /** Updates the tooltip position. */
  90. update: () => void;
  91. /** Toggles the tooltip visibility. */
  92. toggle: () => void;
  93. /** Enables the tooltip. */
  94. enable(): void;
  95. /** Disables the tooltip. */
  96. disable(): void;
  97. /** Toggles the `disabled` property. */
  98. toggleEnabled(): void;
  99. /**
  100. * Handles the `touchstart` event listener for `Tooltip`
  101. *
  102. * @this {Tooltip}
  103. * @param {TouchEvent} e the `Event` object
  104. */
  105. handleTouch: ({ target }: TouchEvent_2) => void;
  106. /**
  107. * Toggles on/off the `Tooltip` event listeners.
  108. *
  109. * @param add when `true`, event listeners are added
  110. */
  111. _toggleEventListeners: (add?: boolean) => void;
  112. /** Removes the `Tooltip` from the target element. */
  113. dispose(): void;
  114. }
  115. declare interface TooltipOptions extends BaseOptions {
  116. template: string | HTMLElement;
  117. title: string | HTMLElement;
  118. customClass: string;
  119. trigger: string;
  120. placement: "top" | "bottom" | "left" | "right";
  121. sanitizeFn?: (str: string) => string;
  122. animation: boolean;
  123. delay: number;
  124. content: string | HTMLElement;
  125. dismissible: boolean;
  126. btnClose: string | HTMLElement;
  127. }
  128. export { }