toast.d.ts 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /** Returns a new `BaseComponent` instance. */
  2. declare class BaseComponent {
  3. element: Element;
  4. options?: BaseOptions;
  5. /**
  6. * @param target `Element` or selector string
  7. * @param config component instance options
  8. */
  9. constructor(target: Element | string, config?: BaseOptions);
  10. get version(): string;
  11. get name(): string;
  12. get defaults(): {};
  13. /** just to have something to extend from */
  14. _toggleEventListeners: () => void;
  15. /** Removes component from target element. */
  16. dispose(): void;
  17. }
  18. declare interface BaseOptions {
  19. [key: string]: unknown;
  20. }
  21. /** Creates a new `Toast` instance. */
  22. declare class Toast extends BaseComponent {
  23. static selector: string;
  24. static init: (element: Element) => Toast;
  25. static getInstance: (element: Element) => Toast | null;
  26. element: HTMLElement;
  27. options: ToastOptions;
  28. dismiss: HTMLElement | null;
  29. triggers: HTMLElement[];
  30. relatedTarget: HTMLElement | null;
  31. /**
  32. * @param target the target `.toast` element
  33. * @param config the instance options
  34. */
  35. constructor(target: Element | string, config?: Partial<ToastOptions>);
  36. /**
  37. * Returns component name string.
  38. */
  39. get name(): string;
  40. /**
  41. * Returns component default options.
  42. */
  43. get defaults(): {
  44. animation: boolean;
  45. autohide: boolean;
  46. delay: number;
  47. };
  48. /**
  49. * Returns *true* when toast is visible.
  50. */
  51. get isShown(): boolean;
  52. /** Shows the toast. */
  53. show: () => void;
  54. /** Hides the toast. */
  55. hide: () => void;
  56. /**
  57. * Toggles on/off the `click` event listener.
  58. *
  59. * @param add when `true`, it will add the listener
  60. */
  61. _toggleEventListeners: (add?: boolean) => void;
  62. /** Removes the `Toast` component from the target element. */
  63. dispose(): void;
  64. }
  65. export default Toast;
  66. declare interface ToastOptions extends BaseOptions {
  67. animation: boolean;
  68. autohide: boolean;
  69. delay: number;
  70. }
  71. export { }