alert.d.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import { PointerEvent as PointerEvent_2 } from '@thednp/shorty';
  2. /** Creates a new Alert instance. */
  3. declare class Alert extends BaseComponent {
  4. static selector: string;
  5. static init: (element: Element) => Alert;
  6. static getInstance: (element: Element) => Alert | null;
  7. dismiss: HTMLElement | null;
  8. constructor(target: Element | string);
  9. /** Returns component name string. */
  10. get name(): string;
  11. /**
  12. * Public method that hides the `.alert` element from the user,
  13. * disposes the instance once animation is complete, then
  14. * removes the element from the DOM.
  15. */
  16. close: (e: PointerEvent_2<HTMLElement>) => void;
  17. /**
  18. * Toggle on / off the `click` event listener.
  19. *
  20. * @param add when `true`, event listener is added
  21. */
  22. _toggleEventListeners: (add?: boolean) => void;
  23. /** Remove the component from target element. */
  24. dispose(): void;
  25. }
  26. export default Alert;
  27. /** Returns a new `BaseComponent` instance. */
  28. declare class BaseComponent {
  29. element: Element;
  30. options?: BaseOptions;
  31. /**
  32. * @param target `Element` or selector string
  33. * @param config component instance options
  34. */
  35. constructor(target: Element | string, config?: BaseOptions);
  36. get version(): string;
  37. get name(): string;
  38. get defaults(): {};
  39. /** just to have something to extend from */
  40. _toggleEventListeners: () => void;
  41. /** Removes component from target element. */
  42. dispose(): void;
  43. }
  44. declare interface BaseOptions {
  45. [key: string]: unknown;
  46. }
  47. export { }